Upload app.py
Browse files
app.py
CHANGED
|
@@ -460,7 +460,9 @@ def extract_text(file):
|
|
| 460 |
with gr.Blocks() as lf_tts:
|
| 461 |
with gr.Row():
|
| 462 |
with gr.Column():
|
|
|
|
| 463 |
text = gr.Textbox(label='Input Text', info='Generate speech in batches of 100 text segments and automatically join them together')
|
|
|
|
| 464 |
with gr.Row():
|
| 465 |
voice = gr.Dropdown(list(CHOICES.items()), value='af', allow_custom_value=True, label='Voice', info='Starred voices are more stable')
|
| 466 |
use_gpu = gr.Dropdown(
|
|
@@ -473,10 +475,6 @@ with gr.Blocks() as lf_tts:
|
|
| 473 |
with gr.Accordion('Text Settings', open=False):
|
| 474 |
skip_square_brackets = gr.Checkbox(True, label='Skip [Square Brackets]', info='Recommended for academic papers, Wikipedia articles, or texts with citations')
|
| 475 |
newline_split = gr.Number(2, label='Newline Split', info='Split the input text on this many newlines. Affects how the text is segmented.', precision=0, minimum=0)
|
| 476 |
-
with gr.Row():
|
| 477 |
-
upload_btn = gr.UploadButton('Upload txt or pdf', file_types=['text'])
|
| 478 |
-
segment_btn = gr.Button('Tokenize', variant='primary')
|
| 479 |
-
upload_btn.upload(fn=extract_text, inputs=[upload_btn], outputs=[text])
|
| 480 |
with gr.Column():
|
| 481 |
audio_stream = gr.Audio(label='Output Audio Stream', interactive=False, streaming=True, autoplay=True)
|
| 482 |
with gr.Accordion('Audio Settings', open=True):
|
|
@@ -484,14 +482,13 @@ with gr.Blocks() as lf_tts:
|
|
| 484 |
trim = gr.Slider(minimum=0, maximum=24000, value=0, step=1000, label='✂️ Trim', info='Cut from both ends')
|
| 485 |
pad_between = gr.Slider(minimum=0, maximum=24000, value=0, step=1000, label='🔇 Pad Between', info='How much silence to insert between segments')
|
| 486 |
with gr.Row():
|
|
|
|
| 487 |
generate_btn = gr.Button('Generate x0', variant='secondary', interactive=False)
|
| 488 |
-
stop_btn = gr.Button('Stop', variant='stop')
|
| 489 |
with gr.Row():
|
| 490 |
segments = gr.Dataframe(headers=['#', 'Text', 'Tokens', 'Length'], row_count=(1, 'dynamic'), col_count=(4, 'fixed'), label='Segments', interactive=False, wrap=True)
|
| 491 |
segments.change(fn=did_change_segments, inputs=[segments], outputs=[segment_btn, generate_btn])
|
| 492 |
segment_btn.click(segment_and_tokenize, inputs=[text, voice, skip_square_brackets, newline_split], outputs=[segments])
|
| 493 |
-
|
| 494 |
-
stop_btn.click(cancels=[generate_event])
|
| 495 |
|
| 496 |
with gr.Blocks() as about:
|
| 497 |
gr.Markdown('''
|
|
|
|
| 460 |
with gr.Blocks() as lf_tts:
|
| 461 |
with gr.Row():
|
| 462 |
with gr.Column():
|
| 463 |
+
file_input = gr.File(file_types=['.pdf', '.txt'], label='Input File: pdf or txt')
|
| 464 |
text = gr.Textbox(label='Input Text', info='Generate speech in batches of 100 text segments and automatically join them together')
|
| 465 |
+
file_input.upload(fn=extract_text, inputs=[file_input], outputs=[text])
|
| 466 |
with gr.Row():
|
| 467 |
voice = gr.Dropdown(list(CHOICES.items()), value='af', allow_custom_value=True, label='Voice', info='Starred voices are more stable')
|
| 468 |
use_gpu = gr.Dropdown(
|
|
|
|
| 475 |
with gr.Accordion('Text Settings', open=False):
|
| 476 |
skip_square_brackets = gr.Checkbox(True, label='Skip [Square Brackets]', info='Recommended for academic papers, Wikipedia articles, or texts with citations')
|
| 477 |
newline_split = gr.Number(2, label='Newline Split', info='Split the input text on this many newlines. Affects how the text is segmented.', precision=0, minimum=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
with gr.Column():
|
| 479 |
audio_stream = gr.Audio(label='Output Audio Stream', interactive=False, streaming=True, autoplay=True)
|
| 480 |
with gr.Accordion('Audio Settings', open=True):
|
|
|
|
| 482 |
trim = gr.Slider(minimum=0, maximum=24000, value=0, step=1000, label='✂️ Trim', info='Cut from both ends')
|
| 483 |
pad_between = gr.Slider(minimum=0, maximum=24000, value=0, step=1000, label='🔇 Pad Between', info='How much silence to insert between segments')
|
| 484 |
with gr.Row():
|
| 485 |
+
segment_btn = gr.Button('Tokenize', variant='primary')
|
| 486 |
generate_btn = gr.Button('Generate x0', variant='secondary', interactive=False)
|
|
|
|
| 487 |
with gr.Row():
|
| 488 |
segments = gr.Dataframe(headers=['#', 'Text', 'Tokens', 'Length'], row_count=(1, 'dynamic'), col_count=(4, 'fixed'), label='Segments', interactive=False, wrap=True)
|
| 489 |
segments.change(fn=did_change_segments, inputs=[segments], outputs=[segment_btn, generate_btn])
|
| 490 |
segment_btn.click(segment_and_tokenize, inputs=[text, voice, skip_square_brackets, newline_split], outputs=[segments])
|
| 491 |
+
generate_btn.click(lf_generate, inputs=[segments, voice, speed, trim, pad_between, use_gpu], outputs=[audio_stream])
|
|
|
|
| 492 |
|
| 493 |
with gr.Blocks() as about:
|
| 494 |
gr.Markdown('''
|