OpenAI 会议纪要生成教程

2026-11-10 11:01 更新

本教程将构建一个自动生成会议纪要的应用:转录会议录音、总结讨论内容、提取要点和行动项、分析情绪倾向,最后将结果保存为 Word 文档。

开始使用

本教程假定你熟悉下面支持的一种编程语言,并已准备好 OpenAI API 密钥。你可以使用用于快速验证流程的简短音频样本,或不超过 25 MB 的自有录音。

安装 OpenAI SDK,以及适合所用语言的 DOCX 库:

转录音频

DALL·E 生成的音频波形图

第一步,将会议录音发送给 /v1/audio API。文件转录模型会将口语转换为文本。开始时可以省略可选的 prompt 和 temperature 参数,使用其默认值。

下载示例音频。

将下载的文件保存为运行示例所在目录下的 meeting.wav,或将示例中的 meeting.wav 替换为自有录音路径。简短样本用于验证流程;若要生成有用的摘要和行动项,应使用不超过 25 MB 的真实会议录音。

先定义辅助函数,打开录音文件,并将内容发送给 gpt-transcribe:

来源示例 1(javascript):

// [中文] 打开本地音频文件并上传内容,由gpt-transcribe返回转录文本;同一语言的片段需按顺序组合。
import fs from "node:fs";

import { Document, HeadingLevel, Packer, Paragraph, TextRun } from "docx";
import OpenAI from "openai";

const openai = new OpenAI();

async function transcribeAudio(audioFilePath) {
  const transcription = await openai.audio.transcriptions.create({
    file: fs.createReadStream(audioFilePath),
    model: "gpt-transcribe",
  });
  return transcription.text;
}

来源示例 2(python):

## [中文] 打开本地音频文件并上传内容,由gpt-transcribe返回转录文本;同一语言的片段需按顺序组合。
from pathlib import Path

from docx import Document
from openai import OpenAI

client = OpenAI()


def transcribe_audio(audio_file_path: str | Path) -> str:
    with Path(audio_file_path).open("rb") as audio_file:
        transcription = client.audio.transcriptions.create(
            file=audio_file,
            model="gpt-transcribe",
        )
    return transcription.text

来源示例 3(go):

// [中文] 打开本地音频文件并上传内容,由gpt-transcribe返回转录文本;同一语言的片段需按顺序组合。
package main

import (
    "context"
    "fmt"
    "os"
    "strings"

    "github.com/gomutex/godocx"
    "github.com/openai/openai-go/v3"
)

type meetingMinutes struct {
    AbstractSummary string
    KeyPoints       string
    ActionItems     string
    Sentiment       string
}

var client = openai.NewClient()

func transcribeAudio(ctx context.Context, audioFilePath string) (string, error) {
    audioFile, err := os.Open(audioFilePath)
    if err != nil {
        return "", err
    }
    defer audioFile.Close()

    transcription, err := client.Audio.Transcriptions.New(ctx, openai.AudioTranscriptionNewParams{
        File:  audioFile,
        Model: "gpt-transcribe",
    })
    if err != nil {
        return "", err
    }
    return transcription.Text, nil
}

来源示例 4(java):

// [中文] 打开本地音频文件并上传内容,由gpt-transcribe返回转录文本;同一语言的片段需按顺序组合。
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.audio.transcriptions.TranscriptionCreateParams;
import com.openai.models.chat.completions.ChatCompletionCreateParams;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFStyle;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType;

public final class TutorialMeetingMinutesExample {
  private TutorialMeetingMinutesExample() {}

  record MeetingMinutes(
      String abstractSummary, String keyPoints, String actionItems, String sentiment) {}

  private static final class ClientHolder {
    private static final OpenAIClient INSTANCE = OpenAIOkHttpClient.fromEnv();
  }

  private static OpenAIClient client() {
    return ClientHolder.INSTANCE;
  }

  static String transcribeAudio(Path audioFilePath) {
    var transcription =
        client()
            .audio()
            .transcriptions()
            .create(
                TranscriptionCreateParams.builder()
                    .file(audioFilePath)
                    .model("gpt-transcribe")
                    .build());
    return transcription.asTranscription().text();
  }

来源示例 5(ruby):

## [中文] 打开本地音频文件并上传内容,由gpt-transcribe返回转录文本;同一语言的片段需按顺序组合。
require "caracal"
require "openai"
require "pathname"

client = OpenAI::Client.new

def transcribe_audio(client, audio_file_path)
  transcription = client.audio.transcriptions.create(
    file: Pathname(audio_file_path),
    model: "gpt-transcribe"
  )
  transcription.text
end

该函数接收本地音频路径,通过所用语言的标准文件接口打开文件,再把文件内容交给转录模型。转录端点需要音频字节,而不是本地路径字符串或远程 URL。如果服务器把录音存放在其他位置,需要先下载录音,或把录音内容以流的形式放入请求,再创建转录。

使用 GPT 模型总结和分析转录文本

通过 Chat Completions API 将转录文本交给 GPT 模型。本教程演示仍受支持、适用于既有集成的 Chat Completions 路径。新项目可使用 Responses API,并从 gpt-6-astra 开始。下方示例按原文使用经过其测试的模型,完成摘要、要点提取、行动项提取和情绪分析;此处保留原模型标识,不代表已经在你的账户上实测。

本教程为每个任务分别调用一次模型。也可以把多项指令合并到一个请求中,以减少调用次数;不过,分开使用提示词更容易分别调整各项结果。

定义一个共用辅助函数,将转录文本和具体任务的指令发送给模型:

来源示例 6(javascript):

// [中文] 将任务指令放入system消息、转录文本放入user消息,调用Chat Completions并读取文本;保留来源模型gpt-5.5。
async function complete(transcription, instructions) {
  const response = await openai.chat.completions.create({
    model: "gpt-5.5",
    messages: [
      { role: "system", content: instructions },
      { role: "user", content: transcription },
    ],
  });
  return response.choices[0].message.content ?? "";
}

来源示例 7(python):

## [中文] 将任务指令放入system消息、转录文本放入user消息,调用Chat Completions并读取文本;保留来源模型gpt-5.5。
def complete(transcription: str, instructions: str) -> str:
    response = client.chat.completions.create(
        model="gpt-5.5",
        messages=[
            {"role": "system", "content": instructions},
            {"role": "user", "content": transcription},
        ],
    )
    return response.choices[0].message.content or ""

来源示例 8(go):

// [中文] 将任务指令放入system消息、转录文本放入user消息,调用Chat Completions并读取文本;保留来源模型gpt-5.5。
func complete(ctx context.Context, transcription, instructions string) (string, error) {
    response, err := client.Chat.Completions.New(ctx, openai.ChatCompletionNewParams{
        Model: "gpt-5.5",
        Messages: []openai.ChatCompletionMessageParamUnion{
            openai.SystemMessage(instructions),
            openai.UserMessage(transcription),
        },
    })
    if err != nil {
        return "", err
    }
    return response.Choices[0].Message.Content, nil
}

来源示例 9(java):

// [中文] 将任务指令放入system消息、转录文本放入user消息,调用Chat Completions并读取文本;保留来源模型gpt-5.5。
private static String complete(String transcription, String instructions) {
  var response =
      client()
          .chat()
          .completions()
          .create(
              ChatCompletionCreateParams.builder()
                  .model("gpt-5.5")
                  .addSystemMessage(instructions)
                  .addUserMessage(transcription)
                  .build());
  return response.choices().get(0).message().content().orElse("");
}

来源示例 10(ruby):

## [中文] 将任务指令放入system消息、转录文本放入user消息,调用Chat Completions并读取文本;保留来源模型gpt-5.5。
def complete(client, transcription, instructions)
  response = client.chat.completions.create(
    model: "gpt-5.5",
    messages: [
      {
        role: :system,
        content: instructions
      },
      {
        role: :user,
        content: transcription
      }
    ]
  )
  response.choices.first.message.content || ""
end

再定义编排函数,返回会议纪要的四个部分:

来源示例 11(javascript):

代码内文字译释:输出栏目名:Abstract summary=摘要,Key points=要点,Action items=行动项,Sentiment=情绪倾向。

// [中文] 依次调用摘要、要点、行动项和情绪分析四个函数,组装会议纪要;各函数在后续片段定义。
async function buildMeetingMinutes(transcription) {
  return {
    "Abstract summary": await extractAbstractSummary(transcription),
    "Key points": await extractKeyPoints(transcription),
    "Action items": await extractActionItems(transcription),
    Sentiment: await analyzeSentiment(transcription),
  };
}

来源示例 12(python):

代码内文字译释:输出栏目名:Abstract summary=摘要,Key points=要点,Action items=行动项,Sentiment=情绪倾向。

## [中文] 依次调用摘要、要点、行动项和情绪分析四个函数,组装会议纪要;各函数在后续片段定义。
def meeting_minutes(transcription: str) -> dict[str, str]:
    return {
        "Abstract summary": abstract_summary_extraction(transcription),
        "Key points": key_points_extraction(transcription),
        "Action items": action_item_extraction(transcription),
        "Sentiment": sentiment_analysis(transcription),
    }

来源示例 13(go):

代码内文字译释:输出栏目名:Abstract summary=摘要,Key points=要点,Action items=行动项,Sentiment=情绪倾向。

// [中文] 依次调用摘要、要点、行动项和情绪分析四个函数,组装会议纪要;各函数在后续片段定义。
func buildMeetingMinutes(ctx context.Context, transcription string) (meetingMinutes, error) {
    summary, err := extractAbstractSummary(ctx, transcription)
    if err != nil {
        return meetingMinutes{}, err
    }
    keyPoints, err := extractKeyPoints(ctx, transcription)
    if err != nil {
        return meetingMinutes{}, err
    }
    actionItems, err := extractActionItems(ctx, transcription)
    if err != nil {
        return meetingMinutes{}, err
    }
    sentiment, err := analyzeSentiment(ctx, transcription)
    if err != nil {
        return meetingMinutes{}, err
    }
    return meetingMinutes{summary, keyPoints, actionItems, sentiment}, nil
}

来源示例 14(java):

代码内文字译释:输出栏目名:Abstract summary=摘要,Key points=要点,Action items=行动项,Sentiment=情绪倾向。

// [中文] 依次调用摘要、要点、行动项和情绪分析四个函数,组装会议纪要;各函数在后续片段定义。
static MeetingMinutes buildMeetingMinutes(String transcription) {
  return new MeetingMinutes(
      extractAbstractSummary(transcription),
      extractKeyPoints(transcription),
      extractActionItems(transcription),
      analyzeSentiment(transcription));
}

来源示例 15(ruby):

代码内文字译释:输出栏目名:Abstract summary=摘要,Key points=要点,Action items=行动项,Sentiment=情绪倾向。

## [中文] 依次调用摘要、要点、行动项和情绪分析四个函数,组装会议纪要;各函数在后续片段定义。
def build_meeting_minutes(client, transcription)
  {
    "Abstract summary" => extract_abstract_summary(client, transcription),
    "Key points" => extract_key_points(client, transcription),
    "Action items" => extract_action_items(client, transcription),
    "Sentiment" => analyze_sentiment(client, transcription)
  }
end

该函数把转录文本分别交给四个专门的辅助函数,用于生成摘要、提取要点、提取行动项和分析情绪。若应用需要更多分析,可以再增加辅助函数及对应输出部分。

下面分别介绍这些函数的工作方式。

提取摘要

摘要函数要求模型用一个简洁段落概括会议,保留重要决策及背景,省略偏离主题的讨论。系统消息控制这种行为。更多调整输出的方法见提示词工程指南。

来源示例 16(javascript):

代码内文字译释:用一个简洁段落总结会议转录文本。保留最重要的决策及背景,省略偏离主题的内容。

// [中文] 请求模型将转录文本压缩为一段摘要,保留重要决策与背景,省略偏题内容。
async function extractAbstractSummary(transcription) {
  return complete(
    transcription,
    "Summarize the meeting transcript in one concise paragraph. Keep the most important decisions and context, and omit tangents."
  );
}

来源示例 17(python):

代码内文字译释:用一个简洁段落总结会议转录文本。保留最重要的决策及背景,省略偏离主题的内容。

## [中文] 请求模型将转录文本压缩为一段摘要,保留重要决策与背景,省略偏题内容。
def abstract_summary_extraction(transcription: str) -> str:
    return complete(
        transcription,
        "Summarize the meeting transcript in one concise paragraph. "
        "Keep the most important decisions and context, and omit tangents.",
    )

来源示例 18(go):

代码内文字译释:用一个简洁段落总结会议转录文本。保留最重要的决策及背景,省略偏离主题的内容。

// [中文] 请求模型将转录文本压缩为一段摘要,保留重要决策与背景,省略偏题内容。
func extractAbstractSummary(ctx context.Context, transcription string) (string, error) {
    return complete(ctx, transcription, "Summarize the meeting transcript in one concise paragraph. Keep the most important decisions and context, and omit tangents.")
}

来源示例 19(java):

代码内文字译释:用一个简洁段落总结会议转录文本。保留最重要的决策及背景,省略偏离主题的内容。

// [中文] 请求模型将转录文本压缩为一段摘要,保留重要决策与背景,省略偏题内容。
static String extractAbstractSummary(String transcription) {
  return complete(
      transcription,
      "Summarize the meeting transcript in one concise paragraph. "
          + "Keep the most important decisions and context, and omit tangents.");
}

来源示例 20(ruby):

代码内文字译释:用一个简洁段落总结会议转录文本。保留最重要的决策及背景,省略偏离主题的内容。

## [中文] 请求模型将转录文本压缩为一段摘要,保留重要决策与背景,省略偏题内容。
def extract_abstract_summary(client, transcription)
  complete(
    client,
    transcription,
    "Summarize the meeting transcript in one concise paragraph. Keep the most important decisions and context, and omit tangents."
  )
end

提取要点

要点函数列出会议讨论中的重要想法、发现和主题。如果项目或公司背景有助于模型判断哪些信息对读者最重要,可以将这些背景加入系统消息。

来源示例 21(javascript):

代码内文字译释:列出会议中最重要的想法、发现和主题。使用简洁的项目符号列表。

// [中文] 请求模型用简明项目符号列出会议的重要想法、发现和讨论主题。
async function extractKeyPoints(transcription) {
  return complete(
    transcription,
    "List the most important ideas, findings, and topics from the meeting. Use concise bullet points."
  );
}

来源示例 22(python):

代码内文字译释:列出会议中最重要的想法、发现和主题。使用简洁的项目符号列表。

## [中文] 请求模型用简明项目符号列出会议的重要想法、发现和讨论主题。
def key_points_extraction(transcription: str) -> str:
    return complete(
        transcription,
        "List the most important ideas, findings, and topics from the meeting. "
        "Use concise bullet points.",
    )

来源示例 23(go):

代码内文字译释:列出会议中最重要的想法、发现和主题。使用简洁的项目符号列表。

// [中文] 请求模型用简明项目符号列出会议的重要想法、发现和讨论主题。
func extractKeyPoints(ctx context.Context, transcription string) (string, error) {
    return complete(ctx, transcription, "List the most important ideas, findings, and topics from the meeting. Use concise bullet points.")
}

来源示例 24(java):

代码内文字译释:列出会议中最重要的想法、发现和主题。使用简洁的项目符号列表。

// [中文] 请求模型用简明项目符号列出会议的重要想法、发现和讨论主题。
static String extractKeyPoints(String transcription) {
  return complete(
      transcription,
      "List the most important ideas, findings, and topics from the meeting. "
          + "Use concise bullet points.");
}

来源示例 25(ruby):

代码内文字译释:列出会议中最重要的想法、发现和主题。使用简洁的项目符号列表。

## [中文] 请求模型用简明项目符号列出会议的重要想法、发现和讨论主题。
def extract_key_points(client, transcription)
  complete(
    client,
    transcription,
    "List the most important ideas, findings, and topics from the meeting. Use concise bullet points."
  )
end

提取行动项

行动项函数识别会议确定的任务和后续工作;转录文本中提供了负责人或截止时间时,也会一并提取。如果需要在其他系统中创建和分配任务,可以将这一步连接到函数调用。

来源示例 26(javascript):

代码内文字译释:列出会议确定的每项任务或后续工作。转录文本提供负责人和截止时间时,也一并列出。

// [中文] 请求模型提取会议确定的任务与后续工作,仅在原文提供时列出负责人和截止时间。
async function extractActionItems(transcription) {
  return complete(
    transcription,
    "List every task or follow-up agreed to in the meeting. Include the owner and deadline when the transcript provides them."
  );
}

来源示例 27(python):

代码内文字译释:列出会议确定的每项任务或后续工作。转录文本提供负责人和截止时间时,也一并列出。

## [中文] 请求模型提取会议确定的任务与后续工作,仅在原文提供时列出负责人和截止时间。
def action_item_extraction(transcription: str) -> str:
    return complete(
        transcription,
        "List every task or follow-up agreed to in the meeting. "
        "Include the owner and deadline when the transcript provides them.",
    )

来源示例 28(go):

代码内文字译释:列出会议确定的每项任务或后续工作。转录文本提供负责人和截止时间时,也一并列出。

// [中文] 请求模型提取会议确定的任务与后续工作,仅在原文提供时列出负责人和截止时间。
func extractActionItems(ctx context.Context, transcription string) (string, error) {
    return complete(ctx, transcription, "List every task or follow-up agreed to in the meeting. Include the owner and deadline when the transcript provides them.")
}

来源示例 29(java):

代码内文字译释:列出会议确定的每项任务或后续工作。转录文本提供负责人和截止时间时,也一并列出。

// [中文] 请求模型提取会议确定的任务与后续工作,仅在原文提供时列出负责人和截止时间。
static String extractActionItems(String transcription) {
  return complete(
      transcription,
      "List every task or follow-up agreed to in the meeting. "
          + "Include the owner and deadline when the transcript provides them.");
}

来源示例 30(ruby):

代码内文字译释:列出会议确定的每项任务或后续工作。转录文本提供负责人和截止时间时,也一并列出。

## [中文] 请求模型提取会议确定的任务与后续工作,仅在原文提供时列出负责人和截止时间。
def extract_action_items(client, transcription)
  complete(
    client,
    transcription,
    "List every task or follow-up agreed to in the meeting. Include the owner and deadline when the transcript provides them."
  )
end

情绪分析

情绪分析函数将讨论的整体倾向归为正面、负面或中性,并解释判断依据。对于较简单的任务,原文建议尝试 gpt-5.6-terra,评估它能否以更低的费用和延迟满足质量目标。

来源示例 31(javascript):

代码内文字译释:将会议的整体情绪描述为正面、负面或中性,并简要解释判断依据。

// [中文] 请求模型判断会议整体情绪为正面、负面或中性,并简述依据。
async function analyzeSentiment(transcription) {
  return complete(
    transcription,
    "Describe the meeting's overall sentiment as positive, negative, or neutral, and briefly explain the assessment."
  );
}

来源示例 32(python):

代码内文字译释:将会议的整体情绪描述为正面、负面或中性,并简要解释判断依据。

## [中文] 请求模型判断会议整体情绪为正面、负面或中性,并简述依据。
def sentiment_analysis(transcription: str) -> str:
    return complete(
        transcription,
        "Describe the meeting's overall sentiment as positive, negative, or "
        "neutral, and briefly explain the assessment.",
    )

来源示例 33(go):

代码内文字译释:将会议的整体情绪描述为正面、负面或中性,并简要解释判断依据。

// [中文] 请求模型判断会议整体情绪为正面、负面或中性,并简述依据。
func analyzeSentiment(ctx context.Context, transcription string) (string, error) {
    return complete(ctx, transcription, "Describe the meeting's overall sentiment as positive, negative, or neutral, and briefly explain the assessment.")
}

来源示例 34(java):

代码内文字译释:将会议的整体情绪描述为正面、负面或中性,并简要解释判断依据。

// [中文] 请求模型判断会议整体情绪为正面、负面或中性,并简述依据。
static String analyzeSentiment(String transcription) {
  return complete(
      transcription,
      "Describe the meeting's overall sentiment as positive, negative, or neutral, "
          + "and briefly explain the assessment.");
}

来源示例 35(ruby):

代码内文字译释:将会议的整体情绪描述为正面、负面或中性,并简要解释判断依据。

## [中文] 请求模型判断会议整体情绪为正面、负面或中性,并简述依据。
def analyze_sentiment(client, transcription)
  complete(
    client,
    transcription,
    "Describe the meeting's overall sentiment as positive, negative, or neutral, and briefly explain the assessment."
  )
end

导出会议纪要

DALL·E 生成的音频波形图

将会议纪要保存为便于阅读和分发的格式。Microsoft Word 是这类报告的常见选择,示例分别使用适合各语言的 DOCX 库。在端到端应用中,也可以通过电子邮件发送结果,或写入其他系统。

定义辅助函数,把每个结果部分写入 Word 文档:

来源示例 36(javascript):

// [中文] 将会议纪要各部分写为Word标题与段落,保存为DOCX;依赖所用语言对应的文档库。
async function saveAsDocx(minutes, filename) {
  const children = Object.entries(minutes).flatMap(([heading, content]) => [
    new Paragraph({ text: heading, heading: HeadingLevel.HEADING_1 }),
    new Paragraph({
      children: content
        .split(/\r\n?|\n/)
        .flatMap((line, index) => [
          ...(index > 0 ? [new TextRun({ break: 1 })] : []),
          new TextRun(line),
        ]),
    }),
  ]);
  const document = new Document({ sections: [{ children }] });
  await fs.promises.writeFile(filename, await Packer.toBuffer(document));
}

来源示例 37(python):

## [中文] 将会议纪要各部分写为Word标题与段落,保存为DOCX;依赖所用语言对应的文档库。
def save_as_docx(minutes: dict[str, str], filename: Path) -> None:
    document = Document()
    for heading, content in minutes.items():
        document.add_heading(heading, level=1)
        document.add_paragraph(content)
    document.save(filename)

来源示例 38(go):

代码内文字译释:文档栏目名:Abstract summary=摘要,Key points=要点,Action items=行动项,Sentiment=情绪倾向。

// [中文] 将会议纪要各部分写为Word标题与段落,保存为DOCX;依赖所用语言对应的文档库。
func saveAsDocx(minutes meetingMinutes, filename string) error {
    document, err := godocx.NewDocument()
    if err != nil {
        return err
    }
    for _, section := range []struct{ heading, content string }{
        {"Abstract summary", minutes.AbstractSummary},
        {"Key points", minutes.KeyPoints},
        {"Action items", minutes.ActionItems},
        {"Sentiment", minutes.Sentiment},
    } {
        document.AddHeading(section.heading, 1)
        for _, line := range strings.Split(strings.ReplaceAll(section.content, "\r\n", "\n"), "\n") {
            document.AddParagraph(line)
        }
    }
    return document.SaveTo(filename)
}

来源示例 39(java):

代码内文字译释:文档栏目名:Abstract summary=摘要,Key points=要点,Action items=行动项,Sentiment=情绪倾向。

// [中文] 将会议纪要各部分写为Word标题与段落,保存为DOCX;依赖所用语言对应的文档库。
static void saveAsDocx(MeetingMinutes minutes, Path filename) throws IOException {
  try (var document = new XWPFDocument();
      OutputStream output = Files.newOutputStream(filename)) {
    addHeadingStyle(document);
    addSection(document, "Abstract summary", minutes.abstractSummary());
    addSection(document, "Key points", minutes.keyPoints());
    addSection(document, "Action items", minutes.actionItems());
    addSection(document, "Sentiment", minutes.sentiment());
    document.write(output);
  }
}

private static void addHeadingStyle(XWPFDocument document) {
  var headingStyle = CTStyle.Factory.newInstance();
  headingStyle.setStyleId("Heading1");
  headingStyle.addNewName().setVal("Heading 1");
  headingStyle.setType(STStyleType.PARAGRAPH);
  headingStyle.addNewPPr().addNewOutlineLvl().setVal(BigInteger.ZERO);
  document.createStyles().addStyle(new XWPFStyle(headingStyle));
}

private static void addSection(XWPFDocument document, String heading, String content) {
  var headingParagraph = document.createParagraph();
  headingParagraph.setStyle("Heading1");
  var headingRun = headingParagraph.createRun();
  headingRun.setBold(true);
  headingRun.setFontSize(16);
  headingRun.setText(heading);
  var contentRun = document.createParagraph().createRun();
  String[] lines = content.split("\\R", -1);
  for (int index = 0; index < lines.length; index += 1) {
    if (index > 0) contentRun.addBreak();
    contentRun.setText(lines[index]);
  }
}

来源示例 40(ruby):

## [中文] 将会议纪要各部分写为Word标题与段落,保存为DOCX;依赖所用语言对应的文档库。
def save_as_docx(minutes, filename)
  Caracal::Document.save(filename) do |document|
    minutes.each do |heading, content|
      document.h1(heading)
      content.split(/\r\n?|\n/, -1).each { |line| document.p(line) }
    end
  end
end

该函数接收生成的各部分内容和输出文件名,为每部分添加标题和段落,再把文档保存到当前工作目录。示例保留英文栏目名,含义为:Abstract summary(摘要)、Key points(要点)、Action items(行动项)、Sentiment(情绪倾向)。

最后,将各步骤组合起来,从音频文件生成会议纪要:

来源示例 41(javascript):

// [中文] 读取工作目录中的meeting.wav,转录、生成并打印纪要,再写入meeting_minutes.docx。
const transcription = await transcribeAudio("meeting.wav");
const minutes = await buildMeetingMinutes(transcription);
console.log(minutes);
await saveAsDocx(minutes, "meeting_minutes.docx");

来源示例 42(python):

## [中文] 读取工作目录中的meeting.wav,转录、生成并打印纪要,再写入meeting_minutes.docx。
audio_file_path = Path("meeting.wav")
transcription = transcribe_audio(audio_file_path)
minutes = meeting_minutes(transcription)
print(minutes)
save_as_docx(minutes, Path("meeting_minutes.docx"))

来源示例 43(go):

// [中文] 读取工作目录中的meeting.wav,转录、生成并打印纪要,再写入meeting_minutes.docx。
func main() {
    ctx := context.Background()
    transcription, err := transcribeAudio(ctx, "meeting.wav")
    if err != nil {
        panic(err)
    }
    minutes, err := buildMeetingMinutes(ctx, transcription)
    if err != nil {
        panic(err)
    }
    fmt.Printf("%+v\n", minutes)
    if err := saveAsDocx(minutes, "meeting_minutes.docx"); err != nil {
        panic(err)
    }
}

来源示例 44(java):

// [中文] 读取工作目录中的meeting.wav,转录、生成并打印纪要,再写入meeting_minutes.docx。
public static void main(String[] args) throws IOException {
    String transcription = transcribeAudio(Path.of("meeting.wav"));
    MeetingMinutes minutes = buildMeetingMinutes(transcription);
    System.out.println(minutes);
    saveAsDocx(minutes, Path.of("meeting_minutes.docx"));
  }
}

来源示例 45(ruby):

## [中文] 读取工作目录中的meeting.wav,转录、生成并打印纪要,再写入meeting_minutes.docx。
transcription = transcribe_audio(client, "meeting.wav")
minutes = build_meeting_minutes(client, transcription)
puts minutes
save_as_docx(minutes, "meeting_minutes.docx")

这段代码从进程的当前工作目录读取 meeting.wav,生成并打印会议纪要,再将其保存为 meeting_minutes.docx。

建立基本流程后,可以通过提示词工程 调整提示词,也可以使用函数调用 构建端到端系统。

示例按语言分段展示,需将同一种语言的片段按顺序组合并准备依赖;Java 首段打开的类在最后一段结束。本文完成本地代码保真及可用的静态检查,未调用真实 API、处理录音或生成 DOCX,运行兼容性保留待核。

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号