root commited on
Commit
f5c5225
1 Parent(s): 7019c9d

adding app and reqs

Browse files
Files changed (2) hide show
  1. app.py +32 -0
  2. requirements.txt +318 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from pathlib import Path
3
+ import nemo
4
+ import nemo.collections.asr as nemo_asr
5
+ import librosa
6
+ import soundfile as sf
7
+
8
+
9
+ base_path = str(Path(__file__).parent)
10
+
11
+ # Converting the original wav to the same sr
12
+ def convert_wav_to_16k(input_wav_path, output_file_path, sr=16000):
13
+ y, s = librosa.load(input_wav_path, sr=sr)
14
+ sf.write(output_file_path, y, s)
15
+ print(f'"{input_wav_path}" has been converted to {s}Hz')
16
+ return output_file_path
17
+
18
+ def loading_nemo_and_prediction(processed_wav):
19
+ arabic_asr = nemo_asr.models.EncDecCTCModelBPE.restore_from(restore_path="conformer_ctc_small_60e_adamw_30wtr_32wv_40wte.nemo") # loading the model from a path
20
+ prediction = arabic_asr.transcribe(paths2audio_files=[processed_wav])
21
+ return prediction
22
+
23
+ def predict(uploaded_wav):
24
+ out_path = base_path + "/converted.wav"
25
+ audio_conversion = convert_wav_to_16k(uploaded_wav, out_path)
26
+ prediction_text = loading_nemo_and_prediction(audio_conversion)
27
+ return prediction_text[0]
28
+
29
+
30
+
31
+ demo = gr.Interface(fn=predict,inputs=gr.Audio(value='str',label="Audio file", max_length=10, show_download_button=False, interactive=True, type="filepath"), outputs=gr.Text())
32
+ demo.launch(debug=True, share=True)
requirements.txt ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==2.1.0
2
+ addict==2.4.0
3
+ aiofiles==23.2.1
4
+ aiohttp==3.9.5
5
+ aiosignal==1.3.1
6
+ alabaster==0.7.16
7
+ altair==5.3.0
8
+ aniso8601==9.0.1
9
+ annotated-types==0.6.0
10
+ antlr4-python3-runtime==4.9.3
11
+ anyio==4.3.0
12
+ appdirs==1.4.4
13
+ asciitree==0.3.3
14
+ asttokens==2.4.1
15
+ async-timeout==4.0.3
16
+ attrdict==2.0.1
17
+ attrs==23.2.0
18
+ audioread==3.0.1
19
+ Babel==2.14.0
20
+ backcall==0.2.0
21
+ beautifulsoup4==4.12.3
22
+ black==19.10b0
23
+ bleach==6.1.0
24
+ boto3==1.34.92
25
+ botocore==1.34.92
26
+ braceexpand==0.1.7
27
+ Brotli @ file:///home/conda/feedstock_root/build_artifacts/brotli-split_1648883617327/work
28
+ cdifflib==1.2.6
29
+ certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1707022139797/work/certifi
30
+ cffi @ file:///croot/cffi_1700254295673/work
31
+ charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1698833585322/work
32
+ click==8.0.2
33
+ clip==0.2.0
34
+ colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1666700638685/work
35
+ comm==0.2.2
36
+ contourpy==1.2.1
37
+ cycler==0.12.1
38
+ Cython==3.0.10
39
+ cytoolz==0.12.3
40
+ datasets==2.19.0
41
+ debugpy==1.8.1
42
+ decorator==5.1.1
43
+ defusedxml==0.7.1
44
+ diffusers==0.27.2
45
+ dill==0.3.8
46
+ Distance==0.1.3
47
+ docker-pycreds==0.4.0
48
+ docopt==0.6.2
49
+ docutils==0.21.2
50
+ editdistance==0.8.1
51
+ einops==0.7.0
52
+ einops-exts==0.0.4
53
+ exceptiongroup==1.2.1
54
+ executing==2.0.1
55
+ faiss-cpu==1.8.0
56
+ fastapi==0.110.3
57
+ fasteners==0.19
58
+ fastjsonschema==2.19.1
59
+ fasttext==0.9.2
60
+ ffmpy==0.3.2
61
+ filelock==3.13.4
62
+ Flask==2.2.5
63
+ Flask-RESTful==0.3.10
64
+ fonttools==4.51.0
65
+ frozenlist==1.4.1
66
+ fsspec @ file:///home/conda/feedstock_root/build_artifacts/fsspec_1710808267764/work
67
+ ftfy==6.2.0
68
+ future==1.0.0
69
+ g2p-en==2.1.0
70
+ gdown==5.1.0
71
+ gitdb==4.0.11
72
+ GitPython==3.1.43
73
+ google==3.0.0
74
+ gradio==4.28.3
75
+ gradio_client==0.16.0
76
+ grpcio==1.62.2
77
+ h11==0.14.0
78
+ h5py==3.11.0
79
+ httpcore==1.0.5
80
+ httpx==0.27.0
81
+ huggingface-hub==0.22.2
82
+ hydra-core==1.3.2
83
+ idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1713279365350/work
84
+ ijson==3.2.3
85
+ imageio==2.34.1
86
+ imagesize==1.4.1
87
+ importlib_metadata==7.1.0
88
+ importlib_resources==6.4.0
89
+ inflect==7.2.1
90
+ iniconfig==2.0.0
91
+ intervaltree==3.1.0
92
+ ipykernel==6.29.4
93
+ ipython==8.12.3
94
+ ipywidgets==8.1.2
95
+ isort==5.13.2
96
+ itsdangerous==2.2.0
97
+ jedi==0.19.1
98
+ jieba==0.42.1
99
+ Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1704966972576/work
100
+ jiwer==2.5.2
101
+ jmespath==1.0.1
102
+ joblib==1.4.0
103
+ jsonschema==4.21.1
104
+ jsonschema-specifications==2023.12.1
105
+ jupyter_client==8.6.1
106
+ jupyter_core==5.7.2
107
+ jupyterlab_pygments==0.3.0
108
+ jupyterlab_widgets==3.0.10
109
+ kaldi-python-io==1.2.2
110
+ kaldiio==2.18.0
111
+ kenlm @ https://github.com/kpu/kenlm/archive/master.zip#sha256=9aca61fb9df045ad86203e04b750e787403dfe4d7b86b3e99173a29f5d12d3c6
112
+ kiwisolver==1.4.5
113
+ kornia==0.7.2
114
+ kornia_rs==0.1.3
115
+ latexcodec==3.0.0
116
+ lazy_loader==0.4
117
+ Levenshtein==0.22.0
118
+ lhotse==1.22.0
119
+ librosa==0.10.1
120
+ lightning @ file:///home/conda/feedstock_root/build_artifacts/lightning_1713989954271/work
121
+ lightning-utilities @ file:///home/conda/feedstock_root/build_artifacts/lightning-utilities_1711597355069/work
122
+ lilcom==1.7
123
+ llvmlite==0.42.0
124
+ loguru==0.7.2
125
+ lxml==5.2.1
126
+ Markdown==3.6
127
+ markdown-it-py==3.0.0
128
+ markdown2==2.4.13
129
+ MarkupSafe @ file:///croot/markupsafe_1704205993651/work
130
+ marshmallow==3.21.1
131
+ matplotlib==3.8.4
132
+ matplotlib-inline==0.1.7
133
+ mdurl==0.1.2
134
+ megatron_core==0.5.0
135
+ mistune==3.0.2
136
+ mkl-fft @ file:///croot/mkl_fft_1695058164594/work
137
+ mkl-random @ file:///croot/mkl_random_1695059800811/work
138
+ mkl-service==2.4.0
139
+ more-itertools==10.2.0
140
+ mpmath @ file:///home/conda/feedstock_root/build_artifacts/mpmath_1678228039184/work
141
+ msgpack==1.0.8
142
+ multidict==6.0.5
143
+ multiprocess==0.70.16
144
+ nbclient==0.10.0
145
+ nbconvert==7.16.4
146
+ nbformat==5.10.4
147
+ nemo_text_processing==0.3.0rc0
148
+ nemo_toolkit==1.23.0
149
+ nerfacc==0.5.3
150
+ nest-asyncio==1.6.0
151
+ networkx @ file:///home/conda/feedstock_root/build_artifacts/networkx_1712540363324/work
152
+ nltk==3.8.1
153
+ numba==0.59.1
154
+ numcodecs==0.12.1
155
+ numpy @ file:///croot/numpy_and_numpy_base_1708638617955/work/dist/numpy-1.26.4-cp310-cp310-linux_x86_64.whl#sha256=d8cd837ed43e87f77e6efaa08e8de927ca030a1c9c5d04624432d6fb9a74a5ee
156
+ nvidia-cublas-cu12==12.1.3.1
157
+ nvidia-cuda-cupti-cu12==12.1.105
158
+ nvidia-cuda-nvrtc-cu12==12.1.105
159
+ nvidia-cuda-runtime-cu12==12.1.105
160
+ nvidia-cudnn-cu12==8.9.2.26
161
+ nvidia-cufft-cu12==11.0.2.54
162
+ nvidia-curand-cu12==10.3.2.106
163
+ nvidia-cusolver-cu12==11.4.5.107
164
+ nvidia-cusparse-cu12==12.1.0.106
165
+ nvidia-nccl-cu12==2.20.5
166
+ nvidia-nvjitlink-cu12==12.4.127
167
+ nvidia-nvtx-cu12==12.1.105
168
+ omegaconf==2.3.0
169
+ onnx==1.16.0
170
+ open-clip-torch==2.24.0
171
+ OpenCC==1.1.6
172
+ orjson==3.10.1
173
+ packaging==24.0
174
+ pandas==2.2.2
175
+ pandocfilters==1.5.1
176
+ pangu==4.0.6.1
177
+ parameterized==0.9.0
178
+ parso==0.8.4
179
+ pathspec==0.12.1
180
+ pexpect==4.9.0
181
+ pickleshare==0.7.5
182
+ pillow==10.3.0
183
+ pipreqs==0.5.0
184
+ plac==1.4.3
185
+ platformdirs==4.2.1
186
+ pluggy==1.5.0
187
+ pooch==1.8.1
188
+ portalocker==2.8.2
189
+ progress==1.6
190
+ prompt-toolkit==3.0.43
191
+ protobuf==4.25.3
192
+ psutil==5.9.8
193
+ ptyprocess==0.7.0
194
+ pure-eval==0.2.2
195
+ pyannote.core==5.0.0
196
+ pyannote.database==5.1.0
197
+ pyannote.metrics==3.2.1
198
+ PyArabic==0.6.15
199
+ pyarrow==16.0.0
200
+ pyarrow-hotfix==0.6
201
+ PyAudio==0.2.14
202
+ pybind11==2.12.0
203
+ pybtex==0.24.0
204
+ pybtex-docutils==1.0.3
205
+ pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1711811537435/work
206
+ pydantic==2.7.1
207
+ pydantic_core==2.18.2
208
+ pydub==0.25.1
209
+ Pygments==2.17.2
210
+ pyloudnorm==0.1.1
211
+ PyMCubes==0.1.4
212
+ pynini==2.1.5
213
+ pyparsing==3.1.2
214
+ pypinyin==0.51.0
215
+ pypinyin-dict==0.8.0
216
+ PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1661604839144/work
217
+ pytest==8.1.1
218
+ pytest-runner==6.0.1
219
+ python-dateutil==2.9.0.post0
220
+ python-multipart==0.0.9
221
+ pytorch-lightning==2.0.7
222
+ pytz==2024.1
223
+ PyYAML==6.0.1
224
+ pyzmq==26.0.2
225
+ rapidfuzz==2.13.7
226
+ referencing==0.35.0
227
+ regex==2024.4.16
228
+ requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1684774241324/work
229
+ resampy==0.4.3
230
+ rich==13.7.1
231
+ rouge-score==0.1.2
232
+ rpds-py==0.18.0
233
+ ruamel.yaml==0.18.6
234
+ ruamel.yaml.clib==0.2.8
235
+ ruff==0.4.2
236
+ s3transfer==0.10.1
237
+ sacrebleu==2.4.2
238
+ sacremoses==0.1.1
239
+ safetensors==0.4.3
240
+ scikit-learn==1.4.2
241
+ scipy==1.13.0
242
+ semantic-version==2.10.0
243
+ sentence-transformers==2.7.0
244
+ sentencepiece==0.2.0
245
+ sentry-sdk==2.0.0
246
+ setproctitle==1.3.3
247
+ shellingham==1.5.4
248
+ six==1.16.0
249
+ smmap==5.0.1
250
+ sniffio==1.3.1
251
+ snowballstemmer==2.2.0
252
+ sortedcontainers==2.4.0
253
+ soundfile==0.12.1
254
+ soupsieve==2.5
255
+ sox==1.5.0
256
+ soxr==0.3.7
257
+ Sphinx==7.3.7
258
+ sphinxcontrib-applehelp==1.0.8
259
+ sphinxcontrib-bibtex==2.6.2
260
+ sphinxcontrib-devhelp==1.0.6
261
+ sphinxcontrib-htmlhelp==2.0.5
262
+ sphinxcontrib-jsmath==1.0.1
263
+ sphinxcontrib-qthelp==1.0.7
264
+ sphinxcontrib-serializinghtml==1.1.10
265
+ stack-data==0.6.3
266
+ starlette==0.37.2
267
+ sympy @ file:///home/conda/feedstock_root/build_artifacts/sympy_1684180539862/work
268
+ tabulate==0.9.0
269
+ taming-transformers==0.0.1
270
+ tensorboard==2.16.2
271
+ tensorboard-data-server==0.7.2
272
+ tensorstore==0.1.45
273
+ termcolor==2.4.0
274
+ text-unidecode==1.3
275
+ textdistance==4.6.2
276
+ texterrors==0.4.4
277
+ threadpoolctl==3.4.0
278
+ timm==0.9.16
279
+ tinycss2==1.3.0
280
+ tokenizers==0.19.1
281
+ toml==0.10.2
282
+ tomli==2.0.1
283
+ tomlkit==0.12.0
284
+ toolz==0.12.1
285
+ torch==2.3.0
286
+ torchdiffeq==0.2.3
287
+ torchmetrics @ file:///home/conda/feedstock_root/build_artifacts/torchmetrics_1710773712978/work
288
+ torchsde==0.2.6
289
+ torchvision==0.18.0
290
+ tornado==6.4
291
+ tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1707598593068/work
292
+ traitlets==5.14.3
293
+ trampoline==0.1.2
294
+ transformers==4.40.1
295
+ trimesh==4.3.1
296
+ triton==2.3.0
297
+ typed-ast==1.5.5
298
+ typeguard==4.2.1
299
+ typer==0.12.3
300
+ typing_extensions==4.11.0
301
+ tzdata==2024.1
302
+ urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1708239446578/work
303
+ uvicorn==0.29.0
304
+ wandb==0.16.6
305
+ wcwidth==0.2.13
306
+ webdataset==0.1.62
307
+ webencodings==0.5.1
308
+ websockets==11.0.3
309
+ Werkzeug==3.0.2
310
+ wget==3.2
311
+ widgetsnbextension==4.0.10
312
+ wrapt==1.16.0
313
+ xxhash==3.4.1
314
+ yarg==0.1.9
315
+ yarl==1.9.4
316
+ youtokentome==1.0.6
317
+ zarr==2.17.2
318
+ zipp==3.18.1