Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,7 +24,7 @@ def audio_to_text(audio):
|
|
| 24 |
outputs = whisper(**inputs)
|
| 25 |
predicted_ids = torch.argmax(outputs.logits, dim=-1)
|
| 26 |
transcribed_text = whisper_tokenizer.decode(predicted_ids[0])
|
| 27 |
-
return
|
| 28 |
|
| 29 |
# Define functions for model predictions
|
| 30 |
def generate_text(prompt):
|
|
@@ -36,11 +36,14 @@ def text_to_speech(text):
|
|
| 36 |
speech = vits_tts(generated_text)[0]['audio']
|
| 37 |
return speech
|
| 38 |
|
|
|
|
|
|
|
|
|
|
| 39 |
# Create Gradio interface
|
| 40 |
audio_input = gr.Audio(label="Can I Help You?", sources="microphone")
|
| 41 |
text_output = gr.Textbox(label="Transcribed Text")
|
| 42 |
gr.Interface(
|
| 43 |
-
|
| 44 |
inputs=audio_input,
|
| 45 |
outputs=gr.Audio(label="Answer:"),
|
| 46 |
title="MyAlexa AI Assistant").launch(inbrowser=True, debug=True)
|
|
|
|
| 24 |
outputs = whisper(**inputs)
|
| 25 |
predicted_ids = torch.argmax(outputs.logits, dim=-1)
|
| 26 |
transcribed_text = whisper_tokenizer.decode(predicted_ids[0])
|
| 27 |
+
return transcribed_text
|
| 28 |
|
| 29 |
# Define functions for model predictions
|
| 30 |
def generate_text(prompt):
|
|
|
|
| 36 |
speech = vits_tts(generated_text)[0]['audio']
|
| 37 |
return speech
|
| 38 |
|
| 39 |
+
def my_alexa(audio):
|
| 40 |
+
return text_to_speech(generate_text(audio_to_text(audio)))
|
| 41 |
+
|
| 42 |
# Create Gradio interface
|
| 43 |
audio_input = gr.Audio(label="Can I Help You?", sources="microphone")
|
| 44 |
text_output = gr.Textbox(label="Transcribed Text")
|
| 45 |
gr.Interface(
|
| 46 |
+
my_alexa,
|
| 47 |
inputs=audio_input,
|
| 48 |
outputs=gr.Audio(label="Answer:"),
|
| 49 |
title="MyAlexa AI Assistant").launch(inbrowser=True, debug=True)
|