Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,7 @@ from gpuinfo import GPUInfo
|
|
34 |
#import csv
|
35 |
import numpy as np
|
36 |
import torch
|
37 |
-
|
38 |
import torchaudio.transforms as transforms
|
39 |
|
40 |
from transformers import pipeline, AutoModel
|
@@ -69,9 +69,17 @@ def convert_to_wav(filepath):
|
|
69 |
pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large", chunk_length_s=30, generate_kwargs={'task': 'transcribe', 'language': 'no'})
|
70 |
|
71 |
@spaces.GPU()
|
72 |
-
def transcribe_audio(audio_file, batch_size=16
|
73 |
-
|
74 |
-
waveform, sample_rate = torchaudio.load(audio_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
# --convert to mono
|
77 |
if len(samples.shape) > 1:
|
|
|
34 |
#import csv
|
35 |
import numpy as np
|
36 |
import torch
|
37 |
+
import torchaudio
|
38 |
import torchaudio.transforms as transforms
|
39 |
|
40 |
from transformers import pipeline, AutoModel
|
|
|
69 |
pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large", chunk_length_s=30, generate_kwargs={'task': 'transcribe', 'language': 'no'})
|
70 |
|
71 |
@spaces.GPU()
|
72 |
+
def transcribe_audio(audio_file, batch_size=16, sample_rate=16000):
|
73 |
+
audio_file = filepath.read(audio_file)
|
74 |
+
waveform, sample_rate = torchaudio.load(audio_file)
|
75 |
+
|
76 |
+
if samples.ndim > 1:
|
77 |
+
samples = samples[0, :]
|
78 |
+
|
79 |
+
# --waveform to ndnumpy array
|
80 |
+
samples = waveform.numpy()
|
81 |
+
|
82 |
+
start_time = time.time()
|
83 |
|
84 |
# --convert to mono
|
85 |
if len(samples.shape) > 1:
|