Remsky commited on
Commit
426ae11
·
1 Parent(s): 5f7437d

Updated sample ui location

Browse files
Files changed (2) hide show
  1. app.py +31 -51
  2. lib/ui_content.py +24 -0
app.py CHANGED
@@ -6,7 +6,7 @@ import logging
6
  import matplotlib.pyplot as plt
7
  import numpy as np
8
  from lib import format_audio_output
9
- from lib.ui_content import header_html, demo_text_info
10
  from lib.book_utils import get_available_books, get_book_info, get_chapter_text
11
  from lib.text_utils import count_tokens
12
  from tts_model import TTSModel
@@ -179,28 +179,7 @@ def create_performance_plot(metrics, voice_names):
179
  return fig, metrics_text
180
 
181
  # Create Gradio interface
182
- with gr.Blocks(title="Kokoro TTS Demo", css="""
183
- .equal-height {
184
- min-height: 400px;
185
- display: flex;
186
- flex-direction: column;
187
- }
188
- .token-label {
189
- font-size: 1rem;
190
- margin-bottom: 0.3rem;
191
- text-align: center;
192
- padding: 0.2rem 0;
193
- }
194
- .token-count {
195
- color: #4169e1;
196
- }
197
- #gradio-accordion > .label-wrap {
198
- background: radial-gradient(circle, rgba(147,51,234,0.4) 0%, rgba(30,58,138,0.4) 100%);
199
- padding: 0.8rem 1rem;
200
- font-weight: 500;
201
- color: #000000;
202
- }
203
- """) as demo:
204
  gr.HTML(header_html)
205
 
206
  with gr.Row():
@@ -350,6 +329,34 @@ with gr.Blocks(title="Kokoro TTS Demo", css="""
350
 
351
  # Column 2: Controls
352
  with gr.Column(elem_classes="equal-height"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
  file_input = gr.File(
354
  label="Upload .txt file",
355
  file_types=[".txt"],
@@ -393,34 +400,7 @@ with gr.Blocks(title="Kokoro TTS Demo", css="""
393
 
394
  submit_btn = gr.Button("Generate Speech", variant="primary")
395
 
396
- # Audio Samples Accordion with custom styling
397
- with gr.Accordion("Audio Samples", open=False, elem_id='gradio-accordion') as audio_accordion:
398
- sample_files = [f for f in os.listdir("samples") if f.endswith('.wav')]
399
- sample_audio = gr.Audio(
400
- value=os.path.join("samples", sample_files[0]) if sample_files else None,
401
- sources=["upload"],
402
- type="filepath",
403
- label="Sample Audio",
404
- interactive=False
405
- )
406
- sample_dropdown = gr.Dropdown(
407
- choices=sample_files,
408
- value=sample_files[0] if sample_files else None,
409
- label="Select Sample",
410
- type="value"
411
- )
412
-
413
- def update_sample(sample_name):
414
- if not sample_name:
415
- return None
416
- return os.path.join("samples", sample_name)
417
-
418
- sample_dropdown.change(
419
- fn=update_sample,
420
- inputs=[sample_dropdown],
421
- outputs=[sample_audio]
422
- )
423
-
424
 
425
 
426
  # Column 3: Output
 
6
  import matplotlib.pyplot as plt
7
  import numpy as np
8
  from lib import format_audio_output
9
+ from lib.ui_content import header_html, demo_text_info, styling
10
  from lib.book_utils import get_available_books, get_book_info, get_chapter_text
11
  from lib.text_utils import count_tokens
12
  from tts_model import TTSModel
 
179
  return fig, metrics_text
180
 
181
  # Create Gradio interface
182
+ with gr.Blocks(title="Kokoro TTS Demo", css=styling) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  gr.HTML(header_html)
184
 
185
  with gr.Row():
 
329
 
330
  # Column 2: Controls
331
  with gr.Column(elem_classes="equal-height"):
332
+ # Audio Samples Accordion with custom styling
333
+ with gr.Accordion("Audio Samples", open=False, elem_id='gradio-accordion') as audio_accordion:
334
+ sample_files = [f for f in os.listdir("samples") if f.endswith('.wav')]
335
+ sample_audio = gr.Audio(
336
+ value=os.path.join("samples", sample_files[0]) if sample_files else None,
337
+ sources=["upload"],
338
+ type="filepath",
339
+ label="Sample Audio",
340
+ interactive=False
341
+ )
342
+ sample_dropdown = gr.Dropdown(
343
+ choices=sample_files,
344
+ value=sample_files[0] if sample_files else None,
345
+ label="Select Sample",
346
+ type="value"
347
+ )
348
+
349
+ def update_sample(sample_name):
350
+ if not sample_name:
351
+ return None
352
+ return os.path.join("samples", sample_name)
353
+
354
+ sample_dropdown.change(
355
+ fn=update_sample,
356
+ inputs=[sample_dropdown],
357
+ outputs=[sample_audio]
358
+ )
359
+
360
  file_input = gr.File(
361
  label="Upload .txt file",
362
  file_types=[".txt"],
 
400
 
401
  submit_btn = gr.Button("Generate Speech", variant="primary")
402
 
403
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
 
405
 
406
  # Column 3: Output
lib/ui_content.py CHANGED
@@ -46,3 +46,27 @@ header_html = f"""
46
  demo_text_info = """
47
  All input text was sourced as public domain.
48
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  demo_text_info = """
47
  All input text was sourced as public domain.
48
  """
49
+
50
+ styling = """
51
+ .equal-height {
52
+ min-height: 400px;
53
+ display: flex;
54
+ flex-direction: column;
55
+ }
56
+ .token-label {
57
+ font-size: 1rem;
58
+ margin-bottom: 0.3rem;
59
+ text-align: center;
60
+ padding: 0.2rem 0;
61
+ }
62
+ .token-count {
63
+ color: #4169e1;
64
+ }
65
+ #gradio-accordion > .label-wrap {
66
+ background: radial-gradient(circle, rgba(147,51,234,0.4) 0%, rgba(30,58,138,0.4) 100%);
67
+ padding: 0.8rem 1rem;
68
+ font-size: 1rem;
69
+ color: #000000;
70
+ border-radius: 4px;
71
+ }
72
+ """