Update app.py
Browse files
app.py
CHANGED
|
@@ -78,17 +78,21 @@ def transcribe_audio(audio):
|
|
| 78 |
)
|
| 79 |
inputs = {k: v.to(DEVICE) for k, v in inputs.items()}
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
with torch.no_grad():
|
| 82 |
-
# Force Yoruba transcription
|
| 83 |
generated_ids = model.generate(
|
| 84 |
**inputs,
|
| 85 |
task="transcribe",
|
| 86 |
-
language="yo",
|
| 87 |
-
max_new_tokens=
|
| 88 |
temperature=0.0,
|
| 89 |
no_repeat_ngram_size=3
|
| 90 |
)
|
| 91 |
|
|
|
|
| 92 |
text = processor.batch_decode(
|
| 93 |
generated_ids,
|
| 94 |
skip_special_tokens=True
|
|
|
|
| 78 |
)
|
| 79 |
inputs = {k: v.to(DEVICE) for k, v in inputs.items()}
|
| 80 |
|
| 81 |
+
MAX_DECODER_TOKENS = 448
|
| 82 |
+
START_TOKENS = 4
|
| 83 |
+
max_new_tokens = MAX_DECODER_TOKENS - START_TOKENS # 444
|
| 84 |
+
|
| 85 |
with torch.no_grad():
|
|
|
|
| 86 |
generated_ids = model.generate(
|
| 87 |
**inputs,
|
| 88 |
task="transcribe",
|
| 89 |
+
language="yo",
|
| 90 |
+
max_new_tokens=max_new_tokens,
|
| 91 |
temperature=0.0,
|
| 92 |
no_repeat_ngram_size=3
|
| 93 |
)
|
| 94 |
|
| 95 |
+
|
| 96 |
text = processor.batch_decode(
|
| 97 |
generated_ids,
|
| 98 |
skip_special_tokens=True
|