Spaces:
Running
Running
jhlfrfufyfn
commited on
Commit
•
75ccc38
1
Parent(s):
2845cc1
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,8 @@ 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 |
|
@@ -11,12 +12,6 @@ my_description = "Беларускамоўная мадэль для агучв
|
|
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("іу", "іў")
|
@@ -29,13 +24,12 @@ def belarusify_russian_text(text: str):
|
|
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 |
-
|
39 |
headers = {'Content-Type': 'text/plain; charset=utf-8'} # Specify the charset as UTF-8
|
40 |
|
41 |
response = requests.post("http://83.229.87.101/processText",
|
@@ -68,20 +62,22 @@ def tts(text: str):
|
|
68 |
|
69 |
# create audio file
|
70 |
wavs = synthesizer.tts(text)
|
71 |
-
with tempfile.NamedTemporaryFile(suffix
|
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=
|
80 |
-
outputs=
|
81 |
title=my_title,
|
82 |
-
description
|
83 |
-
article
|
84 |
-
examples
|
85 |
-
allow_flagging=
|
86 |
)
|
87 |
-
|
|
|
|
2 |
from huggingface_hub import hf_hub_download
|
3 |
import gradio as gr
|
4 |
import tempfile
|
5 |
+
import os
|
6 |
+
import requests
|
7 |
|
8 |
REPO_ID = "jhlfrfufyfn/bel-tts"
|
9 |
|
|
|
12 |
|
13 |
be_text = "Гепарды жывуць у адкрытых і прасторных месцах, дзе ёсць шмат здабычы."
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
def belarusify_russian_text(text: str):
|
16 |
text = text.replace("и", "і")
|
17 |
text = text.replace("іу", "іў")
|
|
|
24 |
text = text.replace("ёу", "ёў")
|
25 |
text = text.replace("щ", "шч")
|
26 |
return text
|
27 |
+
|
|
|
28 |
def tts(text: str):
|
29 |
print("Original text: ", text)
|
30 |
text = belarusify_russian_text(text)
|
31 |
print("Belarusified text: ", text)
|
32 |
+
# Sending a request to the fonemizer
|
33 |
headers = {'Content-Type': 'text/plain; charset=utf-8'} # Specify the charset as UTF-8
|
34 |
|
35 |
response = requests.post("http://83.229.87.101/processText",
|
|
|
62 |
|
63 |
# create audio file
|
64 |
wavs = synthesizer.tts(text)
|
65 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
66 |
+
synthesizer.save_wav(wavs, fp)
|
67 |
return fp.name
|
68 |
|
69 |
print("CWD IS ", os.getcwd())
|
70 |
print("LIST IS", os.listdir())
|
71 |
+
|
72 |
iface = gr.Interface(
|
73 |
fn=tts,
|
74 |
+
inputs=gr.Textbox(lines=5, label="Input Text", value=be_text),
|
75 |
+
outputs=gr.Audio(type="file", label="Output Audio"),
|
76 |
title=my_title,
|
77 |
+
description=my_description,
|
78 |
+
article="",
|
79 |
+
examples=None,
|
80 |
+
allow_flagging="never"
|
81 |
)
|
82 |
+
|
83 |
+
iface.launch()
|