Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,11 +8,11 @@ from gtts import gTTS
|
|
8 |
app = Flask(__name__)
|
9 |
recognizer = sr.Recognizer()
|
10 |
|
11 |
-
# Load Hugging Face Whisper Model
|
12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
13 |
speech_to_text = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=0 if device == "cuda" else -1)
|
14 |
|
15 |
-
# Function to
|
16 |
def generate_audio(text, filename="static/output.mp3"):
|
17 |
tts = gTTS(text=text, lang="en")
|
18 |
tts.save(filename)
|
|
|
8 |
app = Flask(__name__)
|
9 |
recognizer = sr.Recognizer()
|
10 |
|
11 |
+
# Load Hugging Face Whisper Model for Speech-to-Text
|
12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
13 |
speech_to_text = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=0 if device == "cuda" else -1)
|
14 |
|
15 |
+
# Function to generate and play voice prompts
|
16 |
def generate_audio(text, filename="static/output.mp3"):
|
17 |
tts = gTTS(text=text, lang="en")
|
18 |
tts.save(filename)
|