Spaces:
Runtime error
Runtime error
Commit
·
9ba53c0
1
Parent(s):
98f5625
Update asr.py
Browse files
asr.py
CHANGED
@@ -20,15 +20,15 @@ def resample_to_16k(audio, orig_sr):
|
|
20 |
|
21 |
def transcribe(audio):
|
22 |
print(audio)
|
23 |
-
audio = librosa.load(audio, sr=16_000, mono=True)[0]
|
24 |
-
print("After loading: ",audio)
|
25 |
sr,y = audio
|
26 |
y = y.astype(np.float32)
|
27 |
y /= np.max(np.abs(y))
|
28 |
y_resampled = resample_to_16k(y, sr)
|
29 |
print("Without using librosa to load:",y_resampled)
|
30 |
-
inputs = processor(audio, sampling_rate=16_000,return_tensors="pt")
|
31 |
-
|
32 |
with torch.no_grad():
|
33 |
tr_start_time = time.time()
|
34 |
outputs = model(**inputs).logits
|
|
|
20 |
|
21 |
def transcribe(audio):
|
22 |
print(audio)
|
23 |
+
# audio = librosa.load(audio, sr=16_000, mono=True)[0]
|
24 |
+
# print("After loading: ",audio)
|
25 |
sr,y = audio
|
26 |
y = y.astype(np.float32)
|
27 |
y /= np.max(np.abs(y))
|
28 |
y_resampled = resample_to_16k(y, sr)
|
29 |
print("Without using librosa to load:",y_resampled)
|
30 |
+
# inputs = processor(audio, sampling_rate=16_000,return_tensors="pt")
|
31 |
+
inputs = processor(y_resampled, sampling_rate=16_000,return_tensors="pt")
|
32 |
with torch.no_grad():
|
33 |
tr_start_time = time.time()
|
34 |
outputs = model(**inputs).logits
|