class MeetingMinutesGenerator
A class that generates professional meeting minutes from meeting transcripts using OpenAI's GPT-4o model, with capabilities to parse metadata, extract action items, and format output.
/tf/active/vicechatdev/meeting_minutes_generator.py
20 - 137
moderate
Purpose
This class automates the process of converting raw meeting transcripts into structured, professional meeting minutes. It handles the complete workflow: loading transcript files, extracting metadata (date, speakers, duration), generating formatted minutes using GPT-4o with a specialized prompt, and saving the output. The generated minutes include executive summaries, key discussion points, action items, and next steps in clean Markdown format. Ideal for teams needing to document meetings efficiently and consistently.
Source Code
class MeetingMinutesGenerator:
def __init__(self, api_key: str):
"""Initialize the generator with OpenAI API key."""
self.client = openai.OpenAI(api_key=api_key)
def load_transcript(self, file_path: str) -> str:
"""Load transcript from file."""
try:
with open(file_path, 'r', encoding='utf-8') as file:
return file.read()
except Exception as e:
raise Exception(f"Error loading transcript: {e}")
def parse_transcript_metadata(self, transcript: str) -> Dict[str, str]:
"""Extract meeting metadata from transcript."""
# Extract date from filename or content
date_match = re.search(r'(\d{4}-\d{2}-\d{2}|\d{8})', transcript)
meeting_date = date_match.group(1) if date_match else datetime.now().strftime('%Y-%m-%d')
# Extract unique speakers
speaker_pattern = r'^([^at]+) at \d+[h:]?\d+[:\-]\d+ - \d+[h:]?\d+[:\-]\d+'
speakers = set()
for line in transcript.split('\n'):
match = re.match(speaker_pattern, line.strip())
if match:
speaker = match.group(1).strip()
if speaker not in ['Speaker 1', 'Speaker 3', 'Speaker 5', 'Speaker 7']: # Filter generic speakers
speakers.add(speaker)
return {
'date': meeting_date,
'speakers': list(speakers),
'duration': self._extract_duration(transcript)
}
def _extract_duration(self, transcript: str) -> str:
"""Extract meeting duration from transcript."""
time_pattern = r'(\d+[h:]?\d+[:\-]\d+)'
times = re.findall(time_pattern, transcript)
if len(times) >= 2:
start_time = times[0]
end_time = times[-1]
return f"{start_time} - {end_time}"
return "Duration not available"
def generate_meeting_minutes(self, transcript: str, meeting_title: str = "Development Team Meeting") -> str:
"""Generate meeting minutes using GPT-4o."""
metadata = self.parse_transcript_metadata(transcript)
prompt = f"""
You are an expert meeting secretary tasked with creating professional meeting minutes from a transcript.
Transform the following meeting transcript into well-structured meeting minutes with these sections:
1. **Meeting Information**
- Title: {meeting_title}
- Date: {metadata['date']}
- Duration: {metadata['duration']}
- Attendees: {', '.join(metadata['speakers']) if metadata['speakers'] else 'See transcript'}
2. **Executive Summary**
- Brief overview of the meeting's main purpose and outcomes
3. **Key Discussion Points**
- Main topics discussed, organized logically
- Key decisions made
- Important updates or announcements
4. **Action Items**
- Specific tasks assigned with responsible parties
- Deadlines where mentioned
- Follow-up requirements
5. **Next Steps**
- Planned future meetings or activities
- Outstanding issues to be addressed
**Important Instructions:**
- Clean up the conversational language into professional meeting language
- Group related discussions together logically
- Extract concrete action items and decisions
- Ignore off-topic conversations or technical difficulties
- Use clear, professional language
- Format everything in clean Markdown
- Be specific about who is responsible for what actions
- Include relevant technical details but make them accessible
**Transcript:**
{transcript}
Please generate comprehensive meeting minutes following the structure above.
"""
try:
response = self.client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are an expert meeting secretary who creates clear, professional meeting minutes from transcripts. Focus on extracting key decisions, action items, and important discussions while maintaining professional tone."},
{"role": "user", "content": prompt}
],
max_tokens=4000,
temperature=0.3
)
return response.choices[0].message.content
except Exception as e:
raise Exception(f"Error generating meeting minutes: {e}")
def save_minutes(self, minutes: str, output_path: str):
"""Save meeting minutes to file."""
try:
with open(output_path, 'w', encoding='utf-8') as file:
file.write(minutes)
print(f"Meeting minutes saved to: {output_path}")
except Exception as e:
raise Exception(f"Error saving meeting minutes: {e}")
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
- | - |
Parameter Details
api_key: OpenAI API key string required to authenticate with the OpenAI API. This key is used to initialize the OpenAI client for making GPT-4o API calls. Must be a valid API key with access to the gpt-4o model.
Return Value
The constructor returns an instance of MeetingMinutesGenerator with an initialized OpenAI client. Key method returns: load_transcript() returns the transcript content as a string; parse_transcript_metadata() returns a dictionary with 'date', 'speakers' (list), and 'duration' keys; generate_meeting_minutes() returns formatted meeting minutes as a Markdown string; save_minutes() returns None but writes to file.
Class Interface
Methods
__init__(self, api_key: str)
Purpose: Initialize the MeetingMinutesGenerator with an OpenAI API key and create an OpenAI client instance
Parameters:
api_key: Valid OpenAI API key string for authentication
Returns: None (constructor)
load_transcript(self, file_path: str) -> str
Purpose: Load and read a meeting transcript from a file on disk
Parameters:
file_path: Path to the transcript file (absolute or relative path)
Returns: String containing the complete transcript content from the file
parse_transcript_metadata(self, transcript: str) -> Dict[str, str]
Purpose: Extract structured metadata from the transcript including date, speakers, and duration
Parameters:
transcript: Raw transcript text as a string
Returns: Dictionary with keys 'date' (str), 'speakers' (list of str), and 'duration' (str)
_extract_duration(self, transcript: str) -> str
Purpose: Private helper method to extract meeting duration from transcript timestamps
Parameters:
transcript: Raw transcript text containing timestamps
Returns: String representing duration in format 'start_time - end_time' or 'Duration not available'
generate_meeting_minutes(self, transcript: str, meeting_title: str = 'Development Team Meeting') -> str
Purpose: Generate professional meeting minutes from transcript using GPT-4o with structured formatting
Parameters:
transcript: Raw meeting transcript text to processmeeting_title: Optional title for the meeting (defaults to 'Development Team Meeting')
Returns: Formatted meeting minutes as a Markdown string with sections for meeting info, summary, discussion points, action items, and next steps
save_minutes(self, minutes: str, output_path: str)
Purpose: Save generated meeting minutes to a file on disk
Parameters:
minutes: Formatted meeting minutes string to saveoutput_path: File path where minutes should be saved (will create or overwrite)
Returns: None (prints confirmation message to stdout)
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
client |
openai.OpenAI | OpenAI client instance used for making API calls to GPT-4o model, initialized with the provided API key | instance |
Dependencies
openairedatetimetyping
Required Imports
import os
import re
from datetime import datetime
from typing import List, Dict, Tuple
import openai
Usage Example
import openai
from datetime import datetime
from typing import Dict
import re
# Initialize the generator with API key
generator = MeetingMinutesGenerator(api_key='your-openai-api-key')
# Load transcript from file
transcript = generator.load_transcript('meeting_transcript.txt')
# Optional: Parse metadata separately
metadata = generator.parse_transcript_metadata(transcript)
print(f"Meeting date: {metadata['date']}")
print(f"Speakers: {metadata['speakers']}")
# Generate meeting minutes
minutes = generator.generate_meeting_minutes(
transcript=transcript,
meeting_title='Sprint Planning Meeting'
)
# Save the generated minutes
generator.save_minutes(minutes, 'meeting_minutes_2024-01-15.md')
# Or use the minutes string directly
print(minutes)
Best Practices
- Always provide a valid OpenAI API key during instantiation to avoid authentication errors
- Ensure transcript files are UTF-8 encoded to prevent encoding issues
- Handle exceptions from all methods as they raise Exception with descriptive messages
- The class is stateless except for the OpenAI client, so a single instance can process multiple transcripts
- Call methods in order: load_transcript() -> generate_meeting_minutes() -> save_minutes() for typical workflow
- The temperature parameter (0.3) is set for consistent, factual output; modify in code if more creative output is needed
- Monitor OpenAI API usage and costs as generate_meeting_minutes() uses up to 4000 tokens per call
- Transcript format should include speaker names and timestamps for best metadata extraction
- The speaker filtering logic excludes generic speaker labels (Speaker 1, 3, 5, 7); adjust if your transcripts use different conventions
- Consider implementing retry logic for API calls in production environments
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class MeetingMinutesGenerator_v1 92.4% similar
-
function main_v27 78.8% similar
-
function main_v14 74.3% similar
-
function generate_minutes 72.5% similar
-
function main_v2 69.2% similar