Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -67,15 +67,18 @@ def convert_to_wav(filepath):
|
|
67 |
pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large", chunk_length_s=30, generate_kwargs={'task': 'transcribe', 'language': 'no'})
|
68 |
|
69 |
@spaces.GPU()
|
70 |
-
def transcribe_audio(audio_file, batch_size=16):
|
71 |
# --audio file to tensor
|
72 |
-
waveform
|
73 |
-
samples =
|
|
|
|
|
|
|
74 |
|
75 |
start_time = time.time()
|
76 |
|
77 |
# --pipe it
|
78 |
-
outputs = pipe(samples, sampling_rate=sample_rate, batch_size=batch_size, return_timestamps=False)
|
79 |
text = outputs["text"]
|
80 |
|
81 |
end_time = time.time()
|
|
|
67 |
pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large", chunk_length_s=30, generate_kwargs={'task': 'transcribe', 'language': 'no'})
|
68 |
|
69 |
@spaces.GPU()
|
70 |
+
def transcribe_audio(audio_file, batch_size=16, sample_rate =16000):
|
71 |
# --audio file to tensor
|
72 |
+
waveform = waveform.numpy(audio_file)
|
73 |
+
samples = samples.numpy(audio_file)
|
74 |
+
if waveform.ndim > 1:
|
75 |
+
waveform = waveform[0, :]
|
76 |
+
waveform, samples = torchaudio.load(waveform, samples)
|
77 |
|
78 |
start_time = time.time()
|
79 |
|
80 |
# --pipe it
|
81 |
+
outputs = pipe(waveform, samples, sampling_rate=sample_rate, batch_size=batch_size, return_timestamps=False)
|
82 |
text = outputs["text"]
|
83 |
|
84 |
end_time = time.time()
|