Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,8 +27,8 @@ def transcribe(audio):
|
|
27 |
resampler = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)
|
28 |
audio_tensor = resampler(audio_tensor)
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
|
33 |
pipe = pipeline(
|
34 |
"automatic-speech-recognition",
|
@@ -37,9 +37,8 @@ def transcribe(audio):
|
|
37 |
device=device,
|
38 |
)
|
39 |
|
40 |
-
prediction = pipe(
|
41 |
return prediction
|
42 |
-
|
43 |
|
44 |
gradio_app = gr.Interface(
|
45 |
fn=transcribe,
|
|
|
27 |
resampler = torchaudio.transforms.Resample(orig_freq=sample_rate, new_freq=16000)
|
28 |
audio_tensor = resampler(audio_tensor)
|
29 |
|
30 |
+
# Convert back to a NumPy array
|
31 |
+
audio_np = audio_tensor.cpu().numpy()
|
32 |
|
33 |
pipe = pipeline(
|
34 |
"automatic-speech-recognition",
|
|
|
37 |
device=device,
|
38 |
)
|
39 |
|
40 |
+
prediction = pipe(audio_np)["text"]
|
41 |
return prediction
|
|
|
42 |
|
43 |
gradio_app = gr.Interface(
|
44 |
fn=transcribe,
|