Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -24,10 +24,10 @@ bark_model.to(device)
|
|
24 |
|
25 |
def translate(audio):
|
26 |
sr, y = audio
|
27 |
-
if sr != 16000:
|
28 |
-
y = librosa.resample(y, orig_sr=sr, target_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")
|
32 |
generated_ids = asr_model.generate(inputs["input_features"],attention_mask=inputs["attention_mask"],
|
33 |
forced_bos_token_id=asr_processor.tokenizer.lang_code_to_id['it'],)
|
|
|
24 |
|
25 |
def translate(audio):
|
26 |
sr, y = audio
|
|
|
|
|
27 |
y = y.astype(np.float32)
|
28 |
y /= np.max(np.abs(y))
|
29 |
+
if sr != 16000:
|
30 |
+
y = librosa.resample(y, orig_sr=sr, target_sr=16000)
|
31 |
inputs = asr_processor(y, sampling_rate=16000, return_tensors="pt")
|
32 |
generated_ids = asr_model.generate(inputs["input_features"],attention_mask=inputs["attention_mask"],
|
33 |
forced_bos_token_id=asr_processor.tokenizer.lang_code_to_id['it'],)
|