OpenAI手把手官方教学:如何用GPT-4创建会议纪要生成AI
大型语言模型 GPT-4 发布已经有些时日了,基于其开发的应用也层出不穷,不断涌现。这些应用的强大能力已经为许多用户的大量任务场景提供了助力。这里我们要分享的是 OpenAI 的一份官方文档,其中详细介绍了使用其语音识别模型 Whisper 和大型语言模型 GPT-4 创建会议纪要生成器的全流程。
python -m venv env
source env/bin/activate
pip install openai
pip install python-docx
import openai
from docx import Document
def transcribe_audio(audio_file_path):
with open(audio_file_path, 'rb') as audio_file:
transcription = openai.Audio.transcribe("whisper-1", audio_file)
return transcription['text']
def meeting_minutes(transcription):
abstract_summary = abstract_summary_extraction(transcription)
key_points = key_points_extraction(transcription)
action_items = action_item_extraction(transcription)
sentiment = sentiment_analysis(transcription)
return {
'abstract_summary': abstract_summary,
'key_points': key_points,
'action_items': action_items,
'sentiment': sentiment
}
def abstract_summary_extraction(transcription):
response = openai.ChatCompletion.create(
model="gpt-4",
temperature=0,
messages=[
{
"role": "system",
"content": "You are a highly skilled AI trained in language comprehension and summarization. I would like you to read the following text and summarize it into a concise abstract paragraph. Aim to retain the most important points, providing a coherent and readable summary that could help a person understand the main points of the discussion without needing to read the entire text. Please avoid unnecessary details or tangential points."
},
{
"role": "user",
"content": transcription
}
]
)
return response['choices'][0]['message']['content']
def key_points_extraction(transcription):
response = openai.ChatCompletion.create(
model="gpt-4",
temperature=0,
messages=[
{
"role": "system",
"content": "You are a proficient AI with a specialty in distilling information into key points. Based on the following text, identify and list the main points that were discussed or brought up. These should be the most important ideas, findings, or topics that are crucial to the essence of the discussion. Your goal is to provide a list that someone could read to quickly understand what was talked about."
},
{
"role": "user",
"content": transcription
}
]
)
return response['choices'][0]['message']['content']
def action_item_extraction(transcription):
response = openai.ChatCompletion.create(
model="gpt-4",
temperature=0,
messages=[
{
"role": "system",
"content": "You are an AI expert in analyzing conversations and extracting action items. Please review the text and identify any tasks, assignments, or actions that were agreed upon or mentioned as needing to be done. These could be tasks assigned to specific individuals, or general actions that the group has decided to take. Please list these action items clearly and concisely."
},
{
"role": "user",
"content": transcription
}
]
)
return response['choices'][0]['message']['content']
def sentiment_analysis(transcription):
response = openai.ChatCompletion.create(
model="gpt-4",
temperature=0,
messages=[
{
"role": "system",
"content": "As an AI with expertise in language and emotion analysis, your task is to analyze the sentiment of the following text. Please consider the overall tone of the discussion, the emotion conveyed by the language used, and the context in which words and phrases are used. Indicate whether the sentiment is generally positive, negative, or neutral, and provide brief explanations for your analysis where possible."
},
{
"role": "user",
"content": transcription
}
]
)
return response['choices'][0]['message']['content']
def save_as_docx(minutes, filename):
doc = Document()
for key, value in minutes.items():
heading = ' '.join(word.capitalize() for word in key.split('_'))
doc.add_heading(heading, level=1)
doc.add_paragraph(value)
doc.add_paragraph()
doc.save(filename)
audio_file_path = "Earningscall.wav"
transcription = transcribe_audio(audio_file_path)
minutes = meeting_minutes(transcription)
print(minutes)
save_as_docx(minutes, 'meeting_minutes.docx')
© THE END
转载请联系本公众号获得授权
投稿或寻求报道:[email protected]
微信扫码关注该文公众号作者
戳这里提交新闻线索和高质量文章给我们。
来源: qq
点击查看作者最近其他文章