Dua Rajper commited on
Commit
5cce8b9
·
verified ·
1 Parent(s): ae8b1c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -82,7 +82,7 @@ if webrtc_ctx.audio_processor:
82
  speech, _ = sf.read("recorded_audio.wav")
83
  output = stt_pipe(speech) # Transcribe with timestamps
84
 
85
- # Display the full transcribed text
86
  st.write("Transcribed Text:", output['text'])
87
 
88
  # Display the text with timestamps (optional)
@@ -93,17 +93,30 @@ if webrtc_ctx.audio_processor:
93
 
94
  # Generate response using Groq API
95
  try:
 
 
 
96
  chat_completion = groq_client.chat.completions.create(
97
  messages=[{"role": "user", "content": output['text']}],
98
  model="mixtral-8x7b-32768",
99
  temperature=0.5,
100
  max_tokens=1024
101
  )
 
 
 
 
 
102
  response = chat_completion.choices[0].message.content
103
  st.write("Generated Response:", response)
104
 
105
  # Convert response to speech
106
  speech, *_ = tts_model(response, spembs=tts_model.spembs[0]) # Use the first speaker embedding
 
 
 
 
 
107
  sf.write("response.wav", speech, 22050)
108
  st.audio("response.wav")
109
  except Exception as e:
 
82
  speech, _ = sf.read("recorded_audio.wav")
83
  output = stt_pipe(speech) # Transcribe with timestamps
84
 
85
+ # Debug: Print the transcribed text
86
  st.write("Transcribed Text:", output['text'])
87
 
88
  # Display the text with timestamps (optional)
 
93
 
94
  # Generate response using Groq API
95
  try:
96
+ # Debug: Print the input text
97
+ st.write("Input Text:", output['text'])
98
+
99
  chat_completion = groq_client.chat.completions.create(
100
  messages=[{"role": "user", "content": output['text']}],
101
  model="mixtral-8x7b-32768",
102
  temperature=0.5,
103
  max_tokens=1024
104
  )
105
+
106
+ # Debug: Print the API response
107
+ st.write("API Response:", chat_completion)
108
+
109
+ # Extract the generated response
110
  response = chat_completion.choices[0].message.content
111
  st.write("Generated Response:", response)
112
 
113
  # Convert response to speech
114
  speech, *_ = tts_model(response, spembs=tts_model.spembs[0]) # Use the first speaker embedding
115
+
116
+ # Debug: Print the TTS output
117
+ st.write("TTS Output:", speech)
118
+
119
+ # Save and play the speech
120
  sf.write("response.wav", speech, 22050)
121
  st.audio("response.wav")
122
  except Exception as e: