Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -824,56 +824,57 @@ def project_extraction(project_description):
|
|
824 |
# task_analysis, reasoning_path = generate_reasoning_path(project_description, task_description)
|
825 |
|
826 |
# steps = store_and_execute_task(task_description, reasoning_path)
|
827 |
-
def message_back(task_message, execution_status, doc_url, from_whatsapp):
|
828 |
-
# Convert task steps to a simple numbered list
|
829 |
-
task_steps_list = "\n".join(
|
830 |
-
[f"{i + 1}. {step['action']} - {step.get('output', '')}" for i, step in enumerate(execution_status.to_dict(orient="records"))]
|
831 |
-
)
|
832 |
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
)
|
839 |
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
)
|
847 |
-
except Exception as e:
|
848 |
-
logger.error(f"Twilio Error: {e}")
|
849 |
-
raise HTTPException(status_code=500, detail=f"Error sending WhatsApp message: {str(e)}")
|
850 |
|
851 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
852 |
|
853 |
-
#
|
854 |
-
whisper_pipeline = pipeline("automatic-speech-recognition", model="openai/whisper-medium")
|
855 |
|
856 |
-
#
|
857 |
-
|
858 |
-
try:
|
859 |
-
media_response = requests.get(media_url, auth=HTTPBasicAuth(account_sid, auth_token))
|
860 |
-
# Download the media file
|
861 |
-
media_response.raise_for_status()
|
862 |
-
audio_data = media_response.content
|
863 |
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
|
|
|
|
|
|
868 |
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
|
874 |
-
|
875 |
-
|
876 |
-
|
|
|
|
|
|
|
|
|
|
|
877 |
|
878 |
|
879 |
# In[18]:
|
|
|
824 |
# task_analysis, reasoning_path = generate_reasoning_path(project_description, task_description)
|
825 |
|
826 |
# steps = store_and_execute_task(task_description, reasoning_path)
|
|
|
|
|
|
|
|
|
|
|
827 |
|
828 |
+
# def message_back(task_message, execution_status, doc_url, from_whatsapp):
|
829 |
+
# # Convert task steps to a simple numbered list
|
830 |
+
# task_steps_list = "\n".join(
|
831 |
+
# [f"{i + 1}. {step['action']} - {step.get('output', '')}" for i, step in enumerate(execution_status.to_dict(orient="records"))]
|
832 |
+
# )
|
|
|
833 |
|
834 |
+
# # Format the body message
|
835 |
+
# body_message = (
|
836 |
+
# f"*Task Message:*\n{task_message}\n\n"
|
837 |
+
# f"*Execution Status:*\n{task_steps_list}\n\n"
|
838 |
+
# f"*Doc URL:*\n{doc_url}\n\n"
|
839 |
+
# )
|
|
|
|
|
|
|
|
|
840 |
|
841 |
+
# # Send response back to WhatsApp
|
842 |
+
# try:
|
843 |
+
# twillo_client.messages.create(
|
844 |
+
# from_=twilio_phone_number,
|
845 |
+
# to=from_whatsapp,
|
846 |
+
# body=body_message
|
847 |
+
# )
|
848 |
+
# except Exception as e:
|
849 |
+
# logger.error(f"Twilio Error: {e}")
|
850 |
+
# raise HTTPException(status_code=500, detail=f"Error sending WhatsApp message: {str(e)}")
|
851 |
|
852 |
+
# return {"status": "success"}
|
|
|
853 |
|
854 |
+
# # Initialize the Whisper pipeline
|
855 |
+
# whisper_pipeline = pipeline("automatic-speech-recognition", model="openai/whisper-medium")
|
|
|
|
|
|
|
|
|
|
|
856 |
|
857 |
+
# # Function to transcribe audio from a media URL
|
858 |
+
# def transcribe_audio_from_media_url(media_url):
|
859 |
+
# try:
|
860 |
+
# media_response = requests.get(media_url, auth=HTTPBasicAuth(account_sid, auth_token))
|
861 |
+
# # Download the media file
|
862 |
+
# media_response.raise_for_status()
|
863 |
+
# audio_data = media_response.content
|
864 |
|
865 |
+
# # Save the audio data to a file for processing
|
866 |
+
# audio_file_path = "temp_audio_file.mp3"
|
867 |
+
# with open(audio_file_path, "wb") as audio_file:
|
868 |
+
# audio_file.write(audio_data)
|
869 |
|
870 |
+
# # Transcribe the audio using Whisper
|
871 |
+
# transcription = whisper_pipeline(audio_file_path, return_timestamps=True)
|
872 |
+
# logger.debug(f"Transcription: {transcription['text']}")
|
873 |
+
# return transcription["text"]
|
874 |
+
|
875 |
+
# except Exception as e:
|
876 |
+
# logger.error(f"An error occurred: {e}")
|
877 |
+
# return None
|
878 |
|
879 |
|
880 |
# In[18]:
|