Refactor hotwords,support loading hotwords from file (#296)
This commit is contained in:
@@ -43,7 +43,8 @@ class OfflineRecognizer(object):
|
||||
feature_dim: int = 80,
|
||||
decoding_method: str = "greedy_search",
|
||||
max_active_paths: int = 4,
|
||||
context_score: float = 1.5,
|
||||
hotwords_file: str = "",
|
||||
hotwords_score: float = 1.5,
|
||||
debug: bool = False,
|
||||
provider: str = "cpu",
|
||||
):
|
||||
@@ -105,7 +106,8 @@ class OfflineRecognizer(object):
|
||||
feat_config=feat_config,
|
||||
model_config=model_config,
|
||||
decoding_method=decoding_method,
|
||||
context_score=context_score,
|
||||
hotwords_file=hotwords_file,
|
||||
hotwords_score=hotwords_score,
|
||||
)
|
||||
self.recognizer = _Recognizer(recognizer_config)
|
||||
self.config = recognizer_config
|
||||
@@ -379,11 +381,11 @@ class OfflineRecognizer(object):
|
||||
self.config = recognizer_config
|
||||
return self
|
||||
|
||||
def create_stream(self, contexts_list: Optional[List[List[int]]] = None):
|
||||
if contexts_list is None:
|
||||
def create_stream(self, hotwords: Optional[str] = None):
|
||||
if hotwords is None:
|
||||
return self.recognizer.create_stream()
|
||||
else:
|
||||
return self.recognizer.create_stream(contexts_list)
|
||||
return self.recognizer.create_stream(hotwords)
|
||||
|
||||
def decode_stream(self, s: OfflineStream):
|
||||
self.recognizer.decode_stream(s)
|
||||
|
||||
Reference in New Issue
Block a user