Skip to content

Commit

Permalink
little changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrumilp12 committed Jun 16, 2024
1 parent 28597b5 commit 6f8448c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 0 additions & 5 deletions server/agents/mental_health_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,7 @@ def get_initial_greeting(self, user_id):
except StopIteration:
last_turn = {}

# Check if 'SessionId' is in last_turn and extract old_chat_id
if 'SessionId' in last_turn:
old_chat_id = int(last_turn["SessionId"].split('-')[-1])
else:
# Initialize old_chat_id if SessionId is not found
old_chat_id = 0

new_chat_id = old_chat_id + 1

Expand Down
6 changes: 5 additions & 1 deletion server/routes/ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ def get_mental_health_agent_welcome(user_id):
user_id=user_id
)

return response
if response is None:
logger.error(f"No greeting found for user {user_id}")
return jsonify({"error": "Greeting not found"}), 404

return jsonify(response), 200


@ai_routes.post("/ai/mental_health/<user_id>/<chat_id>")
Expand Down
4 changes: 3 additions & 1 deletion server/services/speech_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import io
import subprocess
import os
from dotenv import load_dotenv
load_dotenv() # This loads the environment variables from the .env file into the environment

def check_ffmpeg():
try:
Expand Down Expand Up @@ -46,7 +48,7 @@ def speech_to_text(audio_file):
audio_stream.seek(0)
print(f"Size of audio file: {audio_stream.getbuffer().nbytes} bytes")
# Set up the speech config with your subscription details
speech_key = os.environ.get("SPEECH_KEY")
speech_key = os.environ.get("SPEECH_AI_KEY")
service_region = os.environ.get("SERVICE_REGION")
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
speech_config.set_property(speechsdk.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs, "5000") # Timeout in milliseconds
Expand Down

0 comments on commit 6f8448c

Please sign in to comment.