Spaces:
Running
Running
thewh1teagle
commited on
Commit
โข
787fd4f
1
Parent(s):
9cd4361
sync ui
Browse files- app.py +20 -15
- requirements.txt +2 -2
app.py
CHANGED
@@ -10,16 +10,17 @@ python3 app.py
|
|
10 |
|
11 |
import gradio as gr
|
12 |
from israwave import IsraWave
|
13 |
-
from israwave.helpers import text_has_niqqud
|
14 |
from nakdimon_ort import Nakdimon
|
15 |
from israwave.segment import SegmentExtractor
|
16 |
import numpy as np
|
17 |
|
18 |
segment_extractor = SegmentExtractor()
|
19 |
-
speech_model = IsraWave(
|
20 |
-
niqqud_model = Nakdimon(
|
21 |
|
22 |
-
|
|
|
23 |
if not text_has_niqqud(text):
|
24 |
text = niqqud_model.compute(text)
|
25 |
waveforms = []
|
@@ -28,11 +29,10 @@ def create_audio(text: str, rate, pitch, energy):
|
|
28 |
waveforms.append(waveform.samples)
|
29 |
silence = segment.create_pause(waveform.sample_rate)
|
30 |
waveforms.append(silence)
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
return (sample_rate, samples)
|
36 |
|
37 |
|
38 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
@@ -41,16 +41,21 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
41 |
<h1 style='text-align: center;'>IsraWave</h1>
|
42 |
<p style='text-align: center;'>Text-to-Speech model for Hebrew</p>
|
43 |
""")
|
44 |
-
|
45 |
# Use Textarea with RTL direction
|
46 |
-
text = gr.TextArea(
|
|
|
|
|
|
|
|
|
|
|
47 |
rate = gr.Slider(0.1, 10, label="rate", value=1.0)
|
48 |
pitch = gr.Slider(0.1, 10, label="pitch", value=1.0)
|
49 |
energy = gr.Slider(0.1, 10, label="energy", value=1.0)
|
50 |
|
51 |
-
button = gr.Button("Create"
|
52 |
output = gr.Audio()
|
53 |
-
|
54 |
button.click(fn=create, inputs=[text, rate, pitch, energy], outputs=output)
|
55 |
|
56 |
# Custom CSS for RTL direction
|
@@ -60,9 +65,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
60 |
font-size: 20px;
|
61 |
}
|
62 |
"""
|
63 |
-
|
64 |
gr.Markdown("""
|
65 |
<p style='text-align: center;'><a href='https://github.com/thewh1teagle/israwave' target='_blank'>Israwave on Github</a></p>
|
66 |
""")
|
67 |
|
68 |
-
demo.launch()
|
|
|
10 |
|
11 |
import gradio as gr
|
12 |
from israwave import IsraWave
|
13 |
+
from israwave.helpers import text_has_niqqud, float_to_int16
|
14 |
from nakdimon_ort import Nakdimon
|
15 |
from israwave.segment import SegmentExtractor
|
16 |
import numpy as np
|
17 |
|
18 |
segment_extractor = SegmentExtractor()
|
19 |
+
speech_model = IsraWave("israwave.onnx", "espeak-ng-data")
|
20 |
+
niqqud_model = Nakdimon("nakdimon.onnx")
|
21 |
|
22 |
+
|
23 |
+
def create(text: str, rate, pitch, energy):
|
24 |
if not text_has_niqqud(text):
|
25 |
text = niqqud_model.compute(text)
|
26 |
waveforms = []
|
|
|
29 |
waveforms.append(waveform.samples)
|
30 |
silence = segment.create_pause(waveform.sample_rate)
|
31 |
waveforms.append(silence)
|
32 |
+
waveform = np.concatenate(waveforms)
|
33 |
+
# Gradio expect int16
|
34 |
+
waveform = float_to_int16(waveform)
|
35 |
+
return speech_model.sample_rate, waveform
|
|
|
36 |
|
37 |
|
38 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
41 |
<h1 style='text-align: center;'>IsraWave</h1>
|
42 |
<p style='text-align: center;'>Text-to-Speech model for Hebrew</p>
|
43 |
""")
|
44 |
+
|
45 |
# Use Textarea with RTL direction
|
46 |
+
text = gr.TextArea(
|
47 |
+
label="text",
|
48 |
+
lines=4,
|
49 |
+
elem_id="rtl_textarea",
|
50 |
+
value="ืื ืืืฃ ืืืืืื ืืืจืื ืืืื ืืจื ื, ืืื ืืจืื ืคืืืช ืืืฃ ืืืืืช ืืืืืืช ืขื ืฉืื ืืืืขื ืืืื ื. ืื ืื ืืขืฆื ืขืืืจ ืขื ืืืืืืืช ืืืจื ืืืจืืื ืขื ืืืืช ืฉืื ื? ืืืื ืืคืฉืจ ืืืจืื ืืื ืฉืื ืืืืขื ืืืจ ืืืชืจ? ",
|
51 |
+
)
|
52 |
rate = gr.Slider(0.1, 10, label="rate", value=1.0)
|
53 |
pitch = gr.Slider(0.1, 10, label="pitch", value=1.0)
|
54 |
energy = gr.Slider(0.1, 10, label="energy", value=1.0)
|
55 |
|
56 |
+
button = gr.Button("Create")
|
57 |
output = gr.Audio()
|
58 |
+
|
59 |
button.click(fn=create, inputs=[text, rate, pitch, energy], outputs=output)
|
60 |
|
61 |
# Custom CSS for RTL direction
|
|
|
65 |
font-size: 20px;
|
66 |
}
|
67 |
"""
|
68 |
+
|
69 |
gr.Markdown("""
|
70 |
<p style='text-align: center;'><a href='https://github.com/thewh1teagle/israwave' target='_blank'>Israwave on Github</a></p>
|
71 |
""")
|
72 |
|
73 |
+
demo.launch()
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
gradio
|
2 |
-
israwave
|
|
|
1 |
+
gradio==4.44.0
|
2 |
+
israwave==0.1.5
|