材
网络上沉浸式英语听力素材有限。正好最近调试 OpenAI 的全家桶。
就做个小系统: 100%用 OpenAI 的 API 生成英语听力素材。
成品效果:
Whisper 转录+ChatGPT4 润色+OpenAI TTS 生成英语听力素材(纯英语版)_哔哩哔哩_bilibili
Whisper 转录+ChatGPT4 润色+OpenAI TTS 生成英语听力素材(含中文语音版)_哔哩哔哩_bilibili
实现思路:
- 用
pytube下载 YouTube 视频,并转成音频 - 用 OpenAI 的 API 调用 Whisper ,把音频转成文本
- 用 OpenAI 的 API 调用 ChatGPT4 ,润色、翻译文本成理想格式
- 用 OpenAI 的 API 调用 TTS 生成语音
- 用 ffmpeg 将语音和文字合成最终视频
这里分享我用的 prompt ,使用时将<输入的信息>替换成 Whisper 转录后的文本:
prompt = """
润色以下演讲稿, 注意生成讲故事风格, 不要遗漏细节, 不要遗漏包括提问、举例、交流以及互动等任何信息。忽视文尾的 Thank you 。确保:每句话 8 到 13 个单词,每句话独立成行,不分段,形成格式'英文|中文':
例如:
输入:
All right, I'd like you to take a moment, think about a time when you were recently sick.
Try specifically to think of a time when, even though you weren't feeling all that great, you still felt well enough to get up out of bed, go about your day.
The language I'm speaking right now is on its way to becoming the world's universal language, for better or for worse.
Let's face it.
It's the language of the internet, it's the language of finance,
Thank you.
Thank you.
错误的输出:
All right, take a moment and think back. | 好的,请花一点时间回想一下。
Remember a time when you were sick. | 回忆一下你最近生病的时候。
Recall feeling just well enough for your day. | 回想你虽然感觉不太好,但还能起床过日子。
The language I'm speaking right now is on its way to global dominance. | 我正在说的这种语言正在成为全球通用语言。
It's the language of international domains. | 它是互联网、金融、和其他领域的语言。
Thank you. | 谢谢你们
正确输出:
All right, take a moment and think back. | 好的,请花一点时间回想一下。
Remember a time when you were sick. | 回忆一下你最近生病的时候。
Recall feeling just well enough for your day. | 回想你虽然感觉不太好,但还能起床过日子。
The language I'm speaking right now is on its way to global dominance. | 我正在说的这种语言正在成为全球通用语言。
It's the language of international domains. | 它是互联网、金融、和其他领域的语言。
开始:
<输入的信息>
"""
最后生成 7 个多小时的视频花了 5.7 刀,这还包括了我日常 GPT4 的使用,实际花费估计 5 刀左右。