用途
Geek-skills-podcast-generator 用于将文本内容转换为 AI 生成的播客音频。它调用火山引擎的播客 AI 模型,把输入文本转化为具有自然对话流的双人播客音频,适合把博客文章、研究摘要、教学主题等文字材料快速转成可收听的音频节目。
主要能力
- 文本转播客:输入中文文本(最多 25,000 字符),生成双人对话式播客音频。
- 音频格式选择:支持 mp3、ogg_opus、pcm、aac 四种格式。
- 参数调节:可设置采样率(默认 24000 Hz)、语速(-50 到 100,100 相当于 2.0 倍速)。
- 说话人配置:默认男声 + 女声组合,也可自定义说话人音色。
- 开场音乐:可选开启(默认关闭)。
- 中断续传:生成中断后可通过 retry_info 从上次完成的轮次继续,而非重新开始。
- 流式输出:实时接收音频数据,显示每轮说话进度,并返回生成统计信息(文件大小、轮次数等)。
使用方式
使用前需准备火山引擎凭证:APP_ID 与 ACCESS_KEY(可从火山引擎控制台获取)。
命令行方式:
python scripts/generate_podcast.py \
--text "Your podcast topic or content" \
--output "/path/to/output.mp3" \
--app-id "YOUR_APP_ID" \
--access-key "YOUR_ACCESS_KEY" \
--format mp3 \
--sample-rate 24000 \
--speech-rate 0
Python 模块方式:
import asyncio
from scripts.generate_podcast import PodcastGenerator
async def create_podcast():
generator = PodcastGenerator(
app_id="YOUR_APP_ID",
access_key="YOUR_ACCESS_KEY"
)
result = await generator.generate_podcast(
input_text="分析下当前的大模型发展",
output_path="podcast.mp3",
audio_format="mp3",
sample_rate=24000,
speech_rate=0,
use_head_music=False
)
if result['success']:
print(f"✅ Podcast generated: {result['output_path']}")
else:
print(f"❌ Failed: {result['error']}")
asyncio.run(create_podcast())
自定义说话人示例:
result = await generator.generate_podcast(
input_text="Your topic",
output_path="podcast.mp3",
speakers=[
"zh_male_dayixiansheng_v2_saturn_bigtts",
"zh_female_mizaitongxue_v2_saturn_bigtts"
]
)
中断续传示例:
result = await generator.generate_podcast(
input_text="Your topic",
output_path="podcast.mp3",
retry_info={
"retry_task_id": "previous_task_id",
"last_finished_round_id": 5
}
)
依赖安装:
pip install websockets
适用场景
- 博客文章转播客:将长文内容转为音频节目。
- 研究论文摘要:把研究要点生成播客,可开启开场音乐增强专业感。
- 教育内容:讲解入门概念,可适当放慢语速(如 speech_rate=-20)。
限制
- 最大文本长度 25,000 字符,超出部分会被模型截断。
- 语言支持主要针对中文优化。
- 并发请求受账户配额限制。
- 音频质量由模型能力决定,无法通过参数控制。
- 使用需火山引擎凭证,凭证与配额相关细节暂未提供。