|
@@ -2,28 +2,27 @@
|
|
|
# @Author: SWHL
|
|
# @Author: SWHL
|
|
|
# @Contact: liekkaskono@163.com
|
|
# @Contact: liekkaskono@163.com
|
|
|
import os.path
|
|
import os.path
|
|
|
-import traceback
|
|
|
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
|
from typing import List, Union, Tuple
|
|
from typing import List, Union, Tuple
|
|
|
|
|
|
|
|
import librosa
|
|
import librosa
|
|
|
import numpy as np
|
|
import numpy as np
|
|
|
|
|
|
|
|
-from utils.utils import (CharTokenizer, Hypothesis, ONNXRuntimeError,
|
|
|
|
|
- OrtInferSession, TokenIDConverter, get_logger,
|
|
|
|
|
- read_yaml)
|
|
|
|
|
-from utils.postprocess_utils import sentence_postprocess
|
|
|
|
|
-from utils.frontend import WavFrontend
|
|
|
|
|
|
|
+from .utils.utils import (CharTokenizer, Hypothesis, ONNXRuntimeError,
|
|
|
|
|
+ OrtInferSession, TokenIDConverter, get_logger,
|
|
|
|
|
+ read_yaml)
|
|
|
|
|
+from .utils.postprocess_utils import sentence_postprocess
|
|
|
|
|
+from .utils.frontend import WavFrontend
|
|
|
|
|
|
|
|
logging = get_logger()
|
|
logging = get_logger()
|
|
|
|
|
|
|
|
|
|
|
|
|
class Paraformer():
|
|
class Paraformer():
|
|
|
- def __init__(self, model_dir: Union[str, Path]=None,
|
|
|
|
|
|
|
+ def __init__(self, model_dir: Union[str, Path] = None,
|
|
|
batch_size: int = 1,
|
|
batch_size: int = 1,
|
|
|
- device_id: Union[str, int]="-1",
|
|
|
|
|
|
|
+ device_id: Union[str, int] = "-1",
|
|
|
):
|
|
):
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if not Path(model_dir).exists():
|
|
if not Path(model_dir).exists():
|
|
|
raise FileNotFoundError(f'{model_dir} does not exist.')
|
|
raise FileNotFoundError(f'{model_dir} does not exist.')
|
|
|
|
|
|
|
@@ -140,5 +139,3 @@ class Paraformer():
|
|
|
text = texts[0]
|
|
text = texts[0]
|
|
|
# text = self.tokenizer.tokens2text(token)
|
|
# text = self.tokenizer.tokens2text(token)
|
|
|
return text
|
|
return text
|
|
|
-
|
|
|
|
|
-
|
|
|