Spaces:
Sleeping
Sleeping
HarshitJoshi
commited on
Commit
Β·
8389164
1
Parent(s):
2bd246b
1st Commit
Browse files- .gitattributes +0 -35
- README.md +2 -2
- app.py +49 -0
- examples/example1.mp3 +0 -0
- examples/example2.mp3 +0 -0
- examples/example3.mp3 +0 -0
- requirements.txt +3 -0
.gitattributes
DELETED
@@ -1,35 +0,0 @@
|
|
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 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model 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 |
-
*.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
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
title: ASR Hindi
|
3 |
emoji: π
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.38.1
|
8 |
app_file: app.py
|
|
|
1 |
---
|
2 |
title: ASR Hindi
|
3 |
emoji: π
|
4 |
+
colorFrom: yellow
|
5 |
+
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.38.1
|
8 |
app_file: app.py
|
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
import os
|
4 |
+
|
5 |
+
model_id = "HarshitJoshi/whisper-small-Hindi"
|
6 |
+
pipe = pipeline("automatic-speech-recognition", model=model_id)
|
7 |
+
|
8 |
+
def transcribe_speech(filepath):
|
9 |
+
output = pipe(
|
10 |
+
filepath,
|
11 |
+
max_new_tokens=256,
|
12 |
+
generate_kwargs={
|
13 |
+
"task": "transcribe",
|
14 |
+
"language": "hindi",
|
15 |
+
},
|
16 |
+
chunk_length_s=30,
|
17 |
+
batch_size=8,
|
18 |
+
)
|
19 |
+
return output["text"]
|
20 |
+
|
21 |
+
example_folder = "./examples"
|
22 |
+
example_files = [f for f in os.listdir(example_folder) if f.endswith('.wav') or f.endswith('.mp3')]
|
23 |
+
|
24 |
+
demo = gr.Blocks()
|
25 |
+
|
26 |
+
mic_transcribe = gr.Interface(
|
27 |
+
fn=transcribe_speech,
|
28 |
+
inputs=gr.Audio(source="microphone", type="filepath"),
|
29 |
+
outputs=gr.Textbox(),
|
30 |
+
)
|
31 |
+
|
32 |
+
file_transcribe = gr.Interface(
|
33 |
+
fn=transcribe_speech,
|
34 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
35 |
+
outputs=gr.Textbox(),
|
36 |
+
)
|
37 |
+
|
38 |
+
example_transcribe = gr.Interface(
|
39 |
+
fn=lambda filename: transcribe_speech(os.path.join(example_folder, filename)),
|
40 |
+
inputs=gr.Dropdown(choices=example_files, label="Select an example"),
|
41 |
+
outputs=gr.Textbox(),
|
42 |
+
)
|
43 |
+
|
44 |
+
with demo:
|
45 |
+
gr.TabbedInterface(
|
46 |
+
[mic_transcribe, file_transcribe, example_transcribe],
|
47 |
+
["Transcribe Microphone", "Transcribe Audio File", "Transcribe Example"],
|
48 |
+
)
|
49 |
+
demo.launch(debug=True)
|
examples/example1.mp3
ADDED
Binary file (24.2 kB). View file
|
|
examples/example2.mp3
ADDED
Binary file (20.3 kB). View file
|
|
examples/example3.mp3
ADDED
Binary file (29.2 kB). View file
|
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
transformers
|
3 |
+
gradio
|