aidevhund commited on
Commit
358d190
·
verified ·
1 Parent(s): 96ddea1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -25
app.py CHANGED
@@ -1,51 +1,53 @@
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
-
11
  import gradio as gr
12
  import click
13
  from lang_data import languages
14
- source_lang_list=['English']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  source_lang_list.extend(languages.keys())
 
16
  @click.command()
17
  @click.option("--debug", is_flag=True, default=False, help="Enable debug mode.")
18
  @click.option("--share", is_flag=True, default=False, help="Enable sharing of the interface.")
19
  def main(debug, share):
20
  description = """edge-tts GitHub [https://github.com/rany2/edge-tts]"""
21
  gr.Markdown(description)
 
22
  # Define Gradio inputs and outputs
23
- example=[["This is just beginning of the journey of AI, AI will take over the world soon",
24
- "English",
25
- "Female",
26
- 1.0,
27
- False,
28
- False,
29
- True]]
30
  gradio_inputs = [
31
- gr.Textbox(label="Enter Text", lines=3,placeholder="Enter your text here..."),
32
  gr.Dropdown(label="Language", choices=source_lang_list, value="English"),
33
- gr.Dropdown(label="Gender", choices=['Male','Female'], value="Female"),
34
  gr.Number(label="Speed", value=1.0),
35
- gr.Checkbox(label="Translate Text", value=False),
36
- gr.Checkbox(label="Remove Silence", value=False),
37
  gr.Checkbox(label="Long Sentence", value=True)
38
  ]
39
 
40
  gradio_outputs = [
41
  gr.Audio(label="Audio File")
42
- # gr.File(label="Download Audio F", show_label=True)
43
  ]
44
 
45
  # Create Gradio interface
46
- demo = gr.Interface(fn=tts, inputs=gradio_inputs, outputs=gradio_outputs, title="Edge TTS ",examples=example)#,description=description)
47
 
48
  # Launch Gradio with command-line options
49
- demo.queue().launch(allowed_paths=[f"./audio"],debug=debug, share=share)
 
50
  if __name__ == "__main__":
51
- main()
 
1
  from microsoft_tts import edge_tts_pipeline
 
 
 
 
 
 
 
 
 
2
  import gradio as gr
3
  import click
4
  from lang_data import languages
5
+
6
+ # TTS function
7
+ def tts(text, Language='English', Gender='Male', speed=1.0, translate_text_flag=False, no_silence=True, long_sentence=True):
8
+ voice_name = None
9
+ tts_save_path = ''
10
+ edge_save_path = edge_tts_pipeline(
11
+ text, Language, voice_name, Gender,
12
+ translate_text_flag=translate_text_flag,
13
+ no_silence=no_silence, speed=speed,
14
+ tts_save_path=tts_save_path, long_sentence=long_sentence
15
+ )
16
+ return edge_save_path
17
+
18
+
19
+ # Gradio setup
20
+ source_lang_list = ['English']
21
  source_lang_list.extend(languages.keys())
22
+
23
  @click.command()
24
  @click.option("--debug", is_flag=True, default=False, help="Enable debug mode.")
25
  @click.option("--share", is_flag=True, default=False, help="Enable sharing of the interface.")
26
  def main(debug, share):
27
  description = """edge-tts GitHub [https://github.com/rany2/edge-tts]"""
28
  gr.Markdown(description)
29
+
30
  # Define Gradio inputs and outputs
31
+ example = [["This is just the beginning of the journey of AI, AI will take over the world soon",
32
+ "English", "Female", 1.0, False, False, True]]
33
+
 
 
 
 
34
  gradio_inputs = [
35
+ gr.Textbox(label="Enter Text", lines=3, placeholder="Enter your text here..."),
36
  gr.Dropdown(label="Language", choices=source_lang_list, value="English"),
37
+ gr.Dropdown(label="Gender", choices=['Male', 'Female'], value="Female"),
38
  gr.Number(label="Speed", value=1.0),
 
 
39
  gr.Checkbox(label="Long Sentence", value=True)
40
  ]
41
 
42
  gradio_outputs = [
43
  gr.Audio(label="Audio File")
 
44
  ]
45
 
46
  # Create Gradio interface
47
+ demo = gr.Interface(fn=tts, inputs=gradio_inputs, outputs=gradio_outputs, title="Edge TTS", examples=example)
48
 
49
  # Launch Gradio with command-line options
50
+ demo.queue().launch(allowed_paths=[f"./audio"], debug=debug, share=share)
51
+
52
  if __name__ == "__main__":
53
+ main()