Update app.py via AI Editor
Browse files
app.py
CHANGED
@@ -13,9 +13,15 @@ from datetime import datetime
|
|
13 |
import glob
|
14 |
import threading
|
15 |
import time
|
|
|
|
|
|
|
16 |
|
17 |
-
# Initialize
|
18 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
|
|
|
19 |
|
20 |
# Initialize Dash app with Bootstrap theme for responsive design
|
21 |
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
|
@@ -65,6 +71,22 @@ app.layout = dbc.Container([
|
|
65 |
dcc.Download(id="download-audio"),
|
66 |
], width=6),
|
67 |
]),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
dcc.Store(id="recording-state", data={"is_recording": False, "audio_path": "", "transcript": ""}),
|
69 |
], fluid=True)
|
70 |
|
@@ -121,8 +143,8 @@ def transcribe_chunks(chunks):
|
|
121 |
full_transcript += f"[Time {start_time:.2f}s] {transcript}\n"
|
122 |
return full_transcript
|
123 |
|
124 |
-
# Function to generate meeting minutes using GPT-3.5 Turbo
|
125 |
-
def
|
126 |
response = openai.ChatCompletion.create(
|
127 |
model="gpt-3.5-turbo",
|
128 |
messages=[
|
@@ -132,6 +154,34 @@ def generate_minutes(transcript):
|
|
132 |
)
|
133 |
return response.choices[0].message.content
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
# Function to save text to Word document
|
136 |
def save_to_word(content, filename):
|
137 |
doc = docx.Document()
|
@@ -227,14 +277,26 @@ def download_audio(n_clicks, state):
|
|
227 |
|
228 |
@app.callback(
|
229 |
Output("transcript-preview", "children", allow_duplicate=True),
|
230 |
-
Input("minutes-btn", "n_clicks"),
|
|
|
231 |
State("recording-state", "data"),
|
232 |
prevent_initial_call=True
|
233 |
)
|
234 |
-
def generate_meeting_minutes(n_clicks, state):
|
235 |
if not state["transcript"]:
|
236 |
return state.get("transcript", "")
|
237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
state["transcript"] = minutes
|
239 |
return minutes
|
240 |
|
|
|
13 |
import glob
|
14 |
import threading
|
15 |
import time
|
16 |
+
import google.generativeai as genai
|
17 |
+
from anthropic import Anthropic
|
18 |
+
import requests # For Grok API
|
19 |
|
20 |
+
# Initialize API keys
|
21 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
22 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
23 |
+
anthropic = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
|
24 |
+
grok_api_key = os.getenv("GROK_API_KEY")
|
25 |
|
26 |
# Initialize Dash app with Bootstrap theme for responsive design
|
27 |
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
|
|
|
71 |
dcc.Download(id="download-audio"),
|
72 |
], width=6),
|
73 |
]),
|
74 |
+
dbc.Row([
|
75 |
+
dbc.Col([
|
76 |
+
html.H3("AI Model Selection"),
|
77 |
+
dcc.Dropdown(
|
78 |
+
id='model-selection',
|
79 |
+
options=[
|
80 |
+
{'label': 'OpenAI GPT-3.5', 'value': 'openai'},
|
81 |
+
{'label': 'Google Gemini', 'value': 'gemini'},
|
82 |
+
{'label': 'Anthropic Claude', 'value': 'anthropic'},
|
83 |
+
{'label': 'Grok', 'value': 'grok'}
|
84 |
+
],
|
85 |
+
value='openai',
|
86 |
+
clearable=False
|
87 |
+
),
|
88 |
+
], width=12, className="mb-4"),
|
89 |
+
]),
|
90 |
dcc.Store(id="recording-state", data={"is_recording": False, "audio_path": "", "transcript": ""}),
|
91 |
], fluid=True)
|
92 |
|
|
|
143 |
full_transcript += f"[Time {start_time:.2f}s] {transcript}\n"
|
144 |
return full_transcript
|
145 |
|
146 |
+
# Function to generate meeting minutes using OpenAI GPT-3.5 Turbo
|
147 |
+
def generate_minutes_openai(transcript):
|
148 |
response = openai.ChatCompletion.create(
|
149 |
model="gpt-3.5-turbo",
|
150 |
messages=[
|
|
|
154 |
)
|
155 |
return response.choices[0].message.content
|
156 |
|
157 |
+
# Function to generate meeting minutes using Google Gemini
|
158 |
+
def generate_minutes_gemini(transcript):
|
159 |
+
model = genai.GenerativeModel('gemini-pro')
|
160 |
+
response = model.generate_content(f"Generate detailed meeting minutes from this transcript:\n{transcript}")
|
161 |
+
return response.text
|
162 |
+
|
163 |
+
# Function to generate meeting minutes using Anthropic Claude
|
164 |
+
def generate_minutes_anthropic(transcript):
|
165 |
+
response = anthropic.completions.create(
|
166 |
+
model="claude-2",
|
167 |
+
prompt=f"Human: Generate detailed meeting minutes from this transcript:\n{transcript}\n\nAssistant:",
|
168 |
+
max_tokens_to_sample=2000
|
169 |
+
)
|
170 |
+
return response.completion
|
171 |
+
|
172 |
+
# Function to generate meeting minutes using Grok
|
173 |
+
def generate_minutes_grok(transcript):
|
174 |
+
headers = {
|
175 |
+
"Authorization": f"Bearer {grok_api_key}",
|
176 |
+
"Content-Type": "application/json"
|
177 |
+
}
|
178 |
+
data = {
|
179 |
+
"prompt": f"Generate detailed meeting minutes from this transcript:\n{transcript}",
|
180 |
+
"max_tokens": 2000
|
181 |
+
}
|
182 |
+
response = requests.post("https://api.grok.ai/v1/completions", headers=headers, json=data)
|
183 |
+
return response.json()["choices"][0]["text"]
|
184 |
+
|
185 |
# Function to save text to Word document
|
186 |
def save_to_word(content, filename):
|
187 |
doc = docx.Document()
|
|
|
277 |
|
278 |
@app.callback(
|
279 |
Output("transcript-preview", "children", allow_duplicate=True),
|
280 |
+
[Input("minutes-btn", "n_clicks"),
|
281 |
+
Input("model-selection", "value")],
|
282 |
State("recording-state", "data"),
|
283 |
prevent_initial_call=True
|
284 |
)
|
285 |
+
def generate_meeting_minutes(n_clicks, model, state):
|
286 |
if not state["transcript"]:
|
287 |
return state.get("transcript", "")
|
288 |
+
|
289 |
+
if model == 'openai':
|
290 |
+
minutes = generate_minutes_openai(state["transcript"])
|
291 |
+
elif model == 'gemini':
|
292 |
+
minutes = generate_minutes_gemini(state["transcript"])
|
293 |
+
elif model == 'anthropic':
|
294 |
+
minutes = generate_minutes_anthropic(state["transcript"])
|
295 |
+
elif model == 'grok':
|
296 |
+
minutes = generate_minutes_grok(state["transcript"])
|
297 |
+
else:
|
298 |
+
minutes = "Error: Invalid model selection"
|
299 |
+
|
300 |
state["transcript"] = minutes
|
301 |
return minutes
|
302 |
|