Update app.py
Browse files
app.py
CHANGED
|
@@ -77,9 +77,7 @@ app.layout = dbc.Container([
|
|
| 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 |
])
|
| 85 |
], fluid=True)
|
|
@@ -256,12 +254,19 @@ def process_media(file_path, is_url=False):
|
|
| 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
|
| 265 |
|
| 266 |
{transcript}
|
| 267 |
|
|
@@ -278,13 +283,10 @@ def summarize_transcript(n_clicks, transcript):
|
|
| 278 |
)
|
| 279 |
|
| 280 |
summary = summary_response['choices'][0]['message']['content']
|
| 281 |
-
return "",
|
| 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
|
| 288 |
|
| 289 |
@app.callback(
|
| 290 |
[Output('minutes-status', 'children'),
|
|
@@ -293,9 +295,17 @@ def summarize_transcript(n_clicks, transcript):
|
|
| 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,13 +333,10 @@ def generate_meeting_minutes(n_clicks, transcript):
|
|
| 323 |
)
|
| 324 |
|
| 325 |
minutes = minutes_response['choices'][0]['message']['content']
|
| 326 |
-
return "",
|
| 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
|
| 333 |
|
| 334 |
@app.callback(
|
| 335 |
[Output('output-media-upload', 'children'),
|
|
|
|
| 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 |
dbc.Spinner(html.Div(id='minutes-status'), color="info", type="grow"),
|
|
|
|
| 81 |
])
|
| 82 |
])
|
| 83 |
], fluid=True)
|
|
|
|
| 254 |
State('transcription-preview', 'children'),
|
| 255 |
prevent_initial_call=True
|
| 256 |
)
|
| 257 |
+
@app.callback(
|
| 258 |
+
[Output('summary-status', 'children'),
|
| 259 |
+
Output('download-transcription', 'data')],
|
| 260 |
+
Input('btn-summarize', 'n_clicks'),
|
| 261 |
+
State('transcription-preview', 'children'),
|
| 262 |
+
prevent_initial_call=True
|
| 263 |
+
)
|
| 264 |
def summarize_transcript(n_clicks, transcript):
|
| 265 |
if n_clicks is None or not transcript:
|
| 266 |
+
return "", None
|
| 267 |
|
| 268 |
summary_prompt = f"""
|
| 269 |
+
Please provide a detailed summary of the following transcript. Include the main topics discussed and key points. Format it for readability:
|
| 270 |
|
| 271 |
{transcript}
|
| 272 |
|
|
|
|
| 283 |
)
|
| 284 |
|
| 285 |
summary = summary_response['choices'][0]['message']['content']
|
| 286 |
+
return "", dcc.send_string(summary, "transcript_summary.txt")
|
|
|
|
|
|
|
|
|
|
| 287 |
except Exception as e:
|
| 288 |
logger.error(f"Error generating summary: {str(e)}")
|
| 289 |
+
return f"An error occurred while generating the summary: {str(e)}", None
|
| 290 |
|
| 291 |
@app.callback(
|
| 292 |
[Output('minutes-status', 'children'),
|
|
|
|
| 295 |
State('transcription-preview', 'children'),
|
| 296 |
prevent_initial_call=True
|
| 297 |
)
|
| 298 |
+
|
| 299 |
+
@app.callback(
|
| 300 |
+
[Output('minutes-status', 'children'),
|
| 301 |
+
Output('download-transcription', 'data', allow_duplicate=True)],
|
| 302 |
+
Input('btn-minutes', 'n_clicks'),
|
| 303 |
+
State('transcription-preview', 'children'),
|
| 304 |
+
prevent_initial_call=True
|
| 305 |
+
)
|
| 306 |
def generate_meeting_minutes(n_clicks, transcript):
|
| 307 |
if n_clicks is None or not transcript:
|
| 308 |
+
return "", None
|
| 309 |
|
| 310 |
minutes_prompt = f"""
|
| 311 |
Please transform the following transcript into structured meeting minutes. Include the following sections:
|
|
|
|
| 333 |
)
|
| 334 |
|
| 335 |
minutes = minutes_response['choices'][0]['message']['content']
|
| 336 |
+
return "", dcc.send_string(minutes, "meeting_minutes.txt")
|
|
|
|
|
|
|
|
|
|
| 337 |
except Exception as e:
|
| 338 |
logger.error(f"Error generating meeting minutes: {str(e)}")
|
| 339 |
+
return f"An error occurred while generating meeting minutes: {str(e)}", None
|
| 340 |
|
| 341 |
@app.callback(
|
| 342 |
[Output('output-media-upload', 'children'),
|