pip install -U huggingface_hub
linux该命令不同
set HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download suno/bark --local-dir suno_bark --resume-download
调用示例
from transformers import pipeline
# 创建文本转语音管道
pipe = pipeline("text-to-speech", model="suno/bark")
# 输入文本
text = "你好,世界!"
# 生成语音
output = pipe(text)
# 保存生成的语音为 WAV 文件
with open("output.wav", "wb") as f:
f.write(output["audio"])