Commit
•
9896d2b
0
Parent(s):
Duplicate from jhlfrfufyfn/bel-tts
Browse filesCo-authored-by: Nik <[email protected]>
- .gitattributes +34 -0
- README.md +14 -0
- app.py +87 -0
- requirements.txt +2 -0
- scale_stats.npy +3 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Bel Tts
|
3 |
+
emoji: 📚
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: gray
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.13.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
+
duplicated_from: jhlfrfufyfn/bel-tts
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from TTS.utils.synthesizer import Synthesizer
|
2 |
+
from huggingface_hub import hf_hub_download
|
3 |
+
import gradio as gr
|
4 |
+
import tempfile
|
5 |
+
import os
|
6 |
+
|
7 |
+
REPO_ID = "jhlfrfufyfn/bel-tts"
|
8 |
+
|
9 |
+
my_title = "Беларускі тэкст-у-маўленне"
|
10 |
+
my_description = "Беларускамоўная мадэль для агучвання тэксту (травень 2023)."
|
11 |
+
|
12 |
+
be_text = "Гепарды жывуць у адкрытых і прасторных месцах, дзе ёсць шмат здабычы."
|
13 |
+
|
14 |
+
my_inputs = [
|
15 |
+
gr.inputs.Textbox(lines=5, label="Input Text", default=be_text),
|
16 |
+
]
|
17 |
+
|
18 |
+
my_outputs = gr.outputs.Audio(type="file", label="Output Audio")
|
19 |
+
|
20 |
+
def belarusify_russian_text(text: str):
|
21 |
+
text = text.replace("и", "і")
|
22 |
+
text = text.replace("іу", "іў")
|
23 |
+
text = text.replace("оу", "оў")
|
24 |
+
text = text.replace("ау", "аў")
|
25 |
+
text = text.replace("ыу", "ыў")
|
26 |
+
text = text.replace("уу", "уў")
|
27 |
+
text = text.replace("юу", "юў")
|
28 |
+
text = text.replace("еу", "еў")
|
29 |
+
text = text.replace("ёу", "ёў")
|
30 |
+
text = text.replace("щ", "шч")
|
31 |
+
return text
|
32 |
+
|
33 |
+
import requests
|
34 |
+
def tts(text: str):
|
35 |
+
print("Original text: ", text)
|
36 |
+
text = belarusify_russian_text(text)
|
37 |
+
print("Belarusified text: ", text)
|
38 |
+
# Sending a request to the fonemizer
|
39 |
+
headers = {'Content-Type': 'text/plain; charset=utf-8'} # Specify the charset as UTF-8
|
40 |
+
|
41 |
+
response = requests.post("http://fonemizer.nikuchin.fun/processText",
|
42 |
+
data=text.encode('utf-8'), # Encode the text as UTF-8
|
43 |
+
headers=headers)
|
44 |
+
|
45 |
+
if response.status_code != 200:
|
46 |
+
raise Exception(f"Request to fonemizer failed with status code {response.status_code}")
|
47 |
+
print(response.content)
|
48 |
+
print(response.headers.get('Content-Type'))
|
49 |
+
text = response.text
|
50 |
+
best_model_path = hf_hub_download(repo_id=REPO_ID, filename="model.pth")
|
51 |
+
config_path = hf_hub_download(repo_id=REPO_ID, filename="config.json")
|
52 |
+
vocoder_path = hf_hub_download(repo_id=REPO_ID, filename="vocoder.pth")
|
53 |
+
scale_stats_path = hf_hub_download(repo_id=REPO_ID, filename="scale_stats.npy")
|
54 |
+
vocoder_config_path = hf_hub_download(repo_id=REPO_ID, filename="vocoder_config.json")
|
55 |
+
|
56 |
+
# init synthesizer
|
57 |
+
synthesizer = Synthesizer(
|
58 |
+
best_model_path,
|
59 |
+
config_path,
|
60 |
+
None,
|
61 |
+
None,
|
62 |
+
vocoder_path,
|
63 |
+
vocoder_config_path,
|
64 |
+
None,
|
65 |
+
None,
|
66 |
+
False
|
67 |
+
)
|
68 |
+
|
69 |
+
# create audio file
|
70 |
+
wavs = synthesizer.tts(text)
|
71 |
+
with tempfile.NamedTemporaryFile(suffix = ".wav", delete = False) as fp:
|
72 |
+
synthesizer.save_wav(wavs, fp)
|
73 |
+
return fp.name
|
74 |
+
|
75 |
+
print("CWD IS ", os.getcwd())
|
76 |
+
print("LIST IS", os.listdir())
|
77 |
+
iface = gr.Interface(
|
78 |
+
fn=tts,
|
79 |
+
inputs=my_inputs,
|
80 |
+
outputs=my_outputs,
|
81 |
+
title=my_title,
|
82 |
+
description = my_description,
|
83 |
+
article = "",
|
84 |
+
examples = "",
|
85 |
+
allow_flagging=False
|
86 |
+
)
|
87 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
TTS==0.13.3
|
scale_stats.npy
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:04b9cf60d8d5fc0a5efe55763250ccaa87e4e078ae8927508cd1b4b7ad8ccca3
|
3 |
+
size 10790
|