mesolitica/TTS-Combine-annotated
Viewer • Updated • 360k • 64
How to use mesolitica/malay-parler-tts-mini-v1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="mesolitica/malay-parler-tts-mini-v1") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoModelForSeq2SeqLM
model = AutoModelForSeq2SeqLM.from_pretrained("mesolitica/malay-parler-tts-mini-v1", device_map="auto")How to use mesolitica/malay-parler-tts-mini-v1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "mesolitica/malay-parler-tts-mini-v1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "mesolitica/malay-parler-tts-mini-v1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/mesolitica/malay-parler-tts-mini-v1
How to use mesolitica/malay-parler-tts-mini-v1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "mesolitica/malay-parler-tts-mini-v1" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "mesolitica/malay-parler-tts-mini-v1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "mesolitica/malay-parler-tts-mini-v1" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "mesolitica/malay-parler-tts-mini-v1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use mesolitica/malay-parler-tts-mini-v1 with Docker Model Runner:
docker model run hf.co/mesolitica/malay-parler-tts-mini-v1
Finetuned https://huggingface.co/parler-tts/parler-tts-mini-v1 on Malay TTS dataset
Source code at https://github.com/mesolitica/malaya-speech/tree/master/session/parler-tts
Wandb at https://wandb.ai/huseinzol05/parler-speech?nw=nwuserhuseinzol05
pip3 install git+https://github.com/mesolitica/async-parler-tts
import torch
from parler_tts import ParlerTTSForConditionalGeneration
from transformers import AutoTokenizer
import soundfile as sf
device = "cuda:0" if torch.cuda.is_available() else "cpu"
model = ParlerTTSForConditionalGeneration.from_pretrained("mesolitica/malay-parler-tts-mini-v1").to(device)
tokenizer = AutoTokenizer.from_pretrained("mesolitica/malay-parler-tts-mini-v1")
speakers = [
'Yasmin',
'Osman',
'Bunga',
'Ariff',
'Ayu',
'Kamarul',
'Danial',
'Elina',
]
prompt = 'Husein zolkepli sangat comel dan kacak suka makan cendol'
for s in speakers:
description = f"{s}'s voice, delivers a slightly expressive and animated speech with a moderate speed and pitch. The recording is of very high quality, with the speaker's voice sounding clear and very close up."
input_ids = tokenizer(description, return_tensors="pt").to(device)
prompt_input_ids = tokenizer(prompt, return_tensors="pt").to(device)
generation = model.generate(
input_ids=input_ids.input_ids,
attention_mask=input_ids.attention_mask,
prompt_input_ids=prompt_input_ids.input_ids,
prompt_attention_mask=prompt_input_ids.attention_mask,
)
audio_arr = generation.cpu()
sf.write(f'{s}.mp3', audio_arr.numpy().squeeze(), 44100)