

specify dtype for librosa.load, instead of cast
@d22a5ef88944c1c0d7f0b4f7cb1885e898ec3fa8
--- whisper_online.py
+++ whisper_online.py
... | ... | @@ -10,8 +10,8 @@ |
10 | 10 |
|
11 | 11 |
@lru_cache |
12 | 12 |
def load_audio(fname): |
13 |
- a, _ = librosa.load(fname, sr=16000) |
|
14 |
- return a.astype('float32') |
|
13 |
+ a, _ = librosa.load(fname, sr=16000, dtype=np.float32) |
|
14 |
+ return a |
|
15 | 15 |
|
16 | 16 |
def load_audio_chunk(fname, beg, end): |
17 | 17 |
audio = load_audio(fname) |
--- whisper_online_server.py
+++ whisper_online_server.py
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 |
import sys |
5 | 5 |
import argparse |
6 | 6 |
import os |
7 |
+import numpy as np |
|
7 | 8 |
parser = argparse.ArgumentParser() |
8 | 9 |
|
9 | 10 |
# server options |
... | ... | @@ -137,8 +138,8 @@ |
137 | 138 |
if not raw_bytes: |
138 | 139 |
break |
139 | 140 |
sf = soundfile.SoundFile(io.BytesIO(raw_bytes), channels=1,endian="LITTLE",samplerate=SAMPLING_RATE, subtype="PCM_16",format="RAW") |
140 |
- audio, _ = librosa.load(sf,sr=SAMPLING_RATE) |
|
141 |
- out.append(audio.astype('float32')) |
|
141 |
+ audio, _ = librosa.load(sf,sr=SAMPLING_RATE,dtype=np.float32) |
|
142 |
+ out.append(audio) |
|
142 | 143 |
if not out: |
143 | 144 |
return None |
144 | 145 |
return np.concatenate(out) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?