Spaces:
Runtime error
Runtime error
Upload 4 files
Browse files- README.md +5 -5
- app.py +47 -0
- gitattributes +35 -0
- requirements.txt +5 -0
README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
---
|
2 |
-
title: Automatic Speech
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.29.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
-
license:
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: Automatic Speech Recognititon
|
3 |
+
emoji: π
|
4 |
+
colorFrom: indigo
|
5 |
+
colorTo: purple
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.29.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
+
license: apache-2.0
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
asr = pipeline(task="automatic-speech-recognition",
|
4 |
+
model= "distil-whisper/distil-small.en")
|
5 |
+
|
6 |
+
import gradio as gr
|
7 |
+
demo = gr.Blocks()
|
8 |
+
|
9 |
+
def transcribe_long_form(filepath):
|
10 |
+
if filepath is None:
|
11 |
+
gr.Warning("No audio found, please retry")
|
12 |
+
return
|
13 |
+
output = asr(filepath,
|
14 |
+
max_new_tokens=256,
|
15 |
+
chunk_length_s=30,
|
16 |
+
batch_size=4,)
|
17 |
+
return output['text']
|
18 |
+
|
19 |
+
mic_transcribe = gr.Interface(
|
20 |
+
fn=transcribe_long_form,
|
21 |
+
inputs=gr.Audio(sources="microphone",
|
22 |
+
type="filepath"),
|
23 |
+
outputs=gr.Textbox(label="Transcription",
|
24 |
+
lines=7),
|
25 |
+
allow_flagging="never",
|
26 |
+
description="Speak into the microphone or upload an audio file to transcribe it into text. This model uses a state-of-the-art speech recognition algorithm to recognize spoken words and phrases")
|
27 |
+
|
28 |
+
file_transcribe = gr.Interface(
|
29 |
+
fn=transcribe_long_form,
|
30 |
+
inputs=gr.Audio(sources="upload",
|
31 |
+
type="filepath"),
|
32 |
+
outputs=gr.Textbox(label="Transcription",
|
33 |
+
lines=7),
|
34 |
+
allow_flagging="never",
|
35 |
+
description="Speak into the microphone or upload an audio file to transcribe it into text. This model uses a state-of-the-art speech recognition algorithm to recognize spoken words and phrases")
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
with demo:
|
40 |
+
gr.TabbedInterface(
|
41 |
+
[mic_transcribe,
|
42 |
+
file_transcribe],
|
43 |
+
["Transcribe Microphone",
|
44 |
+
"Transcribe Audio File"],
|
45 |
+
title="SpeechScribe - Automatic Speech Recognition"
|
46 |
+
)
|
47 |
+
demo.launch()
|
gitattributes
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
gradio
|
3 |
+
soundfile
|
4 |
+
librosa
|
5 |
+
torch
|