把口述的想法变成一份像你写的初稿

录一段自己说的话,加上两三篇你以前写的东西,让模型照着你的文风起草。关键不在录音,在那几篇样例——它们才是决定初稿像不像你的东西。

2024/05/14约 6 分钟HiBridge 编译
译文本文是英文原文的中文翻译,原作者与原文链接如下。
原作者
Google
原文标题
Gemini API: Voice memos
原发布平台
Google Gemini Cookbook
原发布日期
2024/05/14

译者说明:本文译自 Google Gemini Cookbook,原文为可运行的 Jupyter Notebook(Apache 2.0 许可)。 原文场景是「用手机上录的语音备忘录生成博客初稿」,此处翻译全部说明性内容与系统指令, 并在文末改写成研究咨询的场景。

关于日期:Cookbook 是持续更新的仓库,页面上没有发布日期。本文的日期取自该 notebook 在 GitHub 上的首次提交日期,也就是这份内容第一次被生产出来的时间。

本文演示如何在同一个提示词里同时使用音频文件和文本文件

你将用 Gemini API,基于你在手机上录的语音备忘录,以及你以前写过的文章,来为下一篇博客生成想法。

一、上传音频和文本

原文用了一段行走时的录音(Walking_thoughts_3.m4a)和两篇之前写的博客(PDF)。

Python
audio_file = client.files.upload(file="Walking_thoughts_3.m4a")

PDF 先转成纯文本再上传:

Terminal
pdftotext A_Possible_Future_for_Online_Content.pdf
Python
blog_file  = client.files.upload(file="A_Possible_Future_for_Online_Content.txt")
blog_file2 = client.files.upload(file="Unanswered_Questions_and_Endless_Possibilities.txt")

二、系统指令:这一步才是关键

原文写了一段很详细的系统指令来配置模型。这段是全文最值得抄的部分,原文照录:

Objective: Transform raw thoughts and ideas into polished, engaging blog posts that capture a writers unique style and voice.

Input:
Example Blog Posts (1-5): A user will provide examples of blog posts that resonate with their desired style and tone. These will guide you in understanding the preferences for word choice, sentence structure, and overall voice.
Audio Clips: A user will share a selection of brainstorming thoughts and key points through audio recordings. They will talk freely and openly, as if they were explaining their ideas to a friend.

Output:
Blog Post Draft: A well-structured first draft of the blog post, suitable for platforms like Substack or LinkedIn.
The draft will include:
Clear and engaging writing: you will strive to make the writing clear, concise, and interesting for the target audience.
Tone and style alignment: The language and style will closely match the examples provided, ensuring consistency with the desired voice.
Logical flow and structure: The draft will be organized with clear sections based on the content of the post.
Target word count: Aim for 500-800 words, but this can be adjusted based on user preferences.

Process:
Style Analysis: Carefully analyze the example blog posts provided by the user to identify key elements of their preferred style, including:
Vocabulary and word choice: Formal vs. informal, technical terms, slang, etc.
Sentence structure and length: Short and impactful vs. longer and descriptive sentences.
Tone and voice: Humorous, serious, informative, persuasive, etc.
Audio Transcription and Comprehension: Your audio clips will be transcribed with high accuracy. you will analyze them to extract key ideas, arguments, and supporting points.
Draft Generation: Using the insights from the audio and the style guidelines from the examples, you will generate a first draft of the blog post. This draft will include all relevant sections with supporting arguments or evidence, and a great ending that ties everything together and makes the reader want to invest in future readings.

拆开看,这段指令做了三件事:

部分 作用
Input 明确告诉它会收到两类东西:1–5 篇文风样例 + 随意口述的录音
Output 规定产出形态:结构清晰、语气对齐、500–800 字
Process 规定它的工作顺序:先分析文风(词汇、句式、语气三项),再转录并理解音频,最后才起草

「Process」那一段是这份指令真正起作用的地方——它不是让模型「写得像我」,而是告诉它先去分析什么、按什么顺序做

三、生成

Python
prompt = "Draft my next blog post based on my thoughts in this audio file and these two previous blog posts I wrote."

response = client.models.generate_content(
    model=MODEL_ID,
    contents=[prompt, blog_file, blog_file2, audio_file],
)

注意用户提示词只有一句话。 复杂度全在系统指令里,日常调用时不需要重复。


译后附记:改成研究咨询的版本

原文的场景是写博客,但这套「口述 + 文风样例 → 初稿」的结构,对这一行有几个更值钱的落点:

① 现场访谈结束后的即时回顾。 从客户那儿出来,在车上录五分钟——今天听到了什么、哪句话意外、下一步该验证什么。趁热录比回办公室再写准得多。 配上你以前的访谈备忘录当样例,出来就是一份可以直接进项目文件夹的东西。

② 出差路上口述报告框架。 你脑子里已经有结论了,只是没时间敲字。口述完,配上你团队过去交付的两份报告当样例,出来的框架已经带着你们的行文习惯。

③ 内部知识的沉淀。 资深同事讲一遍某个客户的历史,录下来,配上标准的项目背景文档当样例——把口头知识转成可交接的文档。

一段可以直接用的系统指令

可复制的提示词
【目标】把我口述的原始想法,整理成一份符合我们团队文风的初稿。

【输入】
- 文风样例:1–5 份我们团队以前交付过的文档。它们决定用词、句式和语气。
- 录音:我随意口述的想法,像跟同事聊天一样,没有组织。

【工作顺序】
1. 先分析文风样例,明确三件事:用词偏正式还是口语、句子偏短还是偏长、
   语气是克制陈述还是带判断。把你的判断先写出来给我看。
2. 再转录并理解录音,提取核心观点、论据和待验证的问题。
3. 最后起草。

【产出要求】
- 结构清晰,分节
- 语气与样例一致
- 录音里没说到的内容,**不要补充、不要展开、不要举例**。
  如果某处逻辑有缺口,在那里标一个「【待补】」而不是自己填上。

复制为纯文本,换行与缩进原样保留,可直接粘贴进对话框。

最后那一条是原文没有、但这一行必须加的。 原文的场景是写博客,模型自由发挥是加分;而你的初稿要送进项目文件夹,任何它自己编出来的例子和数据都是隐患。 让它留「【待补】」,你来填。

配套阅读:转录访谈时,模型为什么会把品牌名听成别的用 CLAUDE.md 把你的规矩固化下来


出处

本文译自 Google Gemini Cookbook,原文 Gemini API: Voice memos, 以 Apache License 2.0 发布。译文与译后附记由 HiBridge 撰写。