ragha108 commited on
Commit
ad4a7ba
·
1 Parent(s): bebdcf7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -1,12 +1,22 @@
1
  from gtts import gTTS
2
  import gradio as gr
3
  import os
 
4
 
5
  def text_to_audio(text):
 
 
6
  # Generate audio from text using gTTS
7
- tts = gTTS(text=text, lang='en', slow=False)
8
- tts.save("test.wav")
9
- return 'test.wav'
 
 
 
 
 
 
 
10
 
11
  iface = gr.Interface(fn = text_to_audio,
12
  inputs = 'text',
 
1
  from gtts import gTTS
2
  import gradio as gr
3
  import os
4
+ from coqui_tts import Synthesizer
5
 
6
  def text_to_audio(text):
7
+ # Load a pre-trained model
8
+ model = Synthesizer.from_pretrained("tts_models/coqui_tts/cleanup")
9
  # Generate audio from text using gTTS
10
+ audio = model.synthesize(text)
11
+ # Save audio to file
12
+ with open("output.wav", "wb") as f:
13
+ f.write(audio)
14
+
15
+ # def text_to_audio(text):
16
+ # # Generate audio from text using gTTS
17
+ # tts = gTTS(text=text, lang='en', slow=False)
18
+ # tts.save("test.wav")
19
+ # return 'test.wav'
20
 
21
  iface = gr.Interface(fn = text_to_audio,
22
  inputs = 'text',