Views
No views yet
modeltext-to-speechpytorchth) and Lao (lo)text-to-speech, speech-synthesis, thai, lao, low-resource, spoken-language-model| File | Description |
|---|---|
thai_tts.pt | Public Thai TTS checkpoint. |
lao_tts.pt | Public Lao TTS checkpoint. |
release_config.json | Sanitized release metadata for the two checkpoints. |
| Checkpoint | Language | Recommended mode |
|---|---|---|
thai_tts.pt | Thai (th) | Cross-lingual inference with inference_cross_lingual. |
lao_tts.pt | Lao (lo) | Cross-lingual inference with inference_cross_lingual. |
1git clone https://github.com/FunAudioLLM/CosyVoice.git
2cd CosyVoice
3pip install -r requirements.txt
4pip install huggingface_hub torchaudio1import sys
2from pathlib import Path
3
4import torch
5import torchaudio
6from huggingface_hub import snapshot_download
7
8sys.path.append("third_party/Matcha-TTS")
9
10from cosyvoice.cli.cosyvoice import CosyVoice2
11from cosyvoice.utils.file_utils import load_wav
12
13
14HF_REPO_ID = "isabeth/SE-Bridge-TTS"
15BASE_MODEL_DIR = Path("pretrained_models/CosyVoice2-0.5B")
16
17language = "thai" # choose "thai" or "lao"; both default to cross-lingual
18checkpoint_name = {
19 "thai": "thai_tts.pt",
20 "lao": "lao_tts.pt",
21}[language]
22
23weights_dir = Path(snapshot_download(HF_REPO_ID))
24checkpoint_path = weights_dir / checkpoint_name
25
26cosyvoice = CosyVoice2(
27 str(BASE_MODEL_DIR),
28 load_jit=False,
29 load_trt=False,
30 load_vllm=False,
31 fp16=False,
32)
33state_dict = torch.load(checkpoint_path, map_location="cpu")
34cosyvoice.model.llm.load_state_dict(state_dict, strict=False)
35
36prompt_speech_16k = load_wav("prompt.wav", 16000)
37tts_text = "Text to synthesize in the selected language."
38
39if language not in {"thai", "lao"}:
40 raise ValueError("language must be either 'thai' or 'lao'")
41
42outputs = cosyvoice.inference_cross_lingual(
43 tts_text,
44 prompt_speech_16k,
45 stream=False,
46)
47
48for idx, output in enumerate(outputs):
49 torchaudio.save(
50 f"se_bridge_tts_{language}_cross_lingual_{idx}.wav",
51 output["tts_speech"],
52 cosyvoice.sample_rate,
53 )1language = "thai"
2prompt_text = "Transcript of prompt.wav."
3outputs = cosyvoice.inference_zero_shot(
4 tts_text,
5 prompt_text,
6 prompt_speech_16k,
7 stream=False,
8)
9
10for idx, output in enumerate(outputs):
11 torchaudio.save(
12 f"se_bridge_tts_thai_zero_shot_{idx}.wav",
13 output["tts_speech"],
14 cosyvoice.sample_rate,
15 )