DSatishchandra commited on
Commit
2d7d678
·
verified ·
1 Parent(s): efee040

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
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
- # Function to generate audio prompts
24
  def generate_audio_prompt(text, filename):
25
- tts = gTTS(text=text, lang="en")
26
- tts.save(os.path.join("static", filename))
 
 
 
 
 
 
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 = {