Commit
·
2140c28
1
Parent(s):
80b7d93
improve UI, add json indent and textare backgroung; responsiveness (wip)
Browse files- static/process_settings.html +188 -84
static/process_settings.html
CHANGED
|
@@ -1,118 +1,222 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
display: flex;
|
| 19 |
-
flex-direction:
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
</head>
|
| 24 |
<body>
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
</div>
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
</div>
|
| 37 |
-
</div>
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
</div>
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
<
|
| 48 |
-
</div>
|
| 49 |
|
| 50 |
<label for="fontsize">Font size</label>
|
| 51 |
<input type="number" name="fontsize" value="42">
|
| 52 |
|
| 53 |
<label for="font">Font</label>
|
| 54 |
<select id="font" name="font">
|
| 55 |
-
|
| 56 |
-
</select
|
| 57 |
|
| 58 |
<label for="bg_color">Background color</label>
|
| 59 |
-
<input type="text" name="bg_color" value="#
|
| 60 |
|
| 61 |
<label for="text_color">Text color</label>
|
| 62 |
<select id="text_color" name="text_color">
|
| 63 |
-
|
| 64 |
</select>
|
| 65 |
|
| 66 |
<label for="caption_mode">Caption mode</label>
|
| 67 |
<select name="caption_mode">
|
| 68 |
-
|
| 69 |
-
|
| 70 |
</select>
|
| 71 |
-
|
| 72 |
-
<input type="hidden" name="video_path" value="{{ video_path }}">
|
| 73 |
-
<input type="hidden" name="temp_dir_path" value="{{ temp_dir_path }}">
|
| 74 |
-
<input type="submit" value="Render & Download">
|
| 75 |
-
</form>
|
| 76 |
-
<div style="text-align: center; margin-top: 2em;">
|
| 77 |
-
<a href="/transcribe_video">Transcribe Another Video</a>
|
| 78 |
</div>
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
function populateDropdown(id, url, defaultValue = null) {
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
.catch(error => {
|
| 100 |
-
console.error(`Error loading ${url}:`, error);
|
| 101 |
-
});
|
| 102 |
-
}
|
| 103 |
-
|
| 104 |
-
// Set your default font and color here:
|
| 105 |
-
const DEFAULT_FONT = "Helvetica";
|
| 106 |
-
const DEFAULT_COLOR = "white";
|
| 107 |
-
|
| 108 |
-
// Populate dropdowns with defaults
|
| 109 |
-
populateDropdown('font', '/static/fonts.txt', DEFAULT_FONT);
|
| 110 |
-
populateDropdown('text_color', '/static/colors.txt', DEFAULT_COLOR);
|
| 111 |
function toggleTranscriptionFields() {
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
}
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
</body>
|
| 118 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
<head>
|
| 4 |
+
<title>Process Video</title>
|
| 5 |
+
<style>
|
| 6 |
+
body {
|
| 7 |
+
font-family: Arial, sans-serif;
|
| 8 |
+
background: #f0f0f0;
|
| 9 |
+
padding: 2rem;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
form {
|
| 13 |
+
background: white;
|
| 14 |
+
padding: 2rem;
|
| 15 |
+
border-radius: 10px;
|
| 16 |
+
max-width: 900px;
|
| 17 |
+
margin: auto;
|
| 18 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
h2 {
|
| 22 |
+
text-align: center;
|
| 23 |
+
margin-bottom: 1.5rem;
|
| 24 |
+
}
|
| 25 |
|
| 26 |
+
.form-section {
|
| 27 |
display: flex;
|
| 28 |
+
flex-direction: row;
|
| 29 |
+
gap: 3rem;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
.column {
|
| 33 |
+
flex: 1;
|
| 34 |
+
min-width: 0;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
.column h3 {
|
| 38 |
+
color: #4CAF50;
|
| 39 |
+
border-bottom: 2px solid #4CAF50;
|
| 40 |
+
padding-bottom: 0.5rem;
|
| 41 |
+
margin-bottom: 1rem;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
label {
|
| 45 |
+
font-weight: bold;
|
| 46 |
+
margin-top: 1rem;
|
| 47 |
+
display: block;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
input[type="text"],
|
| 51 |
+
input[type="number"],
|
| 52 |
+
select,
|
| 53 |
+
textarea {
|
| 54 |
+
width: 100%;
|
| 55 |
+
padding: 0.5rem;
|
| 56 |
+
border: 1px solid #ccc;
|
| 57 |
+
border-radius: 6px;
|
| 58 |
+
margin-top: 0.2rem;
|
| 59 |
+
margin-bottom: 1rem;
|
| 60 |
+
font-size: 1rem;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
textarea {
|
| 64 |
+
height: 320px;
|
| 65 |
+
font-family: monospace;
|
| 66 |
+
background-color: #f9f9f9;
|
| 67 |
+
border: 1px solid #ccc;
|
| 68 |
+
line-height: 1.4;
|
| 69 |
+
white-space: pre-wrap;
|
| 70 |
+
resize: vertical;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
.radio-container {
|
| 74 |
+
display: flex;
|
| 75 |
+
gap: 2rem;
|
| 76 |
+
margin-bottom: 1rem;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.radio-option {
|
| 80 |
+
display: flex;
|
| 81 |
+
flex-direction: column;
|
| 82 |
+
align-items: flex-start;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
input[type="submit"] {
|
| 86 |
+
background: #4CAF50;
|
| 87 |
+
color: white;
|
| 88 |
+
padding: 0.8rem 1.5rem;
|
| 89 |
+
border: none;
|
| 90 |
+
border-radius: 6px;
|
| 91 |
+
cursor: pointer;
|
| 92 |
+
font-size: 1rem;
|
| 93 |
+
margin-top: 2rem;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.centered-link {
|
| 97 |
+
text-align: center;
|
| 98 |
+
margin-top: 2em;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
@media (max-width: 800px) {
|
| 102 |
+
.form-section {
|
| 103 |
+
flex-direction: column;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
.column {
|
| 107 |
+
margin-bottom: 2rem;
|
| 108 |
+
}
|
| 109 |
+
}
|
| 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">
|
| 117 |
+
<!-- Left Column -->
|
| 118 |
+
<div class="column">
|
| 119 |
+
<h3>Highlighting Mode</h3>
|
| 120 |
+
<div class="radio-container">
|
| 121 |
+
<div class="radio-option">
|
| 122 |
+
<label for="mode_normal">Normal</label>
|
| 123 |
+
<input type="radio" name="highlight_mode" value="false" id="mode_normal" checked onchange="toggleTranscriptionFields()">
|
| 124 |
+
</div>
|
| 125 |
+
<div class="radio-option">
|
| 126 |
+
<label for="mode_highlight">Word-level</label>
|
| 127 |
+
<input type="radio" name="highlight_mode" value="true" id="mode_highlight" onchange="toggleTranscriptionFields()">
|
| 128 |
+
</div>
|
| 129 |
</div>
|
| 130 |
+
|
| 131 |
+
<div id="normal_input">
|
| 132 |
+
<label for="srt_string">Transcription (SRT)</label>
|
| 133 |
+
<textarea name="srt_string" id="srt_string">{{ transcription_text }}</textarea>
|
| 134 |
</div>
|
|
|
|
| 135 |
|
| 136 |
+
<div id="highlight_input" style="display: none;">
|
| 137 |
+
<label for="srt_json">Transcription (JSON)</label>
|
| 138 |
+
<textarea name="srt_json" id="srt_json"></textarea>
|
| 139 |
+
</div>
|
| 140 |
</div>
|
| 141 |
|
| 142 |
+
<!-- Right Column -->
|
| 143 |
+
<div class="column">
|
| 144 |
+
<h3>Visual Parameters</h3>
|
|
|
|
| 145 |
|
| 146 |
<label for="fontsize">Font size</label>
|
| 147 |
<input type="number" name="fontsize" value="42">
|
| 148 |
|
| 149 |
<label for="font">Font</label>
|
| 150 |
<select id="font" name="font">
|
| 151 |
+
<option>Loading fonts...</option>
|
| 152 |
+
</select>
|
| 153 |
|
| 154 |
<label for="bg_color">Background color</label>
|
| 155 |
+
<input type="text" name="bg_color" value="#00FFFF00">
|
| 156 |
|
| 157 |
<label for="text_color">Text color</label>
|
| 158 |
<select id="text_color" name="text_color">
|
| 159 |
+
<option>Loading colors...</option>
|
| 160 |
</select>
|
| 161 |
|
| 162 |
<label for="caption_mode">Caption mode</label>
|
| 163 |
<select name="caption_mode">
|
| 164 |
+
<option value="desktop">Desktop</option>
|
| 165 |
+
<option value="mobile">Mobile</option>
|
| 166 |
</select>
|
| 167 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
</div>
|
| 169 |
+
|
| 170 |
+
<input type="hidden" name="video_path" value="{{ video_path }}">
|
| 171 |
+
<input type="hidden" name="temp_dir_path" value="{{ temp_dir_path }}">
|
| 172 |
+
<input type="submit" value="Submit">
|
| 173 |
+
</form>
|
| 174 |
+
|
| 175 |
+
<div class="centered-link">
|
| 176 |
+
<a href="/transcribe_video">Transcribe Another Video</a>
|
| 177 |
+
</div>
|
| 178 |
+
|
| 179 |
+
<script>
|
| 180 |
function populateDropdown(id, url, defaultValue = null) {
|
| 181 |
+
fetch(url)
|
| 182 |
+
.then(response => response.text())
|
| 183 |
+
.then(data => {
|
| 184 |
+
const select = document.getElementById(id);
|
| 185 |
+
select.innerHTML = '';
|
| 186 |
+
const lines = data.split('\n').map(x => x.trim()).filter(Boolean);
|
| 187 |
+
lines.forEach(item => {
|
| 188 |
+
const opt = document.createElement('option');
|
| 189 |
+
opt.value = item;
|
| 190 |
+
opt.textContent = item;
|
| 191 |
+
if (item === defaultValue) opt.selected = true;
|
| 192 |
+
select.appendChild(opt);
|
| 193 |
+
});
|
| 194 |
+
})
|
| 195 |
+
.catch(error => console.error(`Error loading ${url}:`, error));
|
| 196 |
+
}
|
| 197 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
function toggleTranscriptionFields() {
|
| 199 |
+
const isHighlight = document.getElementById('mode_highlight').checked;
|
| 200 |
+
document.getElementById('normal_input').style.display = isHighlight ? 'none' : 'block';
|
| 201 |
+
document.getElementById('highlight_input').style.display = isHighlight ? 'block' : 'none';
|
| 202 |
}
|
| 203 |
+
|
| 204 |
+
// Safely pretty print transcription_json if available
|
| 205 |
+
window.addEventListener("DOMContentLoaded", () => {
|
| 206 |
+
const jsonText = `{{ transcription_json | tojson | safe }}`;
|
| 207 |
+
try {
|
| 208 |
+
const parsed = JSON.parse(jsonText);
|
| 209 |
+
document.getElementById("srt_json").value = JSON.stringify(parsed, null, 1);
|
| 210 |
+
} catch (e) {
|
| 211 |
+
console.warn("Invalid JSON:", e);
|
| 212 |
+
document.getElementById("srt_json").value = jsonText;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
populateDropdown('font', '/static/fonts.txt', "Helvetica");
|
| 216 |
+
populateDropdown('text_color', '/static/colors.txt', "white");
|
| 217 |
+
|
| 218 |
+
toggleTranscriptionFields(); // Set proper display state
|
| 219 |
+
});
|
| 220 |
+
</script>
|
| 221 |
</body>
|
| 222 |
</html>
|