Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ whisper = pipeline("automatic-speech-recognition", model="openai/whisper-tiny")
|
|
| 11 |
knowledge_base = {
|
| 12 |
"what cars are available": "We have Toyota Camry, Honda Civic, and Ford Mustang.",
|
| 13 |
"price of camry": "The Toyota Camry starts at $25,000.",
|
| 14 |
-
"price of
|
| 15 |
}
|
| 16 |
|
| 17 |
def transcribe(audio):
|
|
@@ -35,9 +35,10 @@ def text_to_speech(text):
|
|
| 35 |
print(f"Generating speech for text: {text}")
|
| 36 |
try:
|
| 37 |
tts = gTTS(text, lang="en")
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 41 |
except Exception as e:
|
| 42 |
print(f"Error in text_to_speech: {str(e)}")
|
| 43 |
import traceback
|
|
|
|
| 11 |
knowledge_base = {
|
| 12 |
"what cars are available": "We have Toyota Camry, Honda Civic, and Ford Mustang.",
|
| 13 |
"price of camry": "The Toyota Camry starts at $25,000.",
|
| 14 |
+
"price of tesla": "The Tesla starts at $60,000."
|
| 15 |
}
|
| 16 |
|
| 17 |
def transcribe(audio):
|
|
|
|
| 35 |
print(f"Generating speech for text: {text}")
|
| 36 |
try:
|
| 37 |
tts = gTTS(text, lang="en")
|
| 38 |
+
output_path = "/tmp/response.mp3"
|
| 39 |
+
tts.save(output_path)
|
| 40 |
+
print(f"Speech saved to {output_path}")
|
| 41 |
+
return output_path
|
| 42 |
except Exception as e:
|
| 43 |
print(f"Error in text_to_speech: {str(e)}")
|
| 44 |
import traceback
|