Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -143,12 +143,17 @@ def transcribe_audio(audio_file_path):
|
|
| 143 |
# Move inputs to the appropriate device
|
| 144 |
input_features = inputs.input_features.to(device)
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
with torch.no_grad():
|
| 147 |
-
# Use generation arguments to specify language and task for the Uz-Small model
|
| 148 |
predicted_ids = model.generate(
|
| 149 |
-
input_features,
|
| 150 |
-
|
| 151 |
-
max_length=448 # Use a reasonable max length for speed/resource management
|
| 152 |
)
|
| 153 |
|
| 154 |
# Decode the generated token IDs to get the text transcript
|
|
|
|
| 143 |
# Move inputs to the appropriate device
|
| 144 |
input_features = inputs.input_features.to(device)
|
| 145 |
|
| 146 |
+
forced_ids = processor.get_decoder_prompt_ids(language="uz", task="transcribe")
|
| 147 |
+
|
| 148 |
+
gen_config = GenerationConfig(
|
| 149 |
+
forced_decoder_ids=forced_ids,
|
| 150 |
+
max_length=448
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
with torch.no_grad():
|
|
|
|
| 154 |
predicted_ids = model.generate(
|
| 155 |
+
input_features,
|
| 156 |
+
generation_config=gen_config
|
|
|
|
| 157 |
)
|
| 158 |
|
| 159 |
# Decode the generated token IDs to get the text transcript
|