Metadata-Version: 2.4
Name: podcastgen
Version: 0.1.5
Summary: Generate podcasts from documents using Mimo LLM, Mimo TTS, and MiniMax BGM
Author-email: trueWangSyutung <trueWangSyutung@icloud.cn>
License: MIT License
        
        Copyright (c) 2026 OpenPodcast
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/trueWangSyutung/openpodcast
Project-URL: Documentation, https://github.com/trueWangSyutung/openpodcast#readme
Project-URL: Repository, https://github.com/trueWangSyutung/openpodcast
Project-URL: Issues, https://github.com/trueWangSyutung/openpodcast/issues
Keywords: podcast,tts,llm,minimax,mimo,audio
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: openai>=1.0.0
Requires-Dist: requests>=2.31.0
Requires-Dist: numpy>=1.24.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Dynamic: license-file

# PodcastGen

> 📻 文档播客生成工具 — 基于 Mimo LLM + Mimo TTS + MiniMax BGM

将文档自动转换为高质量播客音频：AI 分析文档结构 → 生成播客脚本 → 语音合成 → 背景音乐 → 混音输出。

## ✨ 特性

- 📊 **智能文档分析**：Mimo LLM (OpenAI 格式) 分析文档，按段落结构化输出 JSON
- 📝 **脚本生成**：支持单人/双人模式，三种风格（专业/轻松/叙事），多语言
- 🎤 **TTS 合成**：Mimo TTS 分段合成，自动拼接停顿
- 🎵 **BGM 生成**：MiniMax Music 2.6 生成背景音乐，自动循环+淡入淡出
- 🔊 **混音输出**：独立音量控制，自动归一化，WAV 输出
- 🎛️ **CLI 命令**：一键生成，支持丰富参数

## 📦 安装

```bash
pip install podcastgen
```

或从源码安装：

```bash
git clone <repo-url>
cd podcast_generator
pip install -e .
```

## 🔑 配置

设置环境变量：

```bash
export MIMO_API_KEY="your-mimo-api-key"
export MINIMAX_API_KEY="your-minimax-api-key"
```

## 🚀 使用

### 命令行

```bash
# 基本用法：基于文档生成
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
```

```bash
# 自定义音色
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秒以上效果更佳），音频时长不能超过30秒

**示例：**
```bash
# 使用音频样本克隆主持人音色
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

```python
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
