Spaces:
Runtime error
Runtime error
aar2dee2
commited on
Commit
·
7fa5768
1
Parent(s):
403c562
fix audio output
Browse files
app.py
CHANGED
|
@@ -100,32 +100,18 @@ def main(input_audio):
|
|
| 100 |
try:
|
| 101 |
# Transcribe the input_audio using WhisperTranscriber
|
| 102 |
transcript = transcriber.transcribe(input_audio)
|
| 103 |
-
except Exception as e:
|
| 104 |
-
logger.error("Failed to transcribe audio: %s", e)
|
| 105 |
-
break
|
| 106 |
-
|
| 107 |
-
try:
|
| 108 |
-
# Generate response using ChatGPTAgent
|
| 109 |
response = agent.generate_response(transcript)
|
| 110 |
-
except Exception as e:
|
| 111 |
-
logger.error("Failed to generate response: %s", e)
|
| 112 |
-
break
|
| 113 |
-
|
| 114 |
-
try:
|
| 115 |
-
# Synthesize the response into audio using CoquiSynthesizer
|
| 116 |
output_audio = synthesizer.synthesize(response)
|
|
|
|
|
|
|
| 117 |
except Exception as e:
|
| 118 |
logger.error("Failed to synthesize response: %s", e)
|
| 119 |
break
|
| 120 |
|
| 121 |
-
return output_audio
|
| 122 |
-
|
| 123 |
|
| 124 |
demo = gr.Interface(fn=main, inputs=gr.Audio(
|
| 125 |
source="microphone",
|
| 126 |
type="filepath",
|
| 127 |
interactive=True,
|
| 128 |
-
), outputs=
|
| 129 |
-
type="filepath"
|
| 130 |
-
))
|
| 131 |
demo.launch()
|
|
|
|
| 100 |
try:
|
| 101 |
# Transcribe the input_audio using WhisperTranscriber
|
| 102 |
transcript = transcriber.transcribe(input_audio)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
response = agent.generate_response(transcript)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
output_audio = synthesizer.synthesize(response)
|
| 105 |
+
return output_audio
|
| 106 |
+
|
| 107 |
except Exception as e:
|
| 108 |
logger.error("Failed to synthesize response: %s", e)
|
| 109 |
break
|
| 110 |
|
|
|
|
|
|
|
| 111 |
|
| 112 |
demo = gr.Interface(fn=main, inputs=gr.Audio(
|
| 113 |
source="microphone",
|
| 114 |
type="filepath",
|
| 115 |
interactive=True,
|
| 116 |
+
), outputs="audio")
|
|
|
|
|
|
|
| 117 |
demo.launch()
|