Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -339,6 +339,7 @@ def generate_subtitles(audio_file_path, prompt, language, auto_detect_language,
|
|
339 |
return temp_srt_path, None, None
|
340 |
|
341 |
|
|
|
342 |
with gr.Blocks() as demo:
|
343 |
gr.Markdown(
|
344 |
"""
|
@@ -349,65 +350,63 @@ with gr.Blocks() as demo:
|
|
349 |
)
|
350 |
with gr.Tabs():
|
351 |
with gr.TabItem("LLMs"):
|
352 |
-
with gr.
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
chatbot
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
)
|
405 |
-
model.change(update_max_tokens, inputs=[model], outputs=max_tokens)
|
406 |
with gr.TabItem("Speech To Text"):
|
407 |
with gr.Tabs():
|
408 |
with gr.TabItem("Transcription"):
|
409 |
gr.Markdown("Transcript audio from files to text!")
|
410 |
-
with gr.
|
411 |
audio_input = gr.File(
|
412 |
type="filepath", label="Upload File containing Audio", file_types=[f".{ext}" for ext in ALLOWED_FILE_EXTENSIONS]
|
413 |
)
|
@@ -416,12 +415,10 @@ with gr.Blocks() as demo:
|
|
416 |
value="whisper-large-v3",
|
417 |
label="Model",
|
418 |
)
|
419 |
-
with gr.Row():
|
420 |
transcribe_prompt = gr.Textbox(
|
421 |
label="Prompt (Optional)",
|
422 |
info="Specify any context or spelling corrections.",
|
423 |
)
|
424 |
-
with gr.Column():
|
425 |
language = gr.Dropdown(
|
426 |
choices=[(lang, code) for lang, code in LANGUAGE_CODES.items()],
|
427 |
value="en",
|
@@ -437,7 +434,7 @@ with gr.Blocks() as demo:
|
|
437 |
)
|
438 |
with gr.TabItem("Translation"):
|
439 |
gr.Markdown("Transcript audio from files and translate them to English text!")
|
440 |
-
with gr.
|
441 |
audio_input_translate = gr.File(
|
442 |
type="filepath", label="Upload File containing Audio", file_types=[f".{ext}" for ext in ALLOWED_FILE_EXTENSIONS]
|
443 |
)
|
@@ -446,7 +443,6 @@ with gr.Blocks() as demo:
|
|
446 |
value="whisper-large-v3",
|
447 |
label="Model",
|
448 |
)
|
449 |
-
with gr.Row():
|
450 |
translate_prompt = gr.Textbox(
|
451 |
label="Prompt (Optional)",
|
452 |
info="Specify any context or spelling corrections.",
|
@@ -459,7 +455,7 @@ with gr.Blocks() as demo:
|
|
459 |
outputs=translation_output,
|
460 |
)
|
461 |
with gr.TabItem("Subtitle Maker"):
|
462 |
-
with gr.
|
463 |
audio_input_subtitles = gr.File(
|
464 |
label="Upload Audio/Video",
|
465 |
file_types=[f".{ext}" for ext in ALLOWED_FILE_EXTENSIONS],
|
@@ -473,15 +469,14 @@ with gr.Blocks() as demo:
|
|
473 |
label="Prompt (Optional)",
|
474 |
info="Specify any context or spelling corrections.",
|
475 |
)
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
)
|
485 |
transcribe_button_subtitles = gr.Button("Generate Subtitles")
|
486 |
srt_output = gr.File(label="SRT Output File")
|
487 |
video_output = gr.File(label="Output Video with Subtitles")
|
@@ -497,4 +492,5 @@ with gr.Blocks() as demo:
|
|
497 |
outputs=[srt_output, video_output, gr.Textbox(label="Error")],
|
498 |
)
|
499 |
|
500 |
-
demo.launch()
|
|
|
|
339 |
return temp_srt_path, None, None
|
340 |
|
341 |
|
342 |
+
|
343 |
with gr.Blocks() as demo:
|
344 |
gr.Markdown(
|
345 |
"""
|
|
|
350 |
)
|
351 |
with gr.Tabs():
|
352 |
with gr.TabItem("LLMs"):
|
353 |
+
with gr.Column():
|
354 |
+
model = gr.Dropdown(
|
355 |
+
choices=[
|
356 |
+
"llama3-70b-8192",
|
357 |
+
"llama3-8b-8192",
|
358 |
+
"mixtral-8x7b-32768",
|
359 |
+
"gemma-7b-it",
|
360 |
+
"gemma2-9b-it",
|
361 |
+
],
|
362 |
+
value="llama3-70b-8192",
|
363 |
+
label="Model",
|
364 |
+
)
|
365 |
+
temperature = gr.Slider(
|
366 |
+
minimum=0.0,
|
367 |
+
maximum=1.0,
|
368 |
+
step=0.01,
|
369 |
+
value=0.5,
|
370 |
+
label="Temperature",
|
371 |
+
info="Controls diversity of the generated text. Lower is more deterministic, higher is more creative.",
|
372 |
+
)
|
373 |
+
max_tokens = gr.Slider(
|
374 |
+
minimum=1,
|
375 |
+
maximum=8192,
|
376 |
+
step=1,
|
377 |
+
value=4096,
|
378 |
+
label="Max Tokens",
|
379 |
+
info="The maximum number of tokens that the model can process in a single response.<br>Maximums: 8k for gemma 7b it, gemma2 9b it, llama 7b & 70b, 32k for mixtral 8x7b.",
|
380 |
+
)
|
381 |
+
top_p = gr.Slider(
|
382 |
+
minimum=0.0,
|
383 |
+
maximum=1.0,
|
384 |
+
step=0.01,
|
385 |
+
value=0.5,
|
386 |
+
label="Top P",
|
387 |
+
info="A method of text generation where a model will only consider the most probable next tokens that make up the probability p.",
|
388 |
+
)
|
389 |
+
seed = gr.Number(
|
390 |
+
precision=0, value=42, label="Seed", info="A starting point to initiate generation, use 0 for random"
|
391 |
+
)
|
392 |
+
model.change(update_max_tokens, inputs=[model], outputs=max_tokens)
|
393 |
+
chatbot = gr.ChatInterface(
|
394 |
+
fn=generate_response,
|
395 |
+
chatbot=None,
|
396 |
+
additional_inputs=[
|
397 |
+
model,
|
398 |
+
temperature,
|
399 |
+
max_tokens,
|
400 |
+
top_p,
|
401 |
+
seed,
|
402 |
+
],
|
403 |
+
)
|
404 |
+
model.change(update_max_tokens, inputs=[model], outputs=max_tokens)
|
|
|
|
|
405 |
with gr.TabItem("Speech To Text"):
|
406 |
with gr.Tabs():
|
407 |
with gr.TabItem("Transcription"):
|
408 |
gr.Markdown("Transcript audio from files to text!")
|
409 |
+
with gr.Column():
|
410 |
audio_input = gr.File(
|
411 |
type="filepath", label="Upload File containing Audio", file_types=[f".{ext}" for ext in ALLOWED_FILE_EXTENSIONS]
|
412 |
)
|
|
|
415 |
value="whisper-large-v3",
|
416 |
label="Model",
|
417 |
)
|
|
|
418 |
transcribe_prompt = gr.Textbox(
|
419 |
label="Prompt (Optional)",
|
420 |
info="Specify any context or spelling corrections.",
|
421 |
)
|
|
|
422 |
language = gr.Dropdown(
|
423 |
choices=[(lang, code) for lang, code in LANGUAGE_CODES.items()],
|
424 |
value="en",
|
|
|
434 |
)
|
435 |
with gr.TabItem("Translation"):
|
436 |
gr.Markdown("Transcript audio from files and translate them to English text!")
|
437 |
+
with gr.Column():
|
438 |
audio_input_translate = gr.File(
|
439 |
type="filepath", label="Upload File containing Audio", file_types=[f".{ext}" for ext in ALLOWED_FILE_EXTENSIONS]
|
440 |
)
|
|
|
443 |
value="whisper-large-v3",
|
444 |
label="Model",
|
445 |
)
|
|
|
446 |
translate_prompt = gr.Textbox(
|
447 |
label="Prompt (Optional)",
|
448 |
info="Specify any context or spelling corrections.",
|
|
|
455 |
outputs=translation_output,
|
456 |
)
|
457 |
with gr.TabItem("Subtitle Maker"):
|
458 |
+
with gr.Column():
|
459 |
audio_input_subtitles = gr.File(
|
460 |
label="Upload Audio/Video",
|
461 |
file_types=[f".{ext}" for ext in ALLOWED_FILE_EXTENSIONS],
|
|
|
469 |
label="Prompt (Optional)",
|
470 |
info="Specify any context or spelling corrections.",
|
471 |
)
|
472 |
+
language_subtitles = gr.Dropdown(
|
473 |
+
choices=[(lang, code) for lang, code in LANGUAGE_CODES.items()],
|
474 |
+
value="en",
|
475 |
+
label="Language",
|
476 |
+
)
|
477 |
+
auto_detect_language_subtitles = gr.Checkbox(
|
478 |
+
label="Auto Detect Language"
|
479 |
+
)
|
|
|
480 |
transcribe_button_subtitles = gr.Button("Generate Subtitles")
|
481 |
srt_output = gr.File(label="SRT Output File")
|
482 |
video_output = gr.File(label="Output Video with Subtitles")
|
|
|
492 |
outputs=[srt_output, video_output, gr.Textbox(label="Error")],
|
493 |
)
|
494 |
|
495 |
+
demo.launch()
|
496 |
+
|