Update README.md
Browse files
README.md
CHANGED
@@ -1,6 +1,66 @@
|
|
1 |
---
|
2 |
-
license: cc-by-nc-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
license: cc-by-nc-nd-4.0
|
3 |
+
---
|
4 |
+
|
5 |
+
|
6 |
+
# Spark TTS Vietnamese
|
7 |
+
|
8 |
+
Spark-TTS is an advanced text-to-speech system that uses the power of large language models (LLM) for highly accurate and natural-sounding voice synthesis. It is designed to be efficient, flexible, and powerful for both research and production use. This model is trained from [viVoice](https://huggingface.co/datasets/thinhlpg/viVoice) vietnamese dataset
|
9 |
+
|
10 |
+
# Usage
|
11 |
+
|
12 |
+
First, install the required packages:
|
13 |
+
|
14 |
+
```
|
15 |
+
pip install --upgrade transformers accelerate
|
16 |
+
```
|
17 |
+
|
18 |
+
## Text-to-Speech
|
19 |
+
We have customized the code so you can inference using the huggingface transformer library without installing anything else.
|
20 |
+
|
21 |
+
```python
|
22 |
+
from transformers import AutoProcessor, AutoModel, AutoTokenizer
|
23 |
+
import soundfile as sf
|
24 |
+
import torch
|
25 |
+
import numpy as np
|
26 |
+
|
27 |
+
device = "cuda"
|
28 |
+
model_id = "DragonLineageAI/Vi-Spark-TTS-0.5B-v2"
|
29 |
+
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
|
30 |
+
model = AutoModel.from_pretrained(model_id, trust_remote_code=True).eval()
|
31 |
+
processor.model = model
|
32 |
+
|
33 |
+
prompt_audio_path = "path_to_audio_path" # CHANGE TO YOUR ACTUAL PATH
|
34 |
+
prompt_transcript = "text corresponding to prompt audio" # Optional
|
35 |
+
text_input = "xin chào mọi người chúng tôi là Nguyễn Công Tú Anh và Chu Văn An đến từ dragonlineageai"
|
36 |
+
|
37 |
+
inputs = processor(
|
38 |
+
text=text_input.lower(),
|
39 |
+
prompt_speech_path=prompt_audio_path,
|
40 |
+
prompt_text=None,
|
41 |
+
return_tensors="pt"
|
42 |
+
).to(device)
|
43 |
+
global_tokens_prompt = inputs.pop("global_token_ids_prompt", None)
|
44 |
+
|
45 |
+
with torch.no_grad():
|
46 |
+
output_ids = model.generate(
|
47 |
+
**inputs,
|
48 |
+
max_new_tokens=3000,
|
49 |
+
do_sample=True,
|
50 |
+
temperature=0.8,
|
51 |
+
top_k=50,
|
52 |
+
top_p=0.95,
|
53 |
+
eos_token_id=processor.tokenizer.eos_token_id,
|
54 |
+
pad_token_id=processor.tokenizer.pad_token_id
|
55 |
+
)
|
56 |
+
|
57 |
+
output_clone = processor.decode(
|
58 |
+
generated_ids=output_ids,
|
59 |
+
global_token_ids_prompt=global_tokens_prompt,
|
60 |
+
input_ids_len=inputs["input_ids"].shape[-1]
|
61 |
+
)
|
62 |
+
|
63 |
+
sf.write("output_cloned.wav", output_clone["audio"], output_clone["sampling_rate"])
|
64 |
+
```
|
65 |
+
## Fintune
|
66 |
+
You can finetune this model with any dataset to improve quality or train on a new language. [training code](https://github.com/tuanh123789/Spark-TTS-finetune)
|