Update app.py
Browse files
app.py
CHANGED
|
@@ -39,30 +39,27 @@ def generate_response(transcribed_text):
|
|
| 39 |
|
| 40 |
|
| 41 |
def inference(text):
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
|
| 48 |
def process_audio_and_respond(audio):
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
|
| 55 |
demo = gr.Interface(
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
)
|
| 66 |
|
| 67 |
-
|
| 68 |
demo.launch()
|
|
|
|
| 39 |
|
| 40 |
|
| 41 |
def inference(text):
|
| 42 |
+
output_file = "tts_output.wav"
|
| 43 |
+
tts = gTTS(text, lang="sw")
|
| 44 |
+
tts.save(output_file)
|
| 45 |
+
return output_file
|
|
|
|
| 46 |
|
| 47 |
def process_audio_and_respond(audio):
|
| 48 |
+
text = transcribe(audio)
|
| 49 |
+
response_text = generate_response(text)
|
| 50 |
+
output_file = inference(response_text)
|
| 51 |
+
return response_text, output_file
|
|
|
|
| 52 |
|
| 53 |
demo = gr.Interface(
|
| 54 |
+
process_audio_and_respond,
|
| 55 |
+
gr.inputs.Audio(source="microphone", type="filepath", label="Bonyeza kitufe cha kurekodi na uliza swali lako"),
|
| 56 |
+
[gr.outputs.Textbox(label="Jibu (kwa njia ya maandishi)"), gr.outputs.Audio(type="filepath", label="Jibu kwa njia ya sauti (Bofya kusikiliza Jibu)")],
|
| 57 |
+
title="Mtaalamu wa Viazi Lishe",
|
| 58 |
+
description="Uliza Mtaalamu wetu swali lolote Kuhusu viazi Lishe",
|
| 59 |
+
theme="compact",
|
| 60 |
+
layout="vertical",
|
| 61 |
+
allow_flagging=False,
|
| 62 |
+
live=True,
|
| 63 |
)
|
| 64 |
|
|
|
|
| 65 |
demo.launch()
|