Update app.py
Browse files
app.py
CHANGED
@@ -20,10 +20,16 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
20 |
config = AutoConfig.from_pretrained("openai/whisper-small")
|
21 |
config.update({"timeout": 60}) # Set timeout to 60 seconds
|
22 |
|
23 |
-
#
|
24 |
def generate_audio_prompt(text, filename):
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
# Generate required voice prompts
|
29 |
prompts = {
|
|
|
20 |
config = AutoConfig.from_pretrained("openai/whisper-small")
|
21 |
config.update({"timeout": 60}) # Set timeout to 60 seconds
|
22 |
|
23 |
+
# Your function where you generate and save the audio
|
24 |
def generate_audio_prompt(text, filename):
|
25 |
+
try:
|
26 |
+
tts = gTTS(text)
|
27 |
+
tts.save(os.path.join("static", filename))
|
28 |
+
except gtts.tts.gTTSError as e:
|
29 |
+
print(f"Error: {e}")
|
30 |
+
print("Retrying after 5 seconds...")
|
31 |
+
time.sleep(5) # Wait for 5 seconds before retrying
|
32 |
+
generate_audio_prompt(text, filename)
|
33 |
|
34 |
# Generate required voice prompts
|
35 |
prompts = {
|