Spaces:
Runtime error
Runtime error
The app
Browse files- README.md +1 -1
- app.py +29 -0
- packages.txt +1 -0
- requirements.txt +2 -0
README.md
CHANGED
@@ -10,4 +10,4 @@ pinned: false
|
|
10 |
license: cc-by-nc-sa-4.0
|
11 |
---
|
12 |
|
13 |
-
|
|
|
10 |
license: cc-by-nc-sa-4.0
|
11 |
---
|
12 |
|
13 |
+
Czech Wav2Vec2-XLS-R model from 250h of recordings.
|
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline, AutoFeatureExtractor, AutoTokenizer, Wav2Vec2ForCTC
|
2 |
+
import gradio as gr
|
3 |
+
import time
|
4 |
+
|
5 |
+
model_id = 'comodoro/wav2vec2-xls-r-300m-cs-250'
|
6 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained(model_id)
|
7 |
+
model = Wav2Vec2ForCTC.from_pretrained(model_id)
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
9 |
+
|
10 |
+
p = pipeline("automatic-speech-recognition", chunk_length_s=5, model=model,
|
11 |
+
tokenizer=tokenizer, feature_extractor=feature_extractor)
|
12 |
+
|
13 |
+
def transcribe(audio, state=""):
|
14 |
+
time.sleep(2)
|
15 |
+
text = p(audio)["text"]
|
16 |
+
state += text + " "
|
17 |
+
return state, state
|
18 |
+
|
19 |
+
gr.Interface(
|
20 |
+
fn=transcribe,
|
21 |
+
inputs=[
|
22 |
+
gr.inputs.Audio(source="microphone", type="filepath"),
|
23 |
+
"state"
|
24 |
+
],
|
25 |
+
outputs=[
|
26 |
+
"textbox",
|
27 |
+
"state"
|
28 |
+
],
|
29 |
+
live=True).launch()
|
packages.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
ffmpeg
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
transformers
|