Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import torch
|
| 2 |
import pickle
|
|
|
|
| 3 |
import streamlit as st
|
| 4 |
import torchaudio as ta
|
| 5 |
|
|
@@ -70,15 +71,15 @@ if submit_button and uploaded_files is not None:
|
|
| 70 |
|
| 71 |
input_features = processor(resampled_inp[0], sampling_rate=16000, return_tensors='pt').input_features
|
| 72 |
|
| 73 |
-
|
| 74 |
-
lang = detect_language(input_features)
|
| 75 |
-
|
| 76 |
-
with open('languages.pkl', 'rb') as f:
|
| 77 |
-
lang_dict = pickle.load(f)
|
| 78 |
-
detected_language = lang_dict[lang]
|
| 79 |
-
|
| 80 |
if task == "translate":
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
forced_decoder_ids = processor.get_decoder_prompt_ids(language=detected_language, task="translate")
|
| 83 |
predicted_ids = model.generate(input_features, forced_decoder_ids=forced_decoder_ids)
|
| 84 |
else:
|
|
|
|
| 1 |
import torch
|
| 2 |
import pickle
|
| 3 |
+
import whisper
|
| 4 |
import streamlit as st
|
| 5 |
import torchaudio as ta
|
| 6 |
|
|
|
|
| 71 |
|
| 72 |
input_features = processor(resampled_inp[0], sampling_rate=16000, return_tensors='pt').input_features
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
if task == "translate":
|
| 75 |
+
|
| 76 |
+
# Detect Language
|
| 77 |
+
lang = detect_language(input_features)
|
| 78 |
+
with open('languages.pkl', 'rb') as f:
|
| 79 |
+
lang_dict = pickle.load(f)
|
| 80 |
+
detected_language = lang_dict[lang]
|
| 81 |
+
|
| 82 |
+
# Set decoder & Predict translation
|
| 83 |
forced_decoder_ids = processor.get_decoder_prompt_ids(language=detected_language, task="translate")
|
| 84 |
predicted_ids = model.generate(input_features, forced_decoder_ids=forced_decoder_ids)
|
| 85 |
else:
|