Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,9 @@ import gradio as gr
|
|
4 |
# Load pre-trained models
|
5 |
stt_model = pipeline("automatic-speech-recognition", model="openai/whisper-tiny")
|
6 |
nlp_model = pipeline("text-generation", model="sshleifer/tiny-gpt2")
|
7 |
-
|
|
|
|
|
8 |
|
9 |
# Define a function to handle the workflow
|
10 |
def conversation(audio):
|
@@ -19,10 +21,10 @@ def conversation(audio):
|
|
19 |
# Default response generation (using GPT-2 model)
|
20 |
response = nlp_model(text, max_length=50)[0]["generated_text"]
|
21 |
|
22 |
-
# Step 3: Convert response text to speech using
|
23 |
-
|
24 |
|
25 |
-
return text, response,
|
26 |
|
27 |
# Create Gradio Interface
|
28 |
interface = gr.Interface(
|
|
|
4 |
# Load pre-trained models
|
5 |
stt_model = pipeline("automatic-speech-recognition", model="openai/whisper-tiny")
|
6 |
nlp_model = pipeline("text-generation", model="sshleifer/tiny-gpt2")
|
7 |
+
|
8 |
+
# Attempt to load Kokoro-82M for TTS (this might require adjustments depending on model support)
|
9 |
+
tts_model = pipeline("text-to-speech", model="hexgrad/Kokoro-82M")
|
10 |
|
11 |
# Define a function to handle the workflow
|
12 |
def conversation(audio):
|
|
|
21 |
# Default response generation (using GPT-2 model)
|
22 |
response = nlp_model(text, max_length=50)[0]["generated_text"]
|
23 |
|
24 |
+
# Step 3: Convert response text to speech using Kokoro-82M
|
25 |
+
tts_audio = tts_model(response)
|
26 |
|
27 |
+
return text, response, tts_audio
|
28 |
|
29 |
# Create Gradio Interface
|
30 |
interface = gr.Interface(
|