-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
c++ api for keyword spotter #642
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Left some minor comments.
if (config->model_config.debug) { | ||
SHERPA_ONNX_LOGE("%s\n", spotter_config.ToString().c_str()); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add
if (!spotter_config.Validate()) {
SHERPA_ONNX_LOGE("Errors in config!");
return nullptr;
}
sherpa-onnx/c-api/c-api.cc
Outdated
SherpaOnnxKeywordSpotter *spotter, SherpaOnnxOnlineStream **streams, | ||
int32_t n) { | ||
std::vector<sherpa_onnx::OnlineStream*> ss(n); | ||
for(int32_t i=0; i!=n; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for(int32_t i=0; i!=n; ++i) { | |
for(int32_t i = 0; i != n; ++i) { |
Please use clang-format
to format your code.
You can install clang-format
with
pip install clang-format
|
||
/// timestamps.size() == tokens.size() | ||
/// timestamps[i] records the time in seconds when tokens[i] is decoded. | ||
float* timestamps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
float* timestamps; | |
const float* timestamps; |
sherpa-onnx/c-api/c-api.h
Outdated
* } | ||
*/ | ||
const char* json; | ||
}SherpaOnnxKeywordResult ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}SherpaOnnxKeywordResult ; | |
} SherpaOnnxKeywordResult ; |
/// @param spotter A pointer returned by CreateKeywordSpotter() | ||
/// @return Return a pointer to an OnlineStream. The user has to invoke | ||
/// DestroyOnlineStream() to free it to avoid memory leak. | ||
SHERPA_ONNX_API SherpaOnnxOnlineStream* CreateKeywordStream( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you prefix every function name with SherpaOnnx
?
That is, replace CreateKeywordStream
with SherpaOnnxCreateKeywordStream
.
I think it was an error to not use SherpaOnnx
for online and offline ASR C APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after add this many line exceed 80 char, I tried the style is not uniform
and change api name means must modify code of other project
Please use the following command to check the code style locally cd sherpa-onnx
./scripts/check_style_cpplint.sh 2 |
This PR has conflicts with #648 since both of them add C API for KWS. @lovemefan What do you think about this PR? |
ok, I'm going to copy the code of c api from this PR |
Thanks! I am merging this PR. Please merge the latest master to your branch after we merge this PR. |
@xinhecuican Thank you for your first-time contribution! |
No description provided.