Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,16 +36,14 @@ def pipe(file, return_timestamps=False,lang="nn"):
|
|
| 36 |
device=device,
|
| 37 |
token=auth_token,
|
| 38 |
torch_dtype=torch.float16,
|
| 39 |
-
model_kwargs={"attn_implementation": "flash_attention_2", "num_beams": 5, "language":
|
| 40 |
)
|
| 41 |
asr.model.config.forced_decoder_ids = asr.tokenizer.get_decoder_prompt_ids(
|
| 42 |
language=lang,
|
| 43 |
task="transcribe",
|
| 44 |
no_timestamps=not return_timestamps,
|
| 45 |
)
|
| 46 |
-
|
| 47 |
-
print("Supported languages:", tokenizer.lang_code_to_id.keys())
|
| 48 |
-
return asr(file, return_timestamps=return_timestamps, batch_size=24)
|
| 49 |
|
| 50 |
def format_output(text):
|
| 51 |
# Add a line break after ".", "!", ":", or "?" unless part of sequences like "..."
|
|
|
|
| 36 |
device=device,
|
| 37 |
token=auth_token,
|
| 38 |
torch_dtype=torch.float16,
|
| 39 |
+
model_kwargs={"attn_implementation": "flash_attention_2", "num_beams": 5, "language": lang} if FLASH_ATTENTION else {"attn_implementation": "sdpa", "num_beams": 5},
|
| 40 |
)
|
| 41 |
asr.model.config.forced_decoder_ids = asr.tokenizer.get_decoder_prompt_ids(
|
| 42 |
language=lang,
|
| 43 |
task="transcribe",
|
| 44 |
no_timestamps=not return_timestamps,
|
| 45 |
)
|
| 46 |
+
return asr(file, return_timestamps=return_timestamps, batch_size=24, language=lang, task="transcribe")
|
|
|
|
|
|
|
| 47 |
|
| 48 |
def format_output(text):
|
| 49 |
# Add a line break after ".", "!", ":", or "?" unless part of sequences like "..."
|