Spaces:
Running
Running
thewh1teagle
commited on
Commit
路
47d86bc
1
Parent(s):
55838b8
init
Browse files- .gitattributes +2 -1
- app.py +66 -0
- israwave.onnx +3 -0
- nakdimon.onnx +3 -0
- requirements.txt +2 -0
.gitattributes
CHANGED
@@ -13,7 +13,6 @@
|
|
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
|
@@ -33,3 +32,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* 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 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
17 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
18 |
*.pb 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
|
35 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
36 |
+
espeak-ng-data/ filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
pip install -r requirements.txt
|
3 |
+
wget https://github.com/thewh1teagle/israwave/releases/download/v0.1.0/israwave.onnx
|
4 |
+
wget https://github.com/thewh1teagle/israwave/releases/download/v0.1.0/nakdimon.onnx
|
5 |
+
wget https://github.com/thewh1teagle/israwave/releases/download/v0.1.0/espeak-ng-data.tar.gz
|
6 |
+
tar xf espeak-ng-data.tar.gz
|
7 |
+
|
8 |
+
python3 app.py
|
9 |
+
"""
|
10 |
+
|
11 |
+
import gradio as gr
|
12 |
+
from israwave import IsraWave
|
13 |
+
from nakdimon_ort import Nakdimon
|
14 |
+
from israwave.segment import SegmentExtractor
|
15 |
+
import numpy as np
|
16 |
+
import soundfile as sf
|
17 |
+
import io
|
18 |
+
|
19 |
+
segment_extractor = SegmentExtractor()
|
20 |
+
speech_model = IsraWave('israwave.onnx', 'espeak-ng-data')
|
21 |
+
niqqud_model = Nakdimon('nakdimon.onnx')
|
22 |
+
|
23 |
+
def create_audio(text: str, rate, pitch, energy):
|
24 |
+
text = niqqud_model.compute(text)
|
25 |
+
waveforms = []
|
26 |
+
for segment in segment_extractor.extract_segments(text):
|
27 |
+
waveform = speech_model.create(segment.text, rate=rate, pitch=pitch, energy=energy)
|
28 |
+
waveforms.append(waveform.samples)
|
29 |
+
silence = segment.create_pause(waveform.sample_rate)
|
30 |
+
waveforms.append(silence)
|
31 |
+
return np.concatenate(waveforms), speech_model.sample_rate
|
32 |
+
|
33 |
+
def create(text, rate, pitch, energy):
|
34 |
+
audio, sample_rate = create_audio(text, rate, pitch, energy)
|
35 |
+
|
36 |
+
# Convert numpy array to WAV format in memory using soundfile
|
37 |
+
with io.BytesIO() as buf:
|
38 |
+
sf.write(buf, audio, sample_rate, format='WAV')
|
39 |
+
buf.seek(0)
|
40 |
+
return buf.read()
|
41 |
+
|
42 |
+
|
43 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
44 |
+
# Centered title
|
45 |
+
gr.Markdown("<h1 style='text-align: center;'>IsraWave</h1>")
|
46 |
+
|
47 |
+
# Use Textarea with RTL direction
|
48 |
+
text = gr.TextArea(label="text", lines=4, elem_id="rtl_textarea", value='讝讛 讻讬祝 诇讛讝诪讬谉 讚讘专讬诐 讘讗讬谞讟专谞讟, 讗讘诇 讛专讘讛 驻讞讜转 讻讬祝 诇讞讻讜转 讜诇讞讻讜转 注讚 砖讛诐 讬讙讬注讜 讗诇讬谞讜. 讗讝 诪讛 讘注爪诐 注讜讘专 注诇 讛讞讘讬诇讜转 讘讚专讱 讛讗专讜讻讛 注讚 诇讘讬转 砖诇谞讜? 讜讛讗诐 讗驻砖专 诇讙专讜诐 诇讻讱 砖讛谉 讬讙讬注讜 诪讛专 讬讜转专? ')
|
49 |
+
rate = gr.Slider(0.1, 10, label="rate", value=1.0)
|
50 |
+
pitch = gr.Slider(0.1, 10, label="pitch", value=1.0)
|
51 |
+
energy = gr.Slider(0.1, 10, label="energy", value=1.0)
|
52 |
+
|
53 |
+
button = gr.Button("Create", elem_id="create_button")
|
54 |
+
output = gr.Audio()
|
55 |
+
|
56 |
+
button.click(fn=create, inputs=[text, rate, pitch, energy], outputs=output)
|
57 |
+
|
58 |
+
# Custom CSS for RTL direction
|
59 |
+
demo.css = """
|
60 |
+
#rtl_textarea textarea {
|
61 |
+
direction: rtl;
|
62 |
+
font-size: 20px;
|
63 |
+
}
|
64 |
+
"""
|
65 |
+
|
66 |
+
demo.launch()
|
israwave.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b47686804d113c0fe37ec9d46b2039ab4fd26a9cda90eb9ebe9f971622207f4f
|
3 |
+
size 71587050
|
nakdimon.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9ff491dcc7d66392019d427a98b97d5de10c0d721628ae740858174ae22b190e
|
3 |
+
size 21312753
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
israwave
|