viet tts
v20241212

Viettts是一个开源工具包,可为社区提供强大的越南TTS模型,能够自然语音综合和强大的语音克隆。越野专为有效的实验而设计,支持越南语音技术的研究和应用。
可以通过Python安装程序(仅Linux,Windows和MacOS支持即将推出)或Docker安装Viettts。
git clone https://github.com/dangvansam/viet-tts.git
cd viet-tts
# (Optional) Install Python environment with conda, you could also use virtualenv
conda create --name viettts python=3.10
conda activate viettts
# Install
pip install -e . && pip cache purge安装Docker,Nvidia驱动程序,NVIDIA容器工具包和CUDA。
运行以下命令:
git clone https://github.com/dangvansam/viet-tts.git
cd viet-tts
# Build docker images
docker compose build
# Run with docker-compose - will create server at: http://localhost:8298
docker compose up -d
# Or run with docker run - will create server at: http://localhost:8298
docker run -itd --gpu=alls -p 8298:8298 -v ./pretrained-models:/app/pretrained-models -n viet-tts-service viet-tts:latest viettts server --host 0.0.0.0 --port 8298您可以使用可用的声音波纹管来综合语音。
| ID | 嗓音 | 性别 | 播放音频 |
|---|---|---|---|
| 1 | NSND-LE-CHUC | ? | |
| 2 | Speechify_10 | ? | |
| 3 | 阿特恩 | ? | |
| 4 | Speechify_11 | ? | |
| 5 | CDTeam | ? | |
| 6 | Speechify_12 | ? | |
| 7 | cross_lingual_prompt | ? | |
| 8 | Speechify_2 | ? | |
| 9 | Diep-chi | ? | |
| 10 | Speekify_3 | ? | |
| 11 | Doremon | ? | |
| 12 | Speekify_4 | ? | |
| 13 | 杰克·斯波罗(Jack-Sparrow) | ? | |
| 14 | Speekify_5 | ? | |
| 15 | nguyen-ngoc-ngan | ? | |
| 16 | Speekify_6 | ? | |
| 17 | nu-nhe-nhang | ? | |
| 18 | Speekify_7 | ? | |
| 19 | Quynh | ? | |
| 20 | Speechify_8 | ? | |
| 21 | Speechify_9 | ? | |
| 22 | Son-tung-mtp | ? | |
| 23 | ZERO_SHOT_PROMPT | ? | |
| 24 | Speekify_1 | ? |
VIETTTS命令行接口(CLI)允许您直接从终端快速生成语音。这是使用它的方法:
# Usage
viettts --help
# Start API Server
viettts server --host 0.0.0.0 --port 8298
# List all built-in voices
viettts show-voices
# Synthesize speech from text with built-in voices
viettts synthesis --text " Xin chào " --voice 0 --output test.wav
# Clone voice from a local audio file
viettts synthesis --text " Xin chào " --voice Download/voice.wav --output cloned.wav您需要为OpenAI客户端设置环境变量:
# Set base_url and API key as environment variables
export OPENAI_BASE_URL=http://localhost:8298
export OPENAI_API_KEY=viet-tts # not use in current version从输入文本中创建语音:
from pathlib import Path
from openai import OpenAI
client = OpenAI ()
output_file_path = Path ( __file__ ). parent / "speech.wav"
with client . audio . speech . with_streaming_response . create (
model = 'tts-1' ,
voice = 'cdteam' ,
input = 'Xin chào Việt Nam.' ,
speed = 1.0 ,
response_format = 'wav'
) as response :
response . stream_to_file ( 'a.wav' ) # Get all built-in voices
curl --location http://0.0.0.0:8298/v1/voices
# OpenAI format (bult-in voices)
curl http://localhost:8298/v1/audio/speech
-H " Authorization: Bearer viet-tts "
-H " Content-Type: application/json "
-d ' {
"model": "tts-1",
"input": "Xin chào Việt Nam.",
"voice": "son-tung-mtp"
} '
--output speech.wav
# API with voice from local file
curl --location http://0.0.0.0:8298/v1/tts
--form ' text="xin chào" '
--form ' audio_file=@"/home/viettts/Downloads/voice.mp4" '
--output speech.wav import fs from "fs" ;
import path from "path" ;
import OpenAI from "openai" ;
const openai = new OpenAI ( ) ;
const speechFile = path . resolve ( "./speech.wav" ) ;
async function main ( ) {
const mp3 = await openai . audio . speech . create ( {
model : "tts-1" ,
voice : "1" ,
input : "Xin chào Việt Nam." ,
} ) ;
console . log ( speechFile ) ;
const buffer = Buffer . from ( await mp3 . arrayBuffer ( ) ) ;
await fs . promises . writeFile ( speechFile , buffer ) ;
}
main ( ) ; VIETTTS源代码在Apache 2.0许可下发布。预先训练的模型和音频样本是根据CC BY-NC许可证的许可,基于野外数据集。对于可能造成的任何不便,我们深表歉意。
上面提供的内容仅用于学术目的,旨在展示技术能力。一些示例来自互联网。如果任何内容侵犯了您的权利,请与我们联系以要求删除其权利。