Spaces:
Running
Running
NeuralFalcon
commited on
Commit
•
b25cc04
1
Parent(s):
823e976
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from microsoft_tts import edge_tts_pipeline
|
2 |
+
def tts(text,Language='English',Gender='Male',speed=1.0,translate_text_flag=False, no_silence=True, long_sentence=True):
|
3 |
+
voice_name=None
|
4 |
+
tts_save_path=''
|
5 |
+
edge_save_path = edge_tts_pipeline(text, Language,voice_name, Gender, translate_text_flag=translate_text_flag,
|
6 |
+
no_silence=no_silence, speed=speed, tts_save_path=tts_save_path,
|
7 |
+
long_sentence=long_sentence)
|
8 |
+
return edge_save_path
|
9 |
+
|
10 |
+
# text="Machine learning is the study of computer "
|
11 |
+
# save_path = tts(text, Language='English',Gender="Male")
|
12 |
+
# print(save_path)
|
13 |
+
# import simpleaudio as sa
|
14 |
+
# def play_sound(filename):
|
15 |
+
# wave_obj = sa.WaveObject.from_wave_file(filename)
|
16 |
+
# play_obj = wave_obj.play()
|
17 |
+
# play_obj.wait_done()
|
18 |
+
# play_sound(save_path)
|
19 |
+
|
20 |
+
import gradio as gr
|
21 |
+
import click
|
22 |
+
from lang_data import languages
|
23 |
+
source_lang_list=['English','Hindi','Bengali']
|
24 |
+
source_lang_list.extend(languages.keys())
|
25 |
+
@click.command()
|
26 |
+
@click.option("--debug", is_flag=True, default=False, help="Enable debug mode.")
|
27 |
+
@click.option("--share", is_flag=True, default=False, help="Enable sharing of the interface.")
|
28 |
+
def main(debug, share):
|
29 |
+
description = """edge-tts GitHub [https://github.com/rany2/edge-tts]"""
|
30 |
+
gr.Markdown(description)
|
31 |
+
# Define Gradio inputs and outputs
|
32 |
+
example=[["This is just beginning of the journey of AI, AI will take over the world soon",
|
33 |
+
"English",
|
34 |
+
"Female",
|
35 |
+
1.0,
|
36 |
+
False,
|
37 |
+
False,
|
38 |
+
True]]
|
39 |
+
gradio_inputs = [
|
40 |
+
gr.Textbox(label="Enter Text", lines=3,placeholder="Enter your text here..."),
|
41 |
+
gr.Dropdown(label="Language", choices=source_lang_list, value="English"),
|
42 |
+
gr.Dropdown(label="Gender", choices=['Male','Female'], value="Female"),
|
43 |
+
gr.Number(label="Speed", value=1.0),
|
44 |
+
gr.Checkbox(label="Translate Text", value=False),
|
45 |
+
gr.Checkbox(label="Remove Silence", value=False),
|
46 |
+
gr.Checkbox(label="Long Sentence", value=True)
|
47 |
+
]
|
48 |
+
|
49 |
+
gradio_outputs = [
|
50 |
+
gr.Audio(label="Audio File")
|
51 |
+
# gr.File(label="Download Audio F", show_label=True)
|
52 |
+
]
|
53 |
+
|
54 |
+
# Create Gradio interface
|
55 |
+
demo = gr.Interface(fn=tts, inputs=gradio_inputs, outputs=gradio_outputs, title="Edge TTS ",examples=example)#,description=description)
|
56 |
+
|
57 |
+
# Launch Gradio with command-line options
|
58 |
+
demo.queue().launch(allowed_paths=[f"./audio"],debug=debug, share=share)
|
59 |
+
if __name__ == "__main__":
|
60 |
+
main()
|