Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ whisper_tokenizer = AutoTokenizer.from_pretrained("openai/whisper-tiny")
|
|
| 9 |
|
| 10 |
llm_model = AutoModelForCausalLM.from_pretrained(
|
| 11 |
"microsoft/Phi-3-mini-4k-instruct",
|
| 12 |
-
device_map="
|
| 13 |
torch_dtype="auto",
|
| 14 |
trust_remote_code=True)
|
| 15 |
llm_tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
|
|
@@ -34,20 +34,15 @@ def generate_text(prompt):
|
|
| 34 |
return generated_text
|
| 35 |
|
| 36 |
def text_to_speech(text):
|
| 37 |
-
|
|
|
|
| 38 |
return speech
|
| 39 |
|
| 40 |
# Create Gradio interface
|
| 41 |
-
audio_input = gr.Audio(label="
|
| 42 |
text_output = gr.Textbox(label="Transcribed Text")
|
| 43 |
-
gr.Interface(
|
| 44 |
-
generate_text,
|
| 45 |
-
inputs=audio_input,
|
| 46 |
-
outputs=gr.Textbox(label="Generated Text")
|
| 47 |
-
).launch()
|
| 48 |
-
|
| 49 |
gr.Interface(
|
| 50 |
text_to_speech,
|
| 51 |
-
inputs=
|
| 52 |
-
outputs=gr.Audio(label="
|
| 53 |
-
).launch()
|
|
|
|
| 9 |
|
| 10 |
llm_model = AutoModelForCausalLM.from_pretrained(
|
| 11 |
"microsoft/Phi-3-mini-4k-instruct",
|
| 12 |
+
device_map="cpu",
|
| 13 |
torch_dtype="auto",
|
| 14 |
trust_remote_code=True)
|
| 15 |
llm_tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
|
|
|
|
| 34 |
return generated_text
|
| 35 |
|
| 36 |
def text_to_speech(text):
|
| 37 |
+
generated_text = phi3_mini_4k(text, max_length=50, do_sample=True)[0]['generated_text']
|
| 38 |
+
speech = vits_tts(generated_text)[0]['audio']
|
| 39 |
return speech
|
| 40 |
|
| 41 |
# Create Gradio interface
|
| 42 |
+
audio_input = gr.Audio(label="Can I Help You?", sources="microphone")
|
| 43 |
text_output = gr.Textbox(label="Transcribed Text")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
gr.Interface(
|
| 45 |
text_to_speech,
|
| 46 |
+
inputs=audio_input,
|
| 47 |
+
outputs=gr.Audio(label="Answer:"),
|
| 48 |
+
title="MyAlexa AI Assistant").launch(inbrowser=True)
|