Spaces:
Sleeping
Sleeping
mrfakename
commited on
Commit
•
a520615
1
Parent(s):
8b5626c
Load voices from pickle
Browse files
app.py
CHANGED
@@ -2,14 +2,19 @@ import gradio as gr
|
|
2 |
import styletts2importable
|
3 |
import ljspeechimportable
|
4 |
import torch
|
|
|
|
|
5 |
theme = gr.themes.Base(
|
6 |
font=[gr.themes.GoogleFont('Libre Franklin'), gr.themes.GoogleFont('Public Sans'), 'system-ui', 'sans-serif'],
|
7 |
)
|
8 |
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']
|
9 |
voices = {}
|
10 |
# todo: cache computed style, load using pickle
|
11 |
-
|
12 |
-
voices
|
|
|
|
|
|
|
13 |
def synthesize(text, voice):
|
14 |
if text.strip() == "":
|
15 |
raise gr.Error("You must enter some text")
|
|
|
2 |
import styletts2importable
|
3 |
import ljspeechimportable
|
4 |
import torch
|
5 |
+
import os
|
6 |
+
import pickle
|
7 |
theme = gr.themes.Base(
|
8 |
font=[gr.themes.GoogleFont('Libre Franklin'), gr.themes.GoogleFont('Public Sans'), 'system-ui', 'sans-serif'],
|
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', 'rb') as f:
|
14 |
+
voices = pickle.load(f)
|
15 |
+
else:
|
16 |
+
for v in voicelist:
|
17 |
+
voices[v] = styletts2importable.compute_style(f'voices/{v}.wav')
|
18 |
def synthesize(text, voice):
|
19 |
if text.strip() == "":
|
20 |
raise gr.Error("You must enter some text")
|