Spaces:
Paused
Paused
Modernize: Gradio 6.29, Python 3.12, File paths, SRT millisecond fix, whisper-large-v3-turbo option
Browse files- README.md +2 -1
- app.py +8 -8
- requirements.txt +1 -2
README.md
CHANGED
|
@@ -4,7 +4,8 @@ emoji: 🔥
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: other
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 6.29.0
|
| 8 |
+
python_version: "3.12"
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
license: other
|
app.py
CHANGED
|
@@ -241,8 +241,8 @@ def check_file(audio_file_path):
|
|
| 241 |
def format_time(seconds):
|
| 242 |
hours = int(seconds // 3600)
|
| 243 |
minutes = int((seconds % 3600) // 60)
|
|
|
|
| 244 |
seconds = int(seconds % 60)
|
| 245 |
-
milliseconds = int((seconds % 1) * 1000)
|
| 246 |
|
| 247 |
return f"{hours:02}:{minutes:02}:{seconds:02},{milliseconds:03}"
|
| 248 |
|
|
@@ -303,8 +303,8 @@ def generate_subtitles(audio_file_path, prompt, language, auto_detect_language,
|
|
| 303 |
output_file_path = chunk_path.replace(os.path.splitext(chunk_path)[1], "_with_subs" + os.path.splitext(chunk_path)[1])
|
| 304 |
# Handle font selection
|
| 305 |
if font_selection == "Custom Font File" and font_file:
|
| 306 |
-
font_name = os.path.splitext(os.path.basename(font_file
|
| 307 |
-
font_dir = os.path.dirname(font_file
|
| 308 |
elif font_selection == "Custom Font File" and not font_file:
|
| 309 |
font_name = None # Let FFmpeg use its default Arial
|
| 310 |
font_dir = None # No font directory
|
|
@@ -383,8 +383,8 @@ def generate_subtitles(audio_file_path, prompt, language, auto_detect_language,
|
|
| 383 |
)
|
| 384 |
# Handle font selection
|
| 385 |
if font_selection == "Custom Font File" and font_file:
|
| 386 |
-
font_name = os.path.splitext(os.path.basename(font_file
|
| 387 |
-
font_dir = os.path.dirname(font_file
|
| 388 |
elif font_selection == "Custom Font File" and not font_file:
|
| 389 |
font_name = None # Let FFmpeg use its default Arial
|
| 390 |
font_dir = None # No font directory
|
|
@@ -450,7 +450,7 @@ h1{text-align:center}
|
|
| 450 |
"""
|
| 451 |
|
| 452 |
|
| 453 |
-
with gr.Blocks(
|
| 454 |
gr.Markdown(
|
| 455 |
"""
|
| 456 |
# Fast Subtitle Maker
|
|
@@ -462,7 +462,7 @@ with gr.Blocks(theme=theme, css=css) as interface:
|
|
| 462 |
)
|
| 463 |
with gr.Row():
|
| 464 |
audio_input_subtitles = gr.File(label="Upload Audio/Video", file_types=[f".{ext}" for ext in ALLOWED_FILE_EXTENSIONS],)
|
| 465 |
-
model_choice_subtitles = gr.Dropdown(choices=["whisper-large-v3"], value="whisper-large-v3", label="Audio Speech Recogition (ASR) Model")
|
| 466 |
with gr.Row():
|
| 467 |
transcribe_prompt_subtitles = gr.Textbox(label="Prompt (Optional)", info="Specify any context or spelling corrections.")
|
| 468 |
with gr.Row():
|
|
@@ -520,4 +520,4 @@ with gr.Blocks(theme=theme, css=css) as interface:
|
|
| 520 |
)
|
| 521 |
|
| 522 |
|
| 523 |
-
interface.launch(
|
|
|
|
| 241 |
def format_time(seconds):
|
| 242 |
hours = int(seconds // 3600)
|
| 243 |
minutes = int((seconds % 3600) // 60)
|
| 244 |
+
milliseconds = int(round((seconds % 1) * 1000)) % 1000
|
| 245 |
seconds = int(seconds % 60)
|
|
|
|
| 246 |
|
| 247 |
return f"{hours:02}:{minutes:02}:{seconds:02},{milliseconds:03}"
|
| 248 |
|
|
|
|
| 303 |
output_file_path = chunk_path.replace(os.path.splitext(chunk_path)[1], "_with_subs" + os.path.splitext(chunk_path)[1])
|
| 304 |
# Handle font selection
|
| 305 |
if font_selection == "Custom Font File" and font_file:
|
| 306 |
+
font_name = os.path.splitext(os.path.basename(font_file))[0] # Get font filename without extension
|
| 307 |
+
font_dir = os.path.dirname(font_file) # Get font directory path
|
| 308 |
elif font_selection == "Custom Font File" and not font_file:
|
| 309 |
font_name = None # Let FFmpeg use its default Arial
|
| 310 |
font_dir = None # No font directory
|
|
|
|
| 383 |
)
|
| 384 |
# Handle font selection
|
| 385 |
if font_selection == "Custom Font File" and font_file:
|
| 386 |
+
font_name = os.path.splitext(os.path.basename(font_file))[0] # Get font filename without extension
|
| 387 |
+
font_dir = os.path.dirname(font_file) # Get font directory path
|
| 388 |
elif font_selection == "Custom Font File" and not font_file:
|
| 389 |
font_name = None # Let FFmpeg use its default Arial
|
| 390 |
font_dir = None # No font directory
|
|
|
|
| 450 |
"""
|
| 451 |
|
| 452 |
|
| 453 |
+
with gr.Blocks() as interface:
|
| 454 |
gr.Markdown(
|
| 455 |
"""
|
| 456 |
# Fast Subtitle Maker
|
|
|
|
| 462 |
)
|
| 463 |
with gr.Row():
|
| 464 |
audio_input_subtitles = gr.File(label="Upload Audio/Video", file_types=[f".{ext}" for ext in ALLOWED_FILE_EXTENSIONS],)
|
| 465 |
+
model_choice_subtitles = gr.Dropdown(choices=["whisper-large-v3", "whisper-large-v3-turbo"], value="whisper-large-v3", label="Audio Speech Recogition (ASR) Model")
|
| 466 |
with gr.Row():
|
| 467 |
transcribe_prompt_subtitles = gr.Textbox(label="Prompt (Optional)", info="Specify any context or spelling corrections.")
|
| 468 |
with gr.Row():
|
|
|
|
| 520 |
)
|
| 521 |
|
| 522 |
|
| 523 |
+
interface.launch(theme=theme, css=css)
|
requirements.txt
CHANGED
|
@@ -1,2 +1 @@
|
|
| 1 |
-
|
| 2 |
-
groq
|
|
|
|
| 1 |
+
groq
|
|
|