Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -65,21 +65,8 @@ def transcribe_audio(audio):
|
|
65 |
result = result[1]
|
66 |
result = result[0][1]
|
67 |
result=gr.Markdown(result)
|
68 |
-
|
69 |
-
|
70 |
-
# ... (rest of the code to get the result)
|
71 |
-
result_text = result # assuming result is the text response
|
72 |
-
# Generate a unique file name with timestamp
|
73 |
-
timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
74 |
-
output_file = os.path.join('./chroma', f'output_{timestamp}.mp3')
|
75 |
-
# Ensure the tmp directory exists
|
76 |
-
if not os.path.exists('./chroma'):
|
77 |
-
os.makedirs('./chroma')
|
78 |
-
# Convert text to speech
|
79 |
-
tts = gTTS(text=result_text, lang='de', slow=False)
|
80 |
-
tts.save(output_file)
|
81 |
-
# Return both text and audio file path
|
82 |
-
return result_text, output_file
|
83 |
#return text
|
84 |
except sr.UnknownValueError:
|
85 |
return "Speech recognition could not understand the audio."
|
@@ -208,15 +195,20 @@ with gr.Blocks() as suche:
|
|
208 |
|
209 |
|
210 |
with gr.Blocks() as speech:
|
211 |
-
gr.Markdown("### audio", elem_classes="tab-header")
|
|
|
212 |
with gr.Row():
|
213 |
-
|
214 |
with gr.Row():
|
215 |
sr_inputs = gr.Microphone(type="filepath")
|
216 |
-
with gr.Row():
|
217 |
-
sr_outputs_audio = gr.Audio(label="Audio Antwort", autoplay=True)
|
218 |
|
219 |
-
sr_inputs.change(transcribe_audio, inputs=sr_inputs, outputs=
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
|
221 |
# Erstelle die Gradio-Schnittstelle
|
222 |
with gr.Blocks() as demo:
|
|
|
65 |
result = result[1]
|
66 |
result = result[0][1]
|
67 |
result=gr.Markdown(result)
|
68 |
+
return result
|
69 |
+
#text = update(text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
#return text
|
71 |
except sr.UnknownValueError:
|
72 |
return "Speech recognition could not understand the audio."
|
|
|
195 |
|
196 |
|
197 |
with gr.Blocks() as speech:
|
198 |
+
gr.Markdown("### audio", elem_classes="tab-header")
|
199 |
+
|
200 |
with gr.Row():
|
201 |
+
sr_outputs = gr.Textbox(label="Antwort")
|
202 |
with gr.Row():
|
203 |
sr_inputs = gr.Microphone(type="filepath")
|
|
|
|
|
204 |
|
205 |
+
sr_inputs.change(transcribe_audio, inputs=sr_inputs, outputs=sr_outputs)
|
206 |
+
|
207 |
+
#with gr.Row():
|
208 |
+
#submit_button = gr.Button("rec")
|
209 |
+
|
210 |
+
#submit_button.click(transcribe_audio, inputs=sr_inputs, outputs=sr_outputs)
|
211 |
+
|
212 |
|
213 |
# Erstelle die Gradio-Schnittstelle
|
214 |
with gr.Blocks() as demo:
|