Spaces:
Runtime error
Runtime error
mrfakename
commited on
Commit
•
0675d4f
1
Parent(s):
addff22
phonemizer max length
Browse files
app.py
CHANGED
@@ -9,6 +9,8 @@ theme = gr.themes.Base(
|
|
9 |
)
|
10 |
voicelist = ['f-us-1', 'f-us-2', 'f-us-3', 'f-us-4', 'm-us-1', 'm-us-2', 'm-us-3', 'm-us-4']
|
11 |
voices = {}
|
|
|
|
|
12 |
# todo: cache computed style, load using pickle
|
13 |
# if os.path.exists('voices.pkl'):
|
14 |
# with open('voices.pkl', 'rb') as f:
|
@@ -19,20 +21,20 @@ for v in voicelist:
|
|
19 |
def synthesize(text, voice):
|
20 |
if text.strip() == "":
|
21 |
raise gr.Error("You must enter some text")
|
22 |
-
if len(text) > 300:
|
23 |
raise gr.Error("Text must be under 300 characters")
|
24 |
v = voice.lower()
|
25 |
return (24000, styletts2importable.inference(text, voices[v], alpha=0.3, beta=0.7, diffusion_steps=7, embedding_scale=1))
|
26 |
def clsynthesize(text, voice):
|
27 |
if text.strip() == "":
|
28 |
raise gr.Error("You must enter some text")
|
29 |
-
if
|
30 |
raise gr.Error("Text must be under 300 characters")
|
31 |
return (24000, styletts2importable.inference(text, styletts2importable.compute_style(voice), alpha=0.3, beta=0.7, diffusion_steps=20, embedding_scale=1))
|
32 |
def ljsynthesize(text):
|
33 |
if text.strip() == "":
|
34 |
raise gr.Error("You must enter some text")
|
35 |
-
if
|
36 |
raise gr.Error("Text must be under 300 characters")
|
37 |
noise = torch.randn(1,1,256).to('cuda' if torch.cuda.is_available() else 'cpu')
|
38 |
return (24000, ljspeechimportable.inference(text, noise, diffusion_steps=7, embedding_scale=1))
|
|
|
9 |
)
|
10 |
voicelist = ['f-us-1', 'f-us-2', 'f-us-3', 'f-us-4', 'm-us-1', 'm-us-2', 'm-us-3', 'm-us-4']
|
11 |
voices = {}
|
12 |
+
import phonemizer
|
13 |
+
global_phonemizer = phonemizer.backend.EspeakBackend(language='en-us', preserve_punctuation=True, with_stress=True)
|
14 |
# todo: cache computed style, load using pickle
|
15 |
# if os.path.exists('voices.pkl'):
|
16 |
# with open('voices.pkl', 'rb') as f:
|
|
|
21 |
def synthesize(text, voice):
|
22 |
if text.strip() == "":
|
23 |
raise gr.Error("You must enter some text")
|
24 |
+
if len(global_phonemizer.phonemize([text])) > 300:
|
25 |
raise gr.Error("Text must be under 300 characters")
|
26 |
v = voice.lower()
|
27 |
return (24000, styletts2importable.inference(text, voices[v], alpha=0.3, beta=0.7, diffusion_steps=7, embedding_scale=1))
|
28 |
def clsynthesize(text, voice):
|
29 |
if text.strip() == "":
|
30 |
raise gr.Error("You must enter some text")
|
31 |
+
if global_phonemizer.phonemize([text]) > 300:
|
32 |
raise gr.Error("Text must be under 300 characters")
|
33 |
return (24000, styletts2importable.inference(text, styletts2importable.compute_style(voice), alpha=0.3, beta=0.7, diffusion_steps=20, embedding_scale=1))
|
34 |
def ljsynthesize(text):
|
35 |
if text.strip() == "":
|
36 |
raise gr.Error("You must enter some text")
|
37 |
+
if global_phonemizer.phonemize([text]) > 300:
|
38 |
raise gr.Error("Text must be under 300 characters")
|
39 |
noise = torch.randn(1,1,256).to('cuda' if torch.cuda.is_available() else 'cpu')
|
40 |
return (24000, ljspeechimportable.inference(text, noise, diffusion_steps=7, embedding_scale=1))
|