Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -210,6 +210,9 @@ pipe_asr = pipeline(
|
|
210 |
return_timestamps=True
|
211 |
)
|
212 |
|
|
|
|
|
|
|
213 |
# Function to handle voice input, generate response from Neo4j, and return audio output
|
214 |
def handle_voice_to_voice(audio):
|
215 |
try:
|
@@ -228,7 +231,7 @@ def handle_voice_to_voice(audio):
|
|
228 |
logging.debug(f"Transcribed question: {question}")
|
229 |
|
230 |
if not question:
|
231 |
-
return "No transcription available, please try again."
|
232 |
|
233 |
# Get response using the transcribed question
|
234 |
response = get_response(question)
|
@@ -238,24 +241,28 @@ def handle_voice_to_voice(audio):
|
|
238 |
audio_path = generate_audio_elevenlabs(response)
|
239 |
logging.debug(f"Generated audio path: {audio_path}")
|
240 |
|
241 |
-
|
|
|
242 |
except Exception as e:
|
243 |
logging.error(f"Error in handle_voice_to_voice: {e}")
|
244 |
-
return "Error processing the audio, please try again."
|
245 |
-
|
246 |
|
247 |
|
248 |
# Define the Gradio interface
|
249 |
with gr.Blocks(theme="rawrsor1/Everforest") as demo:
|
250 |
audio_input = gr.Audio(sources=["microphone"], type='numpy', streaming=True, label="Speak to Ask")
|
251 |
submit_voice_btn = gr.Button("Submit Voice")
|
|
|
252 |
audio_output = gr.Audio(label="Response Audio", type="filepath", autoplay=True, interactive=False)
|
253 |
|
254 |
# Interactions for Submit Voice Button
|
255 |
submit_voice_btn.click(
|
256 |
fn=handle_voice_to_voice,
|
257 |
inputs=audio_input,
|
258 |
-
outputs=audio_output
|
|
|
|
|
|
|
259 |
)
|
260 |
|
261 |
# Launch the Gradio interface
|
|
|
210 |
return_timestamps=True
|
211 |
)
|
212 |
|
213 |
+
# Set up logging to a file to capture debug information
|
214 |
+
logging.basicConfig(filename='neo4j_retrieval.log', level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
215 |
+
|
216 |
# Function to handle voice input, generate response from Neo4j, and return audio output
|
217 |
def handle_voice_to_voice(audio):
|
218 |
try:
|
|
|
231 |
logging.debug(f"Transcribed question: {question}")
|
232 |
|
233 |
if not question:
|
234 |
+
return "No transcription available, please try again.", ""
|
235 |
|
236 |
# Get response using the transcribed question
|
237 |
response = get_response(question)
|
|
|
241 |
audio_path = generate_audio_elevenlabs(response)
|
242 |
logging.debug(f"Generated audio path: {audio_path}")
|
243 |
|
244 |
+
# Return the transcription and the audio path
|
245 |
+
return audio_path, question
|
246 |
except Exception as e:
|
247 |
logging.error(f"Error in handle_voice_to_voice: {e}")
|
248 |
+
return "Error processing the audio, please try again.", ""
|
|
|
249 |
|
250 |
|
251 |
# Define the Gradio interface
|
252 |
with gr.Blocks(theme="rawrsor1/Everforest") as demo:
|
253 |
audio_input = gr.Audio(sources=["microphone"], type='numpy', streaming=True, label="Speak to Ask")
|
254 |
submit_voice_btn = gr.Button("Submit Voice")
|
255 |
+
transcription_textbox = gr.Textbox(label="Transcription", interactive=False)
|
256 |
audio_output = gr.Audio(label="Response Audio", type="filepath", autoplay=True, interactive=False)
|
257 |
|
258 |
# Interactions for Submit Voice Button
|
259 |
submit_voice_btn.click(
|
260 |
fn=handle_voice_to_voice,
|
261 |
inputs=audio_input,
|
262 |
+
outputs=[audio_output, transcription_textbox]
|
263 |
+
).then(
|
264 |
+
fn=lambda: "",
|
265 |
+
outputs=transcription_textbox
|
266 |
)
|
267 |
|
268 |
# Launch the Gradio interface
|