Spaces:
Build error
Build error
Commit
·
170f816
0
Parent(s):
Duplicate from mesolitica/ms-asr-transducer
Browse filesCo-authored-by: husein zolkepli <[email protected]>
- .gitattributes +34 -0
- README.md +13 -0
- app.py +71 -0
- audio/female.wav +3 -0
- audio/haqkiem.wav +3 -0
- audio/husein-generated.wav +3 -0
- audio/husein-zolkepli.wav +3 -0
- audio/khalil-nooh.wav +3 -0
- audio/mas-aisyah.wav +3 -0
- audio/muhyiddin-yassin.wav +3 -0
- audio/shafiqah-idayu.wav +3 -0
- packages.txt +1 -0
- requirements.txt +9 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.onnx 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
|
19 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
25 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: MS ASR TRANSDUCER
|
3 |
+
emoji: 👂🏽
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: pink
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.8.2
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: mesolitica/ms-asr-transducer
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
os.environ['CUDA_VISIBLE_DEVICES'] = ''
|
4 |
+
os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'
|
5 |
+
|
6 |
+
import malaya_speech
|
7 |
+
from malaya_speech.utils.astype import float_to_int
|
8 |
+
from pyctcdecode import build_ctcdecoder
|
9 |
+
from malaya_speech.utils.char import CTC_VOCAB
|
10 |
+
from glob import glob
|
11 |
+
import kenlm
|
12 |
+
import gradio as gr
|
13 |
+
import logging
|
14 |
+
import json
|
15 |
+
|
16 |
+
logging.basicConfig(level=logging.INFO)
|
17 |
+
|
18 |
+
SR = 16000
|
19 |
+
MODELS = {}
|
20 |
+
AVAILABLE_MODELS = malaya_speech.stt.available_transducer().index.tolist()
|
21 |
+
|
22 |
+
wavs = glob('audio/*.wav')
|
23 |
+
|
24 |
+
def load_audio_wav(filename):
|
25 |
+
print(filename)
|
26 |
+
y, sr = malaya_speech.load(filename)
|
27 |
+
return y, sr
|
28 |
+
|
29 |
+
def tts(upload, record, model):
|
30 |
+
|
31 |
+
if record:
|
32 |
+
rate, y = record
|
33 |
+
else:
|
34 |
+
y, rate = load_audio_wav(upload)
|
35 |
+
|
36 |
+
if len(y.shape) == 2:
|
37 |
+
y = y.T[0]
|
38 |
+
|
39 |
+
N = len(y)
|
40 |
+
print(y, N)
|
41 |
+
|
42 |
+
y_16k = malaya_speech.resample(y, rate, SR)
|
43 |
+
|
44 |
+
global MODELS
|
45 |
+
if model not in MODELS:
|
46 |
+
logging.info(f'{model} not in MODELS')
|
47 |
+
MODELS[model] = malaya_speech.stt.deep_transducer(model=model)
|
48 |
+
|
49 |
+
t = MODELS[model].greedy_decoder([y_16k])[0]
|
50 |
+
return t
|
51 |
+
|
52 |
+
examples = []
|
53 |
+
for f in wavs:
|
54 |
+
examples.append([f, None, 'conformer'])
|
55 |
+
|
56 |
+
demo = gr.Interface(
|
57 |
+
fn=tts,
|
58 |
+
inputs=[
|
59 |
+
gr.Audio(source='upload', label = 'upload WAV file', type='filepath'),
|
60 |
+
gr.Audio(source='microphone', label = 'or record using microphone'),
|
61 |
+
gr.components.Dropdown(label='Available models', choices=AVAILABLE_MODELS, value = 'conformer'),
|
62 |
+
],
|
63 |
+
outputs=['text'],
|
64 |
+
examples=examples,
|
65 |
+
cache_examples=False,
|
66 |
+
title='ASR TRANSDUCER from Mesolitica',
|
67 |
+
description='check out accuracy on test set at https://malaya-speech.readthedocs.io/en/latest/load-stt-transducer-model.html'
|
68 |
+
)
|
69 |
+
|
70 |
+
demo.launch(server_name='0.0.0.0')
|
71 |
+
|
audio/female.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1d7137ac0d5c84a40cecafe2b050045201b767d2fcb905acfca48616771ca279
|
3 |
+
size 425004
|
audio/haqkiem.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6c60dacdb3ca8b1a20b90355550aca9c2dcdc02f6a936d89dd1777ba1b368b30
|
3 |
+
size 363052
|
audio/husein-generated.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:437c18998a5fd5704a1897da3727b9e24035120a431f9debb0b27b7412985cd6
|
3 |
+
size 415788
|
audio/husein-zolkepli.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:849f16921b23c7eb96f8b6ee374372eac02b2743661efb0b6734289ba5dd3da8
|
3 |
+
size 993330
|
audio/khalil-nooh.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:fc75e29dccba44c946b9bd12974392c078d0b92b8c8afe3e304191c1952b5618
|
3 |
+
size 346636
|
audio/mas-aisyah.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1f67d8a307332f541208486c4d07e64c0d0d8511486ab71d82307a48e51a9e55
|
3 |
+
size 254284
|
audio/muhyiddin-yassin.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:13007efc00934883a5f5a11fea2e1ff1ba5f5b0fbd3cdf40028d3db0de318c66
|
3 |
+
size 2057738
|
audio/shafiqah-idayu.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f745c2ef94a31bc8d486bdba624a41c52c83e31992f29cea772192d800ffaf09
|
3 |
+
size 620774
|
packages.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
libsndfile1
|
requirements.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
malaya-speech
|
2 |
+
malaya
|
3 |
+
tensorflow==2.9.2
|
4 |
+
torch==1.12.1
|
5 |
+
malaya-boilerplate==0.0.23
|
6 |
+
matplotlib
|
7 |
+
transformers
|
8 |
+
pyctcdecode==0.1.0
|
9 |
+
pypi-kenlm==0.1.20210121
|