re-pull-request allow tokens and hotwords be loaded from buffered string driectly (#1339)

Co-authored-by: xiao <shawl336@163.com>
This commit is contained in:
lxiao336
2024-09-13 09:58:17 +08:00
committed by GitHub
parent 6b6e7635ed
commit 65cfa7548a
12 changed files with 414 additions and 16 deletions

View File

@@ -56,8 +56,19 @@ bool OnlineModelConfig::Validate() const {
return false;
}
if (!FileExists(tokens)) {
SHERPA_ONNX_LOGE("tokens: '%s' does not exist", tokens.c_str());
if (!tokens_buf.empty() && FileExists(tokens)) {
SHERPA_ONNX_LOGE(
"you can not provide a tokens_buf and a tokens file: '%s', "
"at the same time, which is confusing",
tokens.c_str());
return false;
}
if (tokens_buf.empty() && !FileExists(tokens)) {
SHERPA_ONNX_LOGE(
"tokens: '%s' does not exist, you should provide "
"either a tokens buffer or a tokens file",
tokens.c_str());
return false;
}