Update README.md
Browse files
README.md
CHANGED
@@ -6,5 +6,30 @@ tags:
|
|
6 |
- Thai
|
7 |
---
|
8 |
โมเดลนี้ใช้ เสียงที่บันทึกจาก Play.ht : https://play.ht/ เพื่อนำมา finetune model.
|
|
|
|
|
|
|
9 |
|
10 |
การใช้งาน :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
- Thai
|
7 |
---
|
8 |
โมเดลนี้ใช้ เสียงที่บันทึกจาก Play.ht : https://play.ht/ เพื่อนำมา finetune model.
|
9 |
+
Finetune โมเดลโค้ด GitHub : https://github.com/ylacombe/finetune-hf-vits
|
10 |
+
|
11 |
+
|
12 |
|
13 |
การใช้งาน :
|
14 |
+
```py
|
15 |
+
import torch
|
16 |
+
from transformers import VitsTokenizer, VitsModel, set_seed
|
17 |
+
import scipy
|
18 |
+
|
19 |
+
tokenizer = VitsTokenizer.from_pretrained("VIZINTZOR/MMS-TTS-THAI-MALEV1",cache_dir="./mms")
|
20 |
+
model = VitsModel.from_pretrained("VIZINTZOR/MMS-TTS-THAI-MALEV1",cache_dir="./mms")
|
21 |
+
|
22 |
+
inputs = tokenizer(text="สวัสดีครับ นี่คือเสียงพูดภาษาไทย", return_tensors="pt")
|
23 |
+
|
24 |
+
set_seed(456) # make deterministic
|
25 |
+
|
26 |
+
with torch.no_grad():
|
27 |
+
outputs = model(**inputs)
|
28 |
+
|
29 |
+
waveform = outputs.waveform[0]
|
30 |
+
|
31 |
+
# Convert PyTorch tensor to NumPy array
|
32 |
+
waveform_array = waveform.numpy()
|
33 |
+
|
34 |
+
scipy.io.wavfile.write("techno_output.wav", rate=model.config.sampling_rate, data=waveform_array)
|
35 |
+
```
|