Skip to main content

DiffSinger UTAU inference toolkit with CLI

Project description

DiffSinger UTAU

DiffSinger UTAU 推理工具包,提供命令行工具和 Python API 进行语音合成。 基于 diffsinger 项目,兼容 OpenUtau 声库。

功能特性

  • 完整的 DiffSinger 推理流程:时长预测 → 音高预测 → 方差预测 → 声学模型 → 声码器
  • 支持多语言和多说话人
  • 提供命令行工具和 Python API
  • 支持音高移调、性别控制等参数调节

安装

由于历史原因,强依赖 PyTorch 1.13,因此建议使用 Python 3.8。

从 PyPI 安装

pip install diffsinger-utau

从源码安装

# 克隆仓库
git clone https://github.com/bingcheng1998/diffsinger_utau.git
cd diffsinger-utau

# 创建虚拟环境(推荐使用 Python 3.8)
conda create -n diffsinger python=3.8
conda activate diffsinger

# 安装依赖
pip install -e .

使用方法

下载声库

什么是声库?声库可以理解为歌唱者的模型,有着各自的音色等特性。

社区提供了DiffSinger自制声库分享,如果你不确定下载哪个,推荐从zhibin club下载姜柯JiangKe声库开始尝试。

下载声库后,需要解压,解压缩后的路径可以作为程序参数进行推理。

下载示例 ds 文件

什么是 ds 文件?ds 文件是修改后缀后的标准json文件,内容为歌曲的内容,包含歌词、音高等内容。

社区提供了示例文件,建议从示例文件推理开始尝试。

命令行工具

# 基本用法
dsutau samples/07_春江花月夜.ds

# 指定语音库和参数
dsutau samples/07_春江花月夜.ds \
  --voice-bank /Users/bc/Music/Singers/Junninghua_v1.4.0_DiffSinger_OpenUtau  \
  --lang zh \
  --speaker "jiangke" \
  --key-shift 2 \
  --pitch-steps 10 \
  --variance-steps 10 \
  --acoustic-steps 20 \
  --gender 0.0 \
  --output output/pred_all

Python API

from pathlib import Path
from voice_bank import PredAll
from voice_bank.commons.ds_reader import DSReader

# 初始化预测器
voice_bank = Path("artifacts/JiangKe_DiffSinger_CE_25.06")
predictor = PredAll(voice_bank)

# 读取 DS 文件
ds = DSReader("samples/07_春江花月夜.ds").read_ds()[0]

# 执行完整推理
results = predictor.predict_full_pipeline(
    ds=ds,
    lang="zh",
    speaker=None,  # 随机选择说话人
    key_shift=0,
    pitch_steps=10,
    variance_steps=10,
    acoustic_steps=50,
    gender=0.0,
    output_dir="output/pred_all",
    save_intermediate=True,
)

print(f"生成音频: {results['audio_path']}")

参数说明

  • --voice-bank: 语音库目录路径
  • --lang: 语言代码(默认: zh)
  • --speaker: 说话人名称(不指定则随机选择)
  • --key-shift: 音高移调半音数(默认: 0)
  • --pitch-steps: 音高扩散采样步数(默认: 10)
  • --variance-steps: 方差扩散采样步数(默认: 10)
  • --acoustic-steps: 声学模型扩散采样步数(默认: 50)
  • --gender: 性别参数 [-1, 1],-1为男性化,1为女性化(默认: 0)
  • --output: 输出目录(默认: output/pred_all)
  • --no-intermediate: 不保存中间结果文件

输出文件

推理完成后会在输出目录生成以下文件:

  • step1_duration.ds: 时长预测结果
  • step2_pitch.ds: 音高预测结果
  • step3_variance.ds: 方差预测结果
  • step4_mel_data.json: Mel数据(JSON格式)
  • step5_final_audio.wav: 最终音频文件
  • complete_prediction.ds: 完整预测结果

系统要求

  • Python 3.8
  • 支持的操作系统:Windows, macOS, Linux
  • 内存:建议 8GB 以上
  • 存储:至少 2GB 可用空间

依赖项

  • numpy>=1.21,<1.25
  • librosa>=0.9,<0.10
  • PyYAML>=6.0
  • onnxruntime>=1.12,<1.17
  • torch>=1.10,<2.0
  • pypinyin>=0.40
  • scipy>=1.7

开发

# 安装开发依赖
pip install -e ".[dev]"

# 运行测试
pytest

# 代码格式化
black voice_bank/

# 代码检查
flake8 voice_bank/

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

v0.1.2

v0.1.0

  • 初始版本
  • 支持完整的 DiffSinger 推理流程
  • 提供命令行工具和 Python API

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

diffsinger_utau-0.1.2.tar.gz (486.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diffsinger_utau-0.1.2-py3-none-any.whl (46.7 kB view details)

Uploaded Python 3

File details

Details for the file diffsinger_utau-0.1.2.tar.gz.

File metadata

  • Download URL: diffsinger_utau-0.1.2.tar.gz
  • Upload date:
  • Size: 486.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for diffsinger_utau-0.1.2.tar.gz
Algorithm Hash digest
SHA256 44800e44d6e9c863ab2f0b59c8b089683146efc141ee1f76fc7924fe8f40f628
MD5 9a057a0e136364e71c64c22573fc04c5
BLAKE2b-256 bb18165db9e844d8f7afbcb0b2ad18e3fbc02ce0d02c929895a42790892aa2c6

See more details on using hashes here.

File details

Details for the file diffsinger_utau-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for diffsinger_utau-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ba23f47c9b3b564074d95d0441befc0eda344faa718434523a1c97c39daaf969
MD5 639a67cee99bfafef691731b418a203d
BLAKE2b-256 b107fffb2a27d5132e0b6346a8a0ef1d04202af9f76cca9c840ab427dcec318e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page