Commit
·
fc4371c
1
Parent(s):
b77809f
fix multiple form submission; fix typo in default font setting; delete stroke in highlight
Browse files- main.py +4 -6
- static/process_settings.html +3 -3
- static/transcribe_video.html +2 -2
- utils/subtitler.py +1 -1
main.py
CHANGED
|
@@ -16,12 +16,10 @@ from fastapi.security import HTTPBasic
|
|
| 16 |
from pydantic import BaseModel, field_validator
|
| 17 |
from cachetools import TTLCache
|
| 18 |
|
| 19 |
-
## THIS IS A BREAKING CHANGE. SRT FILE INPUT DEPRECATED.
|
| 20 |
-
## DONE: separate transcriber from subtitler logic.
|
| 21 |
-
## DONE: improve loading spinner. (redirect)
|
| 22 |
-
## DONE: fix tempdir cleanup
|
| 23 |
-
## DONE: add transcription preview component + allow for interactive validation of transcription in-browser.
|
| 24 |
## TODO: add word level highlighting option. WIP (Avoid caption char overflow by using a max chars heuristic in transcriber)
|
|
|
|
|
|
|
|
|
|
| 25 |
## TODO: improve UI
|
| 26 |
|
| 27 |
app = FastAPI()
|
|
@@ -111,7 +109,7 @@ async def process_video_api(video_path: str = Form(...),
|
|
| 111 |
srt_string: str = Form(...),
|
| 112 |
srt_json: str = Form(...),
|
| 113 |
fontsize: Optional[int] = Form(42),
|
| 114 |
-
font: Optional[str] = Form("
|
| 115 |
bg_color: Optional[str] = Form("transparent"),
|
| 116 |
text_color: Optional[str] = Form("white"),
|
| 117 |
highlight_mode: Optional[bool] = Form(False),
|
|
|
|
| 16 |
from pydantic import BaseModel, field_validator
|
| 17 |
from cachetools import TTLCache
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
## TODO: add word level highlighting option. WIP (Avoid caption char overflow by using a max chars heuristic in transcriber)
|
| 20 |
+
## TODO: prevent double for submission in process_video/
|
| 21 |
+
## TODO: add more video format options
|
| 22 |
+
## TODO: Add Box + Word highlighting mode options
|
| 23 |
## TODO: improve UI
|
| 24 |
|
| 25 |
app = FastAPI()
|
|
|
|
| 109 |
srt_string: str = Form(...),
|
| 110 |
srt_json: str = Form(...),
|
| 111 |
fontsize: Optional[int] = Form(42),
|
| 112 |
+
font: Optional[str] = Form("Helvetica-Bold"),
|
| 113 |
bg_color: Optional[str] = Form("transparent"),
|
| 114 |
text_color: Optional[str] = Form("white"),
|
| 115 |
highlight_mode: Optional[bool] = Form(False),
|
static/process_settings.html
CHANGED
|
@@ -110,7 +110,7 @@
|
|
| 110 |
</style>
|
| 111 |
</head>
|
| 112 |
<body>
|
| 113 |
-
<form action="/process_video/" method="post">
|
| 114 |
<h2>Step 2: Edit Transcription & Style</h2>
|
| 115 |
|
| 116 |
<div class="form-section">
|
|
@@ -176,7 +176,7 @@
|
|
| 176 |
|
| 177 |
<input type="hidden" name="video_path" value="{{ video_path }}">
|
| 178 |
<input type="hidden" name="temp_dir_path" value="{{ temp_dir_path }}">
|
| 179 |
-
<input type="submit" value="Submit">
|
| 180 |
</form>
|
| 181 |
|
| 182 |
<div class="centered-link">
|
|
@@ -219,7 +219,7 @@
|
|
| 219 |
document.getElementById("srt_json").value = jsonText;
|
| 220 |
}
|
| 221 |
|
| 222 |
-
populateDropdown('font', '/static/fonts.txt', "
|
| 223 |
populateDropdown('bg_color', '/static/colors.txt', "transparent");
|
| 224 |
populateDropdown('text_color', '/static/colors.txt', "white");
|
| 225 |
populateDropdown('highlight_color', '/static/colors.txt', "LightBlue");
|
|
|
|
| 110 |
</style>
|
| 111 |
</head>
|
| 112 |
<body>
|
| 113 |
+
<form action="/process_video/" method="post" onsubmit="submitButton.disabled = true; return true;">
|
| 114 |
<h2>Step 2: Edit Transcription & Style</h2>
|
| 115 |
|
| 116 |
<div class="form-section">
|
|
|
|
| 176 |
|
| 177 |
<input type="hidden" name="video_path" value="{{ video_path }}">
|
| 178 |
<input type="hidden" name="temp_dir_path" value="{{ temp_dir_path }}">
|
| 179 |
+
<input type="submit" name="submitButton" value="Submit">
|
| 180 |
</form>
|
| 181 |
|
| 182 |
<div class="centered-link">
|
|
|
|
| 219 |
document.getElementById("srt_json").value = jsonText;
|
| 220 |
}
|
| 221 |
|
| 222 |
+
populateDropdown('font', '/static/fonts.txt', "Helvetica-Bold");
|
| 223 |
populateDropdown('bg_color', '/static/colors.txt', "transparent");
|
| 224 |
populateDropdown('text_color', '/static/colors.txt', "white");
|
| 225 |
populateDropdown('highlight_color', '/static/colors.txt', "LightBlue");
|
static/transcribe_video.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
| 11 |
</style>
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
-
<form id="video-form" action="/transcribe/" method="post" enctype="multipart/form-data">
|
| 15 |
<h2>Step 1: Upload & Transcribe</h2>
|
| 16 |
|
| 17 |
<label for="video_file">Video File</label>
|
|
@@ -37,7 +37,7 @@
|
|
| 37 |
<i class="fas fa-spinner fa-spin"></i> Processing, please wait...
|
| 38 |
</div>
|
| 39 |
|
| 40 |
-
<input type="submit" value="Transcribe">
|
| 41 |
</form>
|
| 42 |
<script>
|
| 43 |
// Show loading spinner on submit
|
|
|
|
| 11 |
</style>
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
+
<form id="video-form" action="/transcribe/" method="post" enctype="multipart/form-data" onsubmit="submitButton.disabled = true; return true;">
|
| 15 |
<h2>Step 1: Upload & Transcribe</h2>
|
| 16 |
|
| 17 |
<label for="video_file">Video File</label>
|
|
|
|
| 37 |
<i class="fas fa-spinner fa-spin"></i> Processing, please wait...
|
| 38 |
</div>
|
| 39 |
|
| 40 |
+
<input type="submit" name="submitButton" value="Transcribe">
|
| 41 |
</form>
|
| 42 |
<script>
|
| 43 |
// Show loading spinner on submit
|
utils/subtitler.py
CHANGED
|
@@ -75,7 +75,7 @@ def subtitler(video_file: str,
|
|
| 75 |
word_end = float(word_info["end"])
|
| 76 |
|
| 77 |
# Create a background-only word clip
|
| 78 |
-
word_clip = TextClip(word, fontsize=fontsize, color=text_color,
|
| 79 |
method='label', bg_color=highlight_color)
|
| 80 |
word_clip = word_clip.set_start(word_start).set_end(word_end)
|
| 81 |
word_clip = word_clip.set_position((current_x - 7.5, subtitle_y_position))
|
|
|
|
| 75 |
word_end = float(word_info["end"])
|
| 76 |
|
| 77 |
# Create a background-only word clip
|
| 78 |
+
word_clip = TextClip(word, fontsize=fontsize, color=text_color, font=font,
|
| 79 |
method='label', bg_color=highlight_color)
|
| 80 |
word_clip = word_clip.set_start(word_start).set_end(word_end)
|
| 81 |
word_clip = word_clip.set_position((current_x - 7.5, subtitle_y_position))
|