Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,9 +13,9 @@ async def get_voices():
|
|
13 |
# Text to speech functionality
|
14 |
async def text_to_speech(text, voice, rate, pitch, output_path):
|
15 |
if not text.strip():
|
16 |
-
return None, gr.Warning("
|
17 |
if not voice:
|
18 |
-
return None, gr.Warning("
|
19 |
|
20 |
voice_short_name = voice.split(" (")[0]
|
21 |
rate_str = f"{rate:+d}%"
|
@@ -137,9 +137,9 @@ async def text_to_audio_and_srt(text, voice, rate, pitch, num_lines, output_audi
|
|
137 |
# Gradio interface function
|
138 |
def tts_interface(text, voice, rate, pitch, num_lines, output_audio_path="output_audio.mp3", output_srt_path="output_subtitle.srt"):
|
139 |
if not text.strip():
|
140 |
-
return None, None, gr.Warning("
|
141 |
if num_lines <= 0:
|
142 |
-
return None, None, gr.Warning("
|
143 |
|
144 |
try:
|
145 |
audio_path, srt_path, warning = asyncio.run(
|
@@ -168,19 +168,19 @@ async def create_demo():
|
|
168 |
|
169 |
with gr.Row():
|
170 |
with gr.Column():
|
171 |
-
text_input = gr.Textbox(label="Input Text", lines=5, placeholder="
|
172 |
-
voice_dropdown = gr.Dropdown(choices=[""] + list(voices.keys()), label="
|
173 |
-
rate_slider = gr.Slider(minimum=-50, maximum=50, value=0, label="
|
174 |
-
pitch_slider = gr.Slider(minimum=-20, maximum=20, value=0, label="
|
175 |
|
176 |
-
num_lines_slider = gr.Slider(minimum=1, maximum=5, value=2, label="
|
177 |
|
178 |
generate_button = gr.Button("Generate Audio and Subtitles", variant="primary")
|
179 |
|
180 |
with gr.Column():
|
181 |
-
output_audio = gr.Audio(label="
|
182 |
-
output_srt = gr.File(label="
|
183 |
-
warning_msg = gr.Markdown(label="
|
184 |
|
185 |
generate_button.click(
|
186 |
fn=tts_interface,
|
|
|
13 |
# Text to speech functionality
|
14 |
async def text_to_speech(text, voice, rate, pitch, output_path):
|
15 |
if not text.strip():
|
16 |
+
return None, gr.Warning("Введите текст для конвертации текста в аудио...")
|
17 |
if not voice:
|
18 |
+
return None, gr.Warning("Пожалуйста, выберите голос диктора...")
|
19 |
|
20 |
voice_short_name = voice.split(" (")[0]
|
21 |
rate_str = f"{rate:+d}%"
|
|
|
137 |
# Gradio interface function
|
138 |
def tts_interface(text, voice, rate, pitch, num_lines, output_audio_path="output_audio.mp3", output_srt_path="output_subtitle.srt"):
|
139 |
if not text.strip():
|
140 |
+
return None, None, gr.Warning("Вы не ввели текст!")
|
141 |
if num_lines <= 0:
|
142 |
+
return None, None, gr.Warning("Колличество строк в субтитрах должно быть больше 1!")
|
143 |
|
144 |
try:
|
145 |
audio_path, srt_path, warning = asyncio.run(
|
|
|
168 |
|
169 |
with gr.Row():
|
170 |
with gr.Column():
|
171 |
+
text_input = gr.Textbox(label="Input Text", lines=5, placeholder="Введите текст")
|
172 |
+
voice_dropdown = gr.Dropdown(choices=[""] + list(voices.keys()), label="Выберите голос", value="")
|
173 |
+
rate_slider = gr.Slider(minimum=-50, maximum=50, value=0, label="Скорость речи (%)", step=1)
|
174 |
+
pitch_slider = gr.Slider(minimum=-20, maximum=20, value=0, label="Высота тона (Hz)", step=1)
|
175 |
|
176 |
+
num_lines_slider = gr.Slider(minimum=1, maximum=5, value=2, label="Колличество строк в субтитрах", step=1)
|
177 |
|
178 |
generate_button = gr.Button("Generate Audio and Subtitles", variant="primary")
|
179 |
|
180 |
with gr.Column():
|
181 |
+
output_audio = gr.Audio(label="Готовое аудио", type="filepath")
|
182 |
+
output_srt = gr.File(label="Готовые субтитры", file_count="single")
|
183 |
+
warning_msg = gr.Markdown(label="Ошибка!", visible=False)
|
184 |
|
185 |
generate_button.click(
|
186 |
fn=tts_interface,
|