Spaces:
Running
Running
Commit
·
be40b87
1
Parent(s):
5399362
ignore warning
Browse files- app/core/asr_engine.py +13 -2
app/core/asr_engine.py
CHANGED
|
@@ -3,6 +3,8 @@ from typing import List, Dict
|
|
| 3 |
|
| 4 |
import torch
|
| 5 |
from transformers import pipeline
|
|
|
|
|
|
|
| 6 |
import os
|
| 7 |
from typing import Tuple
|
| 8 |
|
|
@@ -29,15 +31,24 @@ def load_model(chunk_length_s: float = 30.0):
|
|
| 29 |
logger.info("Loading ASR model PhoWhisper-base")
|
| 30 |
|
| 31 |
device = 0 if torch.cuda.is_available() else -1
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
_ASR_MODEL = pipeline(
|
| 35 |
task="automatic-speech-recognition",
|
| 36 |
model="vinai/PhoWhisper-base",
|
| 37 |
device=device,
|
| 38 |
-
|
| 39 |
chunk_length_s=chunk_length_s,
|
| 40 |
return_timestamps=True,
|
|
|
|
| 41 |
)
|
| 42 |
|
| 43 |
logger.info(
|
|
|
|
| 3 |
|
| 4 |
import torch
|
| 5 |
from transformers import pipeline
|
| 6 |
+
from transformers import logging as transformers_logging
|
| 7 |
+
import warnings
|
| 8 |
import os
|
| 9 |
from typing import Tuple
|
| 10 |
|
|
|
|
| 31 |
logger.info("Loading ASR model PhoWhisper-base")
|
| 32 |
|
| 33 |
device = 0 if torch.cuda.is_available() else -1
|
| 34 |
+
dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
| 35 |
+
|
| 36 |
+
# Reduce noisy transformer logs and warnings about experimental chunking
|
| 37 |
+
try:
|
| 38 |
+
transformers_logging.set_verbosity_error()
|
| 39 |
+
except Exception:
|
| 40 |
+
pass
|
| 41 |
+
# filter the noisy chunk_length_s warnings (regex)
|
| 42 |
+
warnings.filterwarnings("ignore", message=r".*chunk_length_s.*")
|
| 43 |
|
| 44 |
_ASR_MODEL = pipeline(
|
| 45 |
task="automatic-speech-recognition",
|
| 46 |
model="vinai/PhoWhisper-base",
|
| 47 |
device=device,
|
| 48 |
+
dtype=dtype,
|
| 49 |
chunk_length_s=chunk_length_s,
|
| 50 |
return_timestamps=True,
|
| 51 |
+
ignore_warning=True,
|
| 52 |
)
|
| 53 |
|
| 54 |
logger.info(
|