-
Notifications
You must be signed in to change notification settings - Fork 472
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
Allow modify model config at decode time for ASR #1124
Allow modify model config at decode time for ASR #1124
Conversation
Allow modify model config at decode time for ASR. k2-fsa#1116
sherpa-onnx/c-api/c-api.h
Outdated
@@ -491,7 +496,9 @@ SHERPA_ONNX_API void DecodeMultipleOfflineStreams( | |||
SHERPA_ONNX_API typedef struct SherpaOnnxOfflineRecognizerResult { | |||
const char *text; | |||
|
|||
// Pointer to continuous memory which holds timestamps | |||
const char *lang; |
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 the newly added member, please add it as the last field.
That is, move line 499 to line 529
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.
Done.
Addressing PR comments
sherpa-onnx/c-api/c-api.cc
Outdated
@@ -308,8 +308,27 @@ struct SherpaOnnxOfflineStream { | |||
: impl(std::move(p)) {} | |||
}; | |||
|
|||
sherpa_onnx::OfflineRecognizerConfig convertConfig( |
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.
sherpa_onnx::OfflineRecognizerConfig convertConfig( | |
static sherpa_onnx::OfflineRecognizerConfig convertConfig( |
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.
Done.
sherpa-onnx/c-api/c-api.cc
Outdated
|
||
return recognizer; | ||
void SetSherpaOnnxOfflineRecognizerConfig( |
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.
void SetSherpaOnnxOfflineRecognizerConfig( | |
void SherpaOnnxOfflineRecognizerSetConfig( |
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.
Done.
char *c_lang = new char[lang.size() + 1]; | ||
std::copy(lang.begin(), lang.end(), c_lang); | ||
c_lang[lang.size()] = '\0'; | ||
r->lang = c_lang; |
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.
Remember to use
delete[] r->lang;
to avoid memory leak.
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.
Done.
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.
Thank you!
Left some minor comments. Otherwise, it looks good to me.
Addressing PR comments.
@csukuangfj I addressed the comments. Thank you for the suggestions! |
Thank you! We will merge it once the CI gets passed. (Don't worry about the failed CI tests.) |
Allow modify model config at decode time for ASR.
#1116
Also, exposes the language which was recognized by whisper to the calling client in the SherpaOnnxOfflineRecognizerResult.