Skip to content

Commit 2c761ff

Browse files
authored
Update __init__.py
1 parent 20c876e commit 2c761ff

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pythaiasr/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class ASR:
10-
def __init__(self, model: str="airesearch/wav2vec2-large-xlsr-53-th", lm=False, device=None) -> None:
10+
def __init__(self, model: str="airesearch/wav2vec2-large-xlsr-53-th", lm: bool=False, device: str=None) -> None:
1111
"""
1212
:param str model: The ASR model name
1313
:param bool lm: Use language model (default is False and except *airesearch/wav2vec2-large-xlsr-53-th* model)
@@ -74,21 +74,23 @@ def __call__(self, file: str) -> str:
7474
_model = None
7575

7676

77-
def asr(file: str, model: str = _model_name) -> str:
77+
def asr(file: str, model: str = _model_name, lm: bool=False, device: str=None) -> str:
7878
"""
7979
:param str file: path of sound file
80-
:param str model: The ASR model
80+
:param str model: The ASR model name
81+
:param bool lm: Use language model (except *airesearch/wav2vec2-large-xlsr-53-th* model)
82+
:param str device: device
8183
:return: thai text from ASR
8284
:rtype: str
8385
8486
**Options for model**
8587
* *airesearch/wav2vec2-large-xlsr-53-th* (default) - AI RESEARCH - PyThaiNLP model
86-
* *wannaphong/wav2vec2-large-xlsr-53-th-cv8-newmm* - Thai Wav2Vec2 with CommonVoice V8 (newmm tokenizer) + language model
87-
* *wannaphong/wav2vec2-large-xlsr-53-th-cv8-deepcut* - Thai Wav2Vec2 with CommonVoice V8 (deepcut tokenizer) + language model
88+
* *wannaphong/wav2vec2-large-xlsr-53-th-cv8-newmm* - Thai Wav2Vec2 with CommonVoice V8 (newmm tokenizer) (+ language model)
89+
* *wannaphong/wav2vec2-large-xlsr-53-th-cv8-deepcut* - Thai Wav2Vec2 with CommonVoice V8 (deepcut tokenizer) (+ language model)
8890
"""
8991
global _model, _model_name
9092
if model!=_model or _model == None:
91-
_model = ASR(model)
93+
_model = ASR(model, lm=lm, device=device)
9294
_model_name = model
9395

9496
return _model(file=file)

0 commit comments

Comments
 (0)