Generate podcasts from documents using Mimo LLM, Mimo TTS, and MiniMax BGM
Project description
PodcastGen
📻 文档播客生成工具 — 基于 Mimo LLM + Mimo TTS + MiniMax BGM
将文档自动转换为高质量播客音频:AI 分析文档结构 → 生成播客脚本 → 语音合成 → 背景音乐 → 混音输出。
✨ 特性
- 📊 智能文档分析:Mimo LLM (OpenAI 格式) 分析文档,按段落结构化输出 JSON
- 📝 脚本生成:支持单人/双人模式,三种风格(专业/轻松/叙事),多语言
- 🎤 TTS 合成:Mimo TTS 分段合成,自动拼接停顿
- 🎵 BGM 生成:MiniMax Music 2.6 生成背景音乐,自动循环+淡入淡出
- 🔊 混音输出:独立音量控制,自动归一化,WAV 输出
- 🎛️ CLI 命令:一键生成,支持丰富参数
📦 安装
pip install podcastgen
或从源码安装:
git clone <repo-url>
cd podcast_generator
pip install -e .
🔑 配置
设置环境变量:
export MIMO_API_KEY="your-mimo-api-key"
export MINIMAX_API_KEY="your-minimax-api-key"
🚀 使用
命令行
# 基本用法:基于文档生成
podcastgen -i document.md
# 基于话题直接生成脚本(无需文档)
podcastgen -t "人工智能对教育行业的影响"
# 双人播客 + 轻松风格 + 20分钟
podcastgen -i document.md --mode double --tone casual --duration 20
# 话题模式 + 联网搜索 + 叙事风格
podcastgen -t "2024年AI大模型发展趋势" --web-search --tone storytelling --duration 15
# 仅分析文档(不生成音频)
podcastgen -i document.md --analyze-only
# 自定义BGM和音量
podcastgen -i document.md --bgm-prompt "lo-fi chillhop" --voice-volume 1.0 --bgm-volume 0.25
# 不要BGM,纯人声
podcastgen -i document.md --no-bgm
# 自定义音色
podcastgen -i document.md --host-voice "冰糖" --guest-voice "苏打"
# 英文播客使用英文音色
podcastgen -i document.md --language en --host-voice "Mia" --guest-voice "Dean"
# 使用音色复刻(通过音频样本克隆声音)
podcastgen -i document.md --host-voice-sample ./host_voice.mp3 --guest-voice-sample ./guest_voice.wav
# 话题生成 + 音色复刻
podcastgen -t "时间管理的艺术" --host-voice-sample ./my_voice.wav --duration 10
音色复刻 + 风格控制
podcastgen -i document.md --host-voice-sample ./voice.mp3 --tone casual
### 话题生成模式
无需文档,直接根据话题生成播客脚本。适合快速创作知识分享类播客。
```bash
# 基于话题生成播客
podcastgen -t "人工智能在教育领域的应用与挑战"
# 话题 + 双人对话 + 轻松风格
podcastgen -t "职场新人如何快速成长" --mode double --tone casual --duration 15
# 话题 + 联网搜索(获取最新信息)
podcastgen -t "2024年诺贝尔物理学奖解读" --web-search
# 话题 + 英文播客
podcastgen -t "The future of renewable energy" --language en --duration 20
音色复刻
通过传入音频样本文件,精准复刻目标音色。使用 mimo-v2.5-tts-voiceclone 模型。
注意事项:
- 支持 mp3 和 wav 格式
- 文件大小不能超过 10MB
- 建议使用清晰的人声录音(30秒以上效果更佳)
示例:
# 使用音频样本克隆主持人音色
podcastgen -i document.md --host-voice-sample ./my_voice.wav
# 双人播客,两人都使用音色复刻
podcastgen -i document.md --mode double \
--host-voice-sample ./host_sample.mp3 \
--guest-voice-sample ./guest_sample.wav
可选音色
| 音色名 | Voice ID | 语言 | 性别 |
|---|---|---|---|
| MiMo-默认 | mimo_default |
因部署集群而异 | - |
| 冰糖 | 冰糖 |
中文 | 女性 |
| 茉莉 | 茉莉 |
中文 | 女性 |
| 苏打 | 苏打 |
中文 | 男性 |
| 白桦 | 白桦 |
中文 | 男性 |
| Mia | Mia |
英文 | 女性 |
| Chloe | Chloe |
英文 | 女性 |
| Milo | Milo |
英文 | 男性 |
| Dean | Dean |
英文 | 男性 |
Python API
from podcastgen import PodcastPipeline, load_config
# 使用默认配置
pipeline = PodcastPipeline()
# 基于文档生成播客
result = pipeline.run(
document="你的文档内容...",
mode="single", # single / double
tone="professional", # professional / casual / storytelling
duration_min=10,
language="zh",
)
print(result["files"]["final"]) # 最终音频路径
# 基于话题生成播客(无需文档)
result = pipeline.run(
topic="人工智能在教育领域的应用与挑战",
mode="single",
tone="casual",
duration_min=15,
language="zh",
web_search=True, # 启用联网搜索
)
# 完整参数示例
result = pipeline.run(
document="你的文档内容...",
mode="double",
tone="casual",
duration_min=20,
language="zh",
bgm_prompt="lo-fi chillhop",
voice_volume=1.0,
bgm_volume=0.3,
no_bgm=False,
analyze_only=False,
host_voice="冰糖",
guest_voice="苏打",
host_voice_sample=None, # 音色样本文件路径,启用音色复刻
guest_voice_sample=None,
)
# 使用音色复刻
result = pipeline.run(
document="你的文档内容...",
mode="single",
host_voice_sample="./my_voice.wav", # 通过音频样本克隆声音
)
# 也可以分步调用
analysis = pipeline.analyze(document)
script = pipeline.generate_script(document, analysis)
voice = pipeline.synthesize_voice(script["script"])
bgm = pipeline.generate_bgm("ambient, chill")
mixed = pipeline.mix_audio(voice, bgm)
📁 输出结构
output/podcast_YYYYMMDD_HHMMSS/
├── analysis.json # 文档分析结果(JSON)
├── script.txt # 播客脚本
├── voice.wav # 人声音频
├── bgm.wav # 背景音乐
├── podcast_final.wav # 最终混音
└── metadata.json # 元数据
🔧 API 参考
PodcastPipeline
| 方法 | 说明 |
|---|---|
run(document=None, topic=None, ...) |
完整流程:生成脚本 + TTS + BGM + 混音(document/topic 二选一) |
analyze(document, options) |
分析文档,返回结构化 JSON |
generate_script_from_document(document, analysis, options) |
基于文档生成完整播客脚本 |
generate_script_from_topic(topic, options) |
基于话题生成播客脚本(无需文档) |
synthesize_voice(script_text, progress_cb) |
TTS 合成语音 |
generate_bgm(prompt, duration_sec) |
生成背景音乐 |
mix_audio(voice_data, bgm_data, ...) |
混音合成 |
DocumentAnalyzer
| 方法 | 说明 |
|---|---|
analyze_document(document, options) |
分析文档,返回结构化 JSON |
generate_full_script(document, analysis, options) |
基于文档生成完整播客脚本 |
generate_podcast_script_from_topic(topic, options) |
基于话题生成播客脚本 |
parse_script_segments(script_text) |
解析脚本为角色分段 |
TTSSynthesizer
| 方法 | 说明 |
|---|---|
synthesize_segment(text, role, style) |
合成单段语音 |
synthesize_segments(segments, progress_callback) |
批量合成 |
save_wav(float_data, path) |
保存为 WAV |
BGMGenerator
| 方法 | 说明 |
|---|---|
generate_bgm(prompt, duration_sec) |
生成背景音乐 |
loop_bgm(bgm_data, target_duration_sec) |
循环延长 BGM |
apply_fade(audio_data, fade_in_sec, fade_out_sec) |
添加淡入淡出 |
AudioMixer
| 方法 | 说明 |
|---|---|
mix(voice_data, bgm_data, voice_volume, bgm_volume) |
混音 |
normalize(audio_data) |
归一化音量 |
extract_waveform(audio_data, num_points) |
提取波形数据 |
📋 参数说明
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
document |
str | None |
输入文档内容(与 topic 二选一) |
topic |
str | None |
播客话题描述(与 document 二选一) |
mode |
str | single |
播客模式:single 单人 / double 双人 |
tone |
str | professional |
风格:professional / casual / storytelling |
duration_min |
int | 10 |
目标时长(分钟) |
language |
str | zh |
语言:zh / en |
voice_volume |
float | 1.0 |
人声音量 |
bgm_volume |
float | 0.3 |
BGM 音量 |
host_voice |
str | 冰糖 |
主持人音色 |
guest_voice |
str | 苏打 |
嘉宾音色(双人模式) |
host_voice_sample |
str | "" |
主持人音色样本文件路径(启用音色复刻) |
guest_voice_sample |
str | "" |
嘉宾音色样本文件路径(启用音色复刻) |
web_search |
bool | False |
启用联网搜索(仅用于话题模式) |
no_bgm |
bool | False |
不生成 BGM,仅生成人声 |
analyze_only |
bool | False |
仅分析文档,不生成音频 |
📝 License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file podcastgen-0.1.3.tar.gz.
File metadata
- Download URL: podcastgen-0.1.3.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81db1d123904445d828cf41a6d727710cfb6498160c32f6355108cec451ee4c3
|
|
| MD5 |
65ea6e0ac78974dd8791df364fbdb082
|
|
| BLAKE2b-256 |
5386bf263e348cd980031a7d5f5b9e0198ba1a176a40d6d94ca813f80f0462ec
|
File details
Details for the file podcastgen-0.1.3-py3-none-any.whl.
File metadata
- Download URL: podcastgen-0.1.3-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e932e02509b56a740e9f9d94489d9330b9b2a7fe871bae90037d0b4494156cbc
|
|
| MD5 |
31b34d1cdcf19b671cd445734f568c86
|
|
| BLAKE2b-256 |
e92f7cccaf225fe41ac79658178ae0861570c3eda7160dd91559e825701bb329
|