Chuyển tới nội dung chính

Tích hợp Qwen3-TTS

Chạy Qwen3-TTS của Alibaba cục bộ. Máy chủ tương thích OpenAI được kèm theo Libre WebUI.

Tổng quan

  • 9 giọng dựng sẵn
  • 10 ngôn ngữ
  • Nhân bản từ mẫu 3 giây
  • Thiết kế giọng từ mô tả
  • Điều khiển cảm xúc

Yêu cầu

Thành phầnTối thiểuKhuyến nghị
Python3.12+3.12
GPU VRAM4GB8GB+
RAM8GB16GB+
Đĩa5GB10GB

Nền tảng

Nền tảngBackendGhi chú
NVIDIA GPUCUDANhanh nhất
Apple SiliconMPSDùng 0.6B
CPUPyTorchChậm
Apple Silicon

Dùng customvoice-0.6b; 1.7B có thể gây áp lực bộ nhớ 16GB.

Bắt đầu

1. Cài máy chủ

cd examples/qwen-tts-server

# Create virtual environment (Python 3.12 required)
python3.12 -m venv venv
source venv/bin/activate # Linux/macOS
# or: venv\Scripts\activate # Windows

# Install dependencies
pip install -r requirements.txt

2. Chạy

# NVIDIA GPU (recommended)
python server.py --model customvoice-1.7b

# Apple Silicon
python server.py --model customvoice-0.6b

# CPU (slower)
python server.py --model customvoice-0.6b

Máy chủ chạy tại http://localhost:8100.

3. Cấu hình Libre WebUI

Bật plugin plugins/qwen-tts.json trong Settings → Plugins → Qwen3 TTS.

4. Thử

curl http://localhost:8100/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "qwen3-tts", "input": "Hello, welcome to Libre WebUI!", "voice": "Ryan"}' \
--output speech.wav

Mô hình

Mô hìnhKích thướcDùng cho
customvoice-1.7b~3.5GBGiọng dựng sẵn
customvoice-0.6b~1.5GBNhẹ
voicedesign-1.7b~3.5GBThiết kế giọng
base-1.7b~3.5GBNhân bản
base-0.6b~1.5GBNhân bản nhẹ

Giọng

Giọng dựng sẵn

GiọngNgôn ngữMô tả
RyanAnhNam
AidenAnhNam
VivianTrungNữ
SerenaTrungNữ
Uncle_FuTrungNam
DylanTrungBắc Kinh
EricTrungTứ Xuyên
Ono_AnnaNhậtNữ
SoheeHànNữ

Bí danh OpenAI

OpenAIGiọng
alloyRyan
echoAiden
fableVivian
onyxUncle_Fu
novaSerena
shimmerOno_Anna

API

Tạo giọng nói

Endpoint: POST /v1/audio/speech

{
"model": "qwen3-tts",
"input": "Text to convert to speech",
"voice": "Ryan",
"response_format": "wav",
"instruct": "Speak with enthusiasm",
"language": "English"
}
Tham sốKiểuMặc địnhMô tả
modelstringqwen3-ttsID
inputstringbắt buộcVăn bản
voicestringryanGiọng
response_formatstringwavĐịnh dạng
instructstring""Chỉ dẫn
languagestringtự độngNgôn ngữ

Phản hồi: (audio/wav)

Thiết kế giọng

Endpoint: POST /v1/audio/voice-design

{
"model": "qwen3-tts-voicedesign",
"input": "Welcome to our service.",
"voice_description": "A warm, friendly female voice with a slight British accent",
"language": "English"
}
ghi chú

Cần voicedesign-1.7b.

Nhân bản giọng

Endpoint: POST /v1/audio/voice-clone

curl -X POST http://localhost:8100/v1/audio/voice-clone \
-F "input=Hello, this is my cloned voice." \
-F "reference_audio=@reference.wav" \
-F "reference_text=This is what was said in the reference." \
--output cloned.wav
Tham sốKiểuMô tả
inputstringVăn bản
reference_audiofileMẫu 3+ giây
reference_textstringBản chép
ghi chú

Cần base-1.7b hoặc base-0.6b.

Danh sách giọng

Endpoint: GET /v1/voices

{
"voices": [
{"id": "ryan", "name": "Ryan", "language": "English"},
{"id": "aiden", "name": "Aiden", "language": "English"},
...
]
}

Sức khỏe

Endpoint: GET /health

{ "status": "healthy", "model_loaded": true }

Cấu hình máy chủ

python server.py [OPTIONS]
Tùy chọnMặc địnhMô tả
--host0.0.0.0Host
--port8100Cổng
--modelcustomvoice-1.7bMô hình

Truy cập mạng

# Start server on all interfaces
python server.py --host 0.0.0.0 --port 8100

# Access from another machine
curl http://192.168.1.100:8100/v1/audio/speech ...
{
"endpoint": "http://192.168.1.100:8100/v1/audio/speech",
"capabilities": {
"tts": {
"endpoint": "http://192.168.1.100:8100/v1/audio/speech"
}
}
}

Tính năng sản xuất

Làm sạch

  • Xóa emoji, ký hiệu, Markdown như *bold*_italic_, lặp FUUUUU thành FUU, và chỉ dẫn sân khấu như *(action)* hoặc (whispers)
  • Chuẩn hóa khoảng trắng

Chia văn bản

  • 500 ký tự/phần
  • 30 giây/phần
  • Bỏ phần lỗi
  • Ghép âm thanh

Nhiều GPU

device_map = {"": "cuda:0"} # Uses first GPU only
CUDA_VISIBLE_DEVICES=1 python server.py --model customvoice-1.7b

Khắc phục sự cố

Tải mô hình lỗi

# Set Hugging Face token for gated models
export HF_TOKEN=hf_...

# Or download manually
huggingface-cli download Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice

Hết bộ nhớ Apple

RuntimeError: MPS backend out of memory
python server.py --model customvoice-0.6b

Hết bộ nhớ CUDA

torch.cuda.OutOfMemoryError: CUDA out of memory
  1. Đóng ứng dụng GPU
  2. Dùng 0.6B
  3. Đặt max_chunk_size=300

Hết thời gian

Rút ngắn văn bản hoặc xem log.

Âm thanh sai

Đặt language, bỏ ký hiệu, kiểm tra dấu câu.

Cấu hình plugin

{
"id": "qwen-tts",
"name": "Qwen3 TTS",
"type": "tts",
"endpoint": "http://localhost:8100/v1/audio/speech",
"auth": {
"header": "",
"key_env": ""
},
"model_map": [
"qwen3-tts",
"qwen3-tts-customvoice",
"qwen3-tts-voicedesign",
"qwen3-tts-clone"
],
"capabilities": {
"tts": {
"endpoint": "http://localhost:8100/v1/audio/speech",
"model_map": [
"qwen3-tts",
"qwen3-tts-customvoice",
"qwen3-tts-voicedesign",
"qwen3-tts-clone"
],
"config": {
"voices": [
"Ryan",
"Aiden",
"Vivian",
"Serena",
"Uncle_Fu",
"Dylan",
"Eric",
"Ono_Anna",
"Sohee"
],
"default_voice": "Ryan",
"formats": ["wav"],
"default_format": "wav",
"max_characters": 10000,
"supports_streaming": false,
"no_auth_required": true
}
}
},
"description": "Qwen3-TTS local TTS server (NVIDIA CUDA, Apple MPS, or CPU)",
"documentation_url": "https://github.com/QwenLM/Qwen3-TTS"
}

Tài nguyên