KroZenDev commited on
Commit
2d1eecf
·
verified ·
1 Parent(s): 0acd910

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
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("Please enter the text to convert into voice")
17
  if not voice:
18
- return None, gr.Warning("Please select a voice.")
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("Text input cannot be empty.")
141
  if num_lines <= 0:
142
- return None, None, gr.Warning("Number of SRT lines must be greater than zero.")
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="Enter text here...")
172
- voice_dropdown = gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value="")
173
- rate_slider = gr.Slider(minimum=-50, maximum=50, value=0, label="Rate Adjustment (%)", step=1)
174
- pitch_slider = gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1)
175
 
176
- num_lines_slider = gr.Slider(minimum=1, maximum=5, value=2, label="Number of SRT Lines", 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="Generated Audio", type="filepath")
182
- output_srt = gr.File(label="Generated SRT", file_count="single")
183
- warning_msg = gr.Markdown(label="Warning", visible=False)
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,