Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
import numpy as np
|
3 |
import torch
|
4 |
from datasets import load_dataset
|
5 |
-
import
|
6 |
|
7 |
from transformers import pipeline
|
8 |
from transformers import BarkModel, BarkProcessor
|
@@ -25,8 +25,7 @@ bark_model.to(device)
|
|
25 |
def translate(audio):
|
26 |
sr, y = audio
|
27 |
if sr != 16000:
|
28 |
-
|
29 |
-
y = resampler(y)
|
30 |
y = y.astype(np.float32)
|
31 |
y /= np.max(np.abs(y))
|
32 |
inputs = asr_processor(y, sampling_rate=16000, return_tensors="pt")
|
|
|
2 |
import numpy as np
|
3 |
import torch
|
4 |
from datasets import load_dataset
|
5 |
+
import librosa
|
6 |
|
7 |
from transformers import pipeline
|
8 |
from transformers import BarkModel, BarkProcessor
|
|
|
25 |
def translate(audio):
|
26 |
sr, y = audio
|
27 |
if sr != 16000:
|
28 |
+
y = librosa.resample(y, sr, 16000)
|
|
|
29 |
y = y.astype(np.float32)
|
30 |
y /= np.max(np.abs(y))
|
31 |
inputs = asr_processor(y, sampling_rate=16000, return_tensors="pt")
|