Omnibus commited on
Commit
b83b036
·
1 Parent(s): 181d5d2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from TTS.api import TTS
3
+
4
+
5
+ def try1():
6
+ model_name = TTS.list_models()[0]
7
+ # Init TTS
8
+ tts = TTS(model_name)
9
+ # Run TTS
10
+ # ❗ Since this model is multi-speaker and multi-lingual, we must set the target speaker and the language
11
+ # Text to speech with a numpy output
12
+ wav = tts.tts("This is a test! This is also a test!!", speaker=tts.speakers[0], language=tts.languages[0])
13
+ # Text to speech to a file
14
+ tts.tts_to_file(text="Hello world!", speaker=tts.speakers[0], language=tts.languages[0], file_path="output.wav")
15
+ out = "output.wav"
16
+ return out
17
+
18
+ def try2():
19
+ tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)
20
+ tts.tts_to_file("This is voice cloning.", speaker_wav="my/cloning/audio.wav", language="en", file_path="output.wav")
21
+ tts.tts_to_file("C'est le clonage de la voix.", speaker_wav="my/cloning/audio.wav", language="fr", file_path="output.wav")
22
+ tts.tts_to_file("Isso é clonagem de voz.", speaker_wav="my/cloning/audio.wav", language="pt", file_path="output.wav")
23
+ out = "output.wav"
24
+ return out
25
+
26
+ with gr.Blocks() as app:
27
+ out1 = gr.Audio()
28
+ btn1 = gr.Button()
29
+ btn2 = gr.Button()
30
+
31
+ btn1.click(try1,None,out1)
32
+ btn2.click(try2,None,out1)
33
+
34
+ app.launch()