ragha108 commited on
Commit
554a6b2
·
1 Parent(s): 91e938b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -1,16 +1,13 @@
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
@@ -18,7 +15,7 @@ def text_to_audio(text):
18
  # tts.save("test.wav")
19
  # return 'test.wav'
20
 
21
- iface = gr.Interface(fn = text_to_audio,
22
  inputs = 'text',
23
  outputs = 'audio',
24
  verbose = True,
 
1
+ import tempfile
2
  import gradio as gr
3
+ from neon_tts_plugin_coqui import CoquiTTS
 
4
 
5
+ coquiTTS = CoquiTTS()
6
+
7
+ def tts(text: str):
8
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
9
+ coquiTTS.get_tts(text, fp)
10
+ return fp.name
 
 
11
 
12
  # def text_to_audio(text):
13
  # # Generate audio from text using gTTS
 
15
  # tts.save("test.wav")
16
  # return 'test.wav'
17
 
18
+ iface = gr.Interface(fn = tts,
19
  inputs = 'text',
20
  outputs = 'audio',
21
  verbose = True,