nxhong commited on
Commit
591dff6
·
verified ·
1 Parent(s): e232bc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -56
app.py CHANGED
@@ -239,81 +239,60 @@ def predict(
239
 
240
 
241
  with gr.Blocks(analytics_enabled=False) as demo:
242
- with gr.Row():
243
- with gr.Column():
244
- gr.Markdown(
245
- """
246
- # Text to Speech Vietnamese ✨
247
- - Special thank to thinhlpg
248
- """
249
- )
250
- with gr.Column():
251
- # placeholder to align the image
252
- pass
253
 
254
  with gr.Row():
255
- with gr.Column():
256
  input_text_gr = gr.Textbox(
257
- label="Text Prompt (Văn bản cần đọc)",
258
- info="Mỗi câu nên từ 10 từ trở lên.",
259
- value="Xin chào, tôi là một mô hình chuyển đổi văn bản thành giọng nói tiếng Việt.",
 
 
260
  )
 
261
  language_gr = gr.Dropdown(
262
- label="Language (Ngôn ngữ)",
263
- choices=[
264
- "vi",
265
- "en",
266
- "es",
267
- "fr",
268
- "de",
269
- "it",
270
- "pt",
271
- "pl",
272
- "tr",
273
- "ru",
274
- "nl",
275
- "cs",
276
- "ar",
277
- "zh-cn",
278
- "ja",
279
- "ko",
280
- "hu",
281
- "hi",
282
- ],
283
- max_choices=1,
284
  value="vi",
 
285
  )
 
286
  normalize_text = gr.Checkbox(
287
  label="Chuẩn hóa văn bản tiếng Việt",
288
- info="Normalize Vietnamese text",
289
- value=True,
290
  )
 
291
  ref_gr = gr.Audio(
292
- label="Reference Audio (Giọng mẫu)",
293
  type="filepath",
294
- value="model/samples/nu-luu-loat.wav",
295
- )
296
- tts_button = gr.Button(
297
- "Đọc 🗣️🔥",
298
- elem_id="send-btn",
299
- visible=True,
300
- variant="primary",
301
  )
302
 
303
- with gr.Column():
304
- audio_gr = gr.Audio(label="Synthesised Audio", autoplay=True)
305
- out_text_gr = gr.Text(label="Metrics")
 
 
306
 
 
307
  tts_button.click(
308
  predict,
309
- [
310
- input_text_gr,
311
- language_gr,
312
- ref_gr,
313
- normalize_text,
 
 
 
 
 
 
 
314
  ],
315
  outputs=[audio_gr, out_text_gr],
316
- api_name="predict",
317
  )
318
 
319
  demo.queue()
 
239
 
240
 
241
  with gr.Blocks(analytics_enabled=False) as demo:
242
+ gr.Markdown("# 🇻🇳 Text to Speech Vietnamese (capleaf/viXTTS)")
243
+ gr.Markdown("Nhập văn bản tiếng Việt và chọn giọng mẫu để tạo âm thanh 🎙️")
 
 
 
 
 
 
 
 
 
244
 
245
  with gr.Row():
246
+ with gr.Column(scale=1):
247
  input_text_gr = gr.Textbox(
248
+ label="Nhập văn bản",
249
+ placeholder="Nhập câu tiếng Việt để chuyển thành giọng nói...",
250
+ lines=3,
251
+ interactive=True,
252
+ value="Xin chào, tôi là mô hình chuyển đổi văn bản thành giọng nói tiếng Việt."
253
  )
254
+
255
  language_gr = gr.Dropdown(
256
+ label="Ngôn ngữ",
257
+ choices=["vi", "en", "zh-cn", "ja", "ko"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  value="vi",
259
+ interactive=True
260
  )
261
+
262
  normalize_text = gr.Checkbox(
263
  label="Chuẩn hóa văn bản tiếng Việt",
264
+ value=True
 
265
  )
266
+
267
  ref_gr = gr.Audio(
268
+ label="Giọng mẫu (Reference Audio)",
269
  type="filepath",
270
+ value="model/samples/nu-luu-loat.wav"
 
 
 
 
 
 
271
  )
272
 
273
+ tts_button = gr.Button("▶️ Đọc văn bản", variant="primary")
274
+
275
+ with gr.Column(scale=1):
276
+ audio_gr = gr.Audio(label="Kết quả giọng nói", autoplay=True)
277
+ out_text_gr = gr.Textbox(label="Thông tin chi tiết", interactive=False)
278
 
279
+ # Nút sinh âm thanh
280
  tts_button.click(
281
  predict,
282
+ inputs=[input_text_gr, language_gr, ref_gr, normalize_text],
283
+ outputs=[audio_gr, out_text_gr]
284
+ )
285
+
286
+ # Khi chạy Space sẽ tự test 1 câu luôn
287
+ demo.load(
288
+ predict,
289
+ inputs=[
290
+ gr.Textbox(value="Xin chào, tôi là mô hình viXTTS đang chạy thử."),
291
+ gr.Dropdown(value="vi"),
292
+ gr.Audio(value="model/samples/nu-luu-loat.wav", type="filepath"),
293
+ gr.Checkbox(value=True),
294
  ],
295
  outputs=[audio_gr, out_text_gr],
 
296
  )
297
 
298
  demo.queue()