Update app.py
Browse files
app.py
CHANGED
|
@@ -64,7 +64,7 @@ app.layout = dbc.Container([
|
|
| 64 |
),
|
| 65 |
html.Div(id='output-media-upload'),
|
| 66 |
dbc.Input(id="url-input", type="text", placeholder="Enter audio/video URL (including YouTube)", className="mb-3"),
|
| 67 |
-
dbc.Button("Process
|
| 68 |
dbc.Spinner(html.Div(id='transcription-status'), color="primary", type="grow"),
|
| 69 |
html.H4("Diarized Transcription Preview", className="mt-4"),
|
| 70 |
html.Div(id='transcription-preview', style={'whiteSpace': 'pre-wrap'}),
|
|
@@ -161,18 +161,20 @@ def update_output(contents, n_clicks, filename, url):
|
|
| 161 |
|
| 162 |
trigger_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
| 163 |
|
| 164 |
-
if
|
|
|
|
| 165 |
content_type, content_string = contents.split(',')
|
| 166 |
decoded = base64.b64decode(content_string)
|
| 167 |
status_message, success = process_media(decoded)
|
| 168 |
-
elif
|
|
|
|
| 169 |
status_message, success = process_media(url, is_url=True)
|
| 170 |
else:
|
| 171 |
return "No file uploaded or URL processed.", "", "", True
|
| 172 |
|
| 173 |
if success:
|
| 174 |
preview = transcription_text[:1000] + "..." if len(transcription_text) > 1000 else transcription_text
|
| 175 |
-
return f"
|
| 176 |
else:
|
| 177 |
return "Processing failed.", status_message, "", True
|
| 178 |
|
|
|
|
| 64 |
),
|
| 65 |
html.Div(id='output-media-upload'),
|
| 66 |
dbc.Input(id="url-input", type="text", placeholder="Enter audio/video URL (including YouTube)", className="mb-3"),
|
| 67 |
+
dbc.Button("Process Media", id="process-url-button", color="primary", className="mb-3"),
|
| 68 |
dbc.Spinner(html.Div(id='transcription-status'), color="primary", type="grow"),
|
| 69 |
html.H4("Diarized Transcription Preview", className="mt-4"),
|
| 70 |
html.Div(id='transcription-preview', style={'whiteSpace': 'pre-wrap'}),
|
|
|
|
| 161 |
|
| 162 |
trigger_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
| 163 |
|
| 164 |
+
if contents is not None:
|
| 165 |
+
# Process file upload
|
| 166 |
content_type, content_string = contents.split(',')
|
| 167 |
decoded = base64.b64decode(content_string)
|
| 168 |
status_message, success = process_media(decoded)
|
| 169 |
+
elif url:
|
| 170 |
+
# Process URL
|
| 171 |
status_message, success = process_media(url, is_url=True)
|
| 172 |
else:
|
| 173 |
return "No file uploaded or URL processed.", "", "", True
|
| 174 |
|
| 175 |
if success:
|
| 176 |
preview = transcription_text[:1000] + "..." if len(transcription_text) > 1000 else transcription_text
|
| 177 |
+
return f"Media processed successfully.", status_message, preview, False
|
| 178 |
else:
|
| 179 |
return "Processing failed.", status_message, "", True
|
| 180 |
|