leofltt commited on
Commit
275ebc6
1 Parent(s): 6c4423e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
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 torchaudio
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
- resampler = torchaudio.transforms.Resample(sr, 16000, dtype=y.dtype)
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")