Update app.py
Browse files
app.py
CHANGED
@@ -76,7 +76,9 @@ app.layout = dbc.Container([
|
|
76 |
dbc.Button("Summarize Transcript", id="btn-summarize", color="secondary", className="mt-3 me-2", disabled=True),
|
77 |
dbc.Button("Generate Meeting Minutes", id="btn-minutes", color="info", className="mt-3", disabled=True),
|
78 |
dcc.Download(id="download-transcription"),
|
|
|
79 |
html.Div(id='summary-output', className="mt-4"),
|
|
|
80 |
html.Div(id='minutes-output', className="mt-4")
|
81 |
])
|
82 |
])
|
@@ -248,14 +250,15 @@ def process_media(file_path, is_url=False):
|
|
248 |
os.unlink(wav_path)
|
249 |
|
250 |
@app.callback(
|
251 |
-
Output('summary-
|
|
|
252 |
Input('btn-summarize', 'n_clicks'),
|
253 |
State('transcription-preview', 'children'),
|
254 |
prevent_initial_call=True
|
255 |
)
|
256 |
def summarize_transcript(n_clicks, transcript):
|
257 |
if n_clicks is None or not transcript:
|
258 |
-
return ""
|
259 |
|
260 |
summary_prompt = f"""
|
261 |
Please provide a concise summary of the following transcript. Include the main topics discussed and key points. Format it for readability:
|
@@ -275,23 +278,24 @@ def summarize_transcript(n_clicks, transcript):
|
|
275 |
)
|
276 |
|
277 |
summary = summary_response['choices'][0]['message']['content']
|
278 |
-
return dbc.Card(dbc.CardBody([
|
279 |
html.H5("Transcript Summary", className="card-title"),
|
280 |
html.P(summary, className="card-text")
|
281 |
]))
|
282 |
except Exception as e:
|
283 |
logger.error(f"Error generating summary: {str(e)}")
|
284 |
-
return html.Div(f"An error occurred while generating the summary: {str(e)}", className="text-danger")
|
285 |
|
286 |
@app.callback(
|
287 |
-
Output('minutes-
|
|
|
288 |
Input('btn-minutes', 'n_clicks'),
|
289 |
State('transcription-preview', 'children'),
|
290 |
prevent_initial_call=True
|
291 |
)
|
292 |
def generate_meeting_minutes(n_clicks, transcript):
|
293 |
if n_clicks is None or not transcript:
|
294 |
-
return ""
|
295 |
|
296 |
minutes_prompt = f"""
|
297 |
Please transform the following transcript into structured meeting minutes. Include the following sections:
|
@@ -319,13 +323,13 @@ def generate_meeting_minutes(n_clicks, transcript):
|
|
319 |
)
|
320 |
|
321 |
minutes = minutes_response['choices'][0]['message']['content']
|
322 |
-
return dbc.Card(dbc.CardBody([
|
323 |
html.H5("Meeting Minutes", className="card-title"),
|
324 |
dcc.Markdown(minutes, className="card-text")
|
325 |
]))
|
326 |
except Exception as e:
|
327 |
logger.error(f"Error generating meeting minutes: {str(e)}")
|
328 |
-
return html.Div(f"An error occurred while generating meeting minutes: {str(e)}", className="text-danger")
|
329 |
|
330 |
@app.callback(
|
331 |
[Output('output-media-upload', 'children'),
|
@@ -359,7 +363,7 @@ def update_output(contents, n_clicks, filename, url):
|
|
359 |
return f"Media processed successfully.", status_message, preview, False, False, False
|
360 |
else:
|
361 |
return "Processing failed.", status_message, transcription_preview, True, True, True
|
362 |
-
|
363 |
@app.callback(
|
364 |
Output("download-transcription", "data"),
|
365 |
Input("btn-download", "n_clicks"),
|
|
|
76 |
dbc.Button("Summarize Transcript", id="btn-summarize", color="secondary", className="mt-3 me-2", disabled=True),
|
77 |
dbc.Button("Generate Meeting Minutes", id="btn-minutes", color="info", className="mt-3", disabled=True),
|
78 |
dcc.Download(id="download-transcription"),
|
79 |
+
dbc.Spinner(html.Div(id='summary-status'), color="secondary", type="grow"),
|
80 |
html.Div(id='summary-output', className="mt-4"),
|
81 |
+
dbc.Spinner(html.Div(id='minutes-status'), color="info", type="grow"),
|
82 |
html.Div(id='minutes-output', className="mt-4")
|
83 |
])
|
84 |
])
|
|
|
250 |
os.unlink(wav_path)
|
251 |
|
252 |
@app.callback(
|
253 |
+
[Output('summary-status', 'children'),
|
254 |
+
Output('summary-output', 'children')],
|
255 |
Input('btn-summarize', 'n_clicks'),
|
256 |
State('transcription-preview', 'children'),
|
257 |
prevent_initial_call=True
|
258 |
)
|
259 |
def summarize_transcript(n_clicks, transcript):
|
260 |
if n_clicks is None or not transcript:
|
261 |
+
return "", ""
|
262 |
|
263 |
summary_prompt = f"""
|
264 |
Please provide a concise summary of the following transcript. Include the main topics discussed and key points. Format it for readability:
|
|
|
278 |
)
|
279 |
|
280 |
summary = summary_response['choices'][0]['message']['content']
|
281 |
+
return "", dbc.Card(dbc.CardBody([
|
282 |
html.H5("Transcript Summary", className="card-title"),
|
283 |
html.P(summary, className="card-text")
|
284 |
]))
|
285 |
except Exception as e:
|
286 |
logger.error(f"Error generating summary: {str(e)}")
|
287 |
+
return "", html.Div(f"An error occurred while generating the summary: {str(e)}", className="text-danger")
|
288 |
|
289 |
@app.callback(
|
290 |
+
[Output('minutes-status', 'children'),
|
291 |
+
Output('minutes-output', 'children')],
|
292 |
Input('btn-minutes', 'n_clicks'),
|
293 |
State('transcription-preview', 'children'),
|
294 |
prevent_initial_call=True
|
295 |
)
|
296 |
def generate_meeting_minutes(n_clicks, transcript):
|
297 |
if n_clicks is None or not transcript:
|
298 |
+
return "", ""
|
299 |
|
300 |
minutes_prompt = f"""
|
301 |
Please transform the following transcript into structured meeting minutes. Include the following sections:
|
|
|
323 |
)
|
324 |
|
325 |
minutes = minutes_response['choices'][0]['message']['content']
|
326 |
+
return "", dbc.Card(dbc.CardBody([
|
327 |
html.H5("Meeting Minutes", className="card-title"),
|
328 |
dcc.Markdown(minutes, className="card-text")
|
329 |
]))
|
330 |
except Exception as e:
|
331 |
logger.error(f"Error generating meeting minutes: {str(e)}")
|
332 |
+
return "", html.Div(f"An error occurred while generating meeting minutes: {str(e)}", className="text-danger")
|
333 |
|
334 |
@app.callback(
|
335 |
[Output('output-media-upload', 'children'),
|
|
|
363 |
return f"Media processed successfully.", status_message, preview, False, False, False
|
364 |
else:
|
365 |
return "Processing failed.", status_message, transcription_preview, True, True, True
|
366 |
+
|
367 |
@app.callback(
|
368 |
Output("download-transcription", "data"),
|
369 |
Input("btn-download", "n_clicks"),
|