Update app.py
Browse files
app.py
CHANGED
|
@@ -8,33 +8,26 @@ from neon_tts_plugin_coqui import CoquiTTS
|
|
| 8 |
LANGUAGES = list(CoquiTTS.langs.keys())
|
| 9 |
default_lang = "en"
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
title = "ChatGPTBots.net | TTS"
|
| 14 |
description = "A deep learning toolkit for Text-to-Speech, battle-tested in research and production"
|
| 15 |
info = "More info at [TTS](https://chatgptbots.net)"
|
| 16 |
-
badge = "https://chatgptbots.net/wp-content/uploads/2024/05/AI-YouTube-Transcript-Summarizer-Free-Easy.webp"
|
| 17 |
-
|
| 18 |
|
| 19 |
coquiTTS = CoquiTTS()
|
| 20 |
|
| 21 |
-
|
| 22 |
def tts(text: str, language: str):
|
| 23 |
print(text, language)
|
| 24 |
# return output
|
| 25 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
| 26 |
-
coquiTTS.get_tts(text, fp, speaker
|
| 27 |
return fp.name
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
with gr.Blocks() as blocks:
|
| 32 |
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>"
|
| 33 |
+ title
|
| 34 |
+ "</h1>")
|
| 35 |
gr.Markdown(description)
|
| 36 |
-
with gr.Row()
|
| 37 |
-
with gr.Column()
|
| 38 |
textbox = gr.Textbox(
|
| 39 |
label="Input",
|
| 40 |
value=CoquiTTS.langs[default_lang]["sentence"],
|
|
@@ -45,13 +38,10 @@ with gr.Blocks() as blocks:
|
|
| 45 |
choices=LANGUAGES,
|
| 46 |
value=default_lang
|
| 47 |
)
|
| 48 |
-
with gr.Row()
|
| 49 |
submit = gr.Button("Submit", variant="primary")
|
| 50 |
audio = gr.Audio(label="Output", interactive=False)
|
| 51 |
gr.Markdown(info)
|
| 52 |
-
gr.Markdown("<center>"
|
| 53 |
-
+f'<img src={badge} alt="visitors badge"/>'
|
| 54 |
-
+"</center>")
|
| 55 |
|
| 56 |
# actions
|
| 57 |
submit.click(
|
|
@@ -61,6 +51,4 @@ with gr.Blocks() as blocks:
|
|
| 61 |
)
|
| 62 |
radio.change(lambda lang: CoquiTTS.langs[lang]["sentence"], radio, textbox)
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
blocks.launch()
|
|
|
|
| 8 |
LANGUAGES = list(CoquiTTS.langs.keys())
|
| 9 |
default_lang = "en"
|
| 10 |
|
|
|
|
|
|
|
| 11 |
title = "ChatGPTBots.net | TTS"
|
| 12 |
description = "A deep learning toolkit for Text-to-Speech, battle-tested in research and production"
|
| 13 |
info = "More info at [TTS](https://chatgptbots.net)"
|
|
|
|
|
|
|
| 14 |
|
| 15 |
coquiTTS = CoquiTTS()
|
| 16 |
|
|
|
|
| 17 |
def tts(text: str, language: str):
|
| 18 |
print(text, language)
|
| 19 |
# return output
|
| 20 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
| 21 |
+
coquiTTS.get_tts(text, fp, speaker={"language": language})
|
| 22 |
return fp.name
|
| 23 |
|
|
|
|
|
|
|
| 24 |
with gr.Blocks() as blocks:
|
| 25 |
gr.Markdown("<h1 style='text-align: center; margin-bottom: 1rem'>"
|
| 26 |
+ title
|
| 27 |
+ "</h1>")
|
| 28 |
gr.Markdown(description)
|
| 29 |
+
with gr.Row(): # equal_height=False
|
| 30 |
+
with gr.Column(): # variant="panel"
|
| 31 |
textbox = gr.Textbox(
|
| 32 |
label="Input",
|
| 33 |
value=CoquiTTS.langs[default_lang]["sentence"],
|
|
|
|
| 38 |
choices=LANGUAGES,
|
| 39 |
value=default_lang
|
| 40 |
)
|
| 41 |
+
with gr.Row(): # mobile_collapse=False
|
| 42 |
submit = gr.Button("Submit", variant="primary")
|
| 43 |
audio = gr.Audio(label="Output", interactive=False)
|
| 44 |
gr.Markdown(info)
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
# actions
|
| 47 |
submit.click(
|
|
|
|
| 51 |
)
|
| 52 |
radio.change(lambda lang: CoquiTTS.langs[lang]["sentence"], radio, textbox)
|
| 53 |
|
|
|
|
|
|
|
| 54 |
blocks.launch()
|