Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,8 +2,10 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
import numpy as np
|
4 |
import librosa
|
|
|
5 |
|
6 |
transcriber = pipeline("automatic-speech-recognition", model="Oysiyl/w2v-bert-2.0-ukrainian-colab-CV16.0")
|
|
|
7 |
|
8 |
def transcribe(audio):
|
9 |
sr, y = audio
|
@@ -11,8 +13,9 @@ def transcribe(audio):
|
|
11 |
y /= np.max(np.abs(y))
|
12 |
if sr != 16000:
|
13 |
y = librosa.resample(y, orig_sr=sr, target_sr=16000)
|
14 |
-
|
15 |
-
|
|
|
16 |
|
17 |
|
18 |
demo = gr.Interface(
|
|
|
2 |
from transformers import pipeline
|
3 |
import numpy as np
|
4 |
import librosa
|
5 |
+
from punctuators.models import PunctCapSegModelONNX
|
6 |
|
7 |
transcriber = pipeline("automatic-speech-recognition", model="Oysiyl/w2v-bert-2.0-ukrainian-colab-CV16.0")
|
8 |
+
punct_cap_model = PunctCapSegModelONNX.from_pretrained("1-800-BAD-CODE/xlm-roberta_punctuation_fullstop_truecase")
|
9 |
|
10 |
def transcribe(audio):
|
11 |
sr, y = audio
|
|
|
13 |
y /= np.max(np.abs(y))
|
14 |
if sr != 16000:
|
15 |
y = librosa.resample(y, orig_sr=sr, target_sr=16000)
|
16 |
+
transcribed_text = transcriber({"sampling_rate": 16000, "raw": y})["text"]
|
17 |
+
punct_cap_text = punct_cap_model.infer(texts=[ukr_text], apply_sbd=True)[0][0]
|
18 |
+
return punct_cap_text
|
19 |
|
20 |
|
21 |
demo = gr.Interface(
|