
Viettts adalah alat open-source yang menyediakan komunitas dengan model TTS Vietnam yang kuat, yang mampu melakukan sintesis suara alami dan kloning suara yang kuat. Dirancang untuk eksperimen yang efektif, Viettts mendukung penelitian dan aplikasi dalam teknologi suara Vietnam.
Viettts dapat diinstal melalui penginstal Python (Linux saja, dengan dukungan Windows dan MacOS segera hadir) atau Docker.
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 purgeInstal Docker, Driver NVIDIA, NVIDIA Container Toolkit, dan CUDA.
Jalankan perintah berikut:
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 8298Anda dapat menggunakan suara yang tersedia di bawah untuk mensintesis pidato.
| PENGENAL | Suara | Jenis kelamin | Mainkan audio |
|---|---|---|---|
| 1 | nsnd-le-chuc | ? | |
| 2 | pidato_10 | ? | |
| 3 | Atuan | ? | |
| 4 | pidato_11 | ? | |
| 5 | cdteam | ? | |
| 6 | pidato_12 | ? | |
| 7 | Cross_lingual_prompt | ? | |
| 8 | pidato_2 | ? | |
| 9 | Diep-Chi | ? | |
| 10 | pidato_3 | ? | |
| 11 | Doremon | ? | |
| 12 | pidato_4 | ? | |
| 13 | Jack-Sparrow | ? | |
| 14 | pidato_5 | ? | |
| 15 | Nguyen-Ngoc-Ngan | ? | |
| 16 | pidato_6 | ? | |
| 17 | nu-nhe-nhang | ? | |
| 18 | pidato_7 | ? | |
| 19 | Quynh | ? | |
| 20 | pidato_8 | ? | |
| 21 | pidato_9 | ? | |
| 22 | Son-tung-mtp | ? | |
| 23 | Zero_shot_prompt | ? | |
| 24 | pidato_1 | ? |
Viettts Command Line Interface (CLI) memungkinkan Anda untuk dengan cepat menghasilkan pidato langsung dari terminal. Inilah cara menggunakannya:
# 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.wavAnda perlu mengatur variabel lingkungan untuk klien 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 versionUntuk membuat pidato dari teks input:
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 ( ) ; Kode Sumber Viettts dirilis di bawah lisensi Apache 2.0 . Model pra-terlatih dan sampel audio dilisensikan di bawah lisensi CC BY-NC , berdasarkan dataset di-The-Wild. Kami mohon maaf atas ketidaknyamanan yang mungkin ditimbulkan.
Konten yang disediakan di atas hanya untuk tujuan akademik dan dimaksudkan untuk menunjukkan kemampuan teknis. Beberapa contoh bersumber dari internet. Jika ada konten yang melanggar hak Anda, silakan hubungi kami untuk meminta penghapusannya.