-
Notifications
You must be signed in to change notification settings - Fork 590
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 add wave write to buffer. #1962
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. Otherwise, it looks good to me.
sherpa-onnx/csrc/wave-reader.cc
Outdated
@@ -315,7 +315,9 @@ std::vector<float> ReadWaveImpl(std::istream &is, int32_t *sampling_rate, | |||
std::vector<float> ReadWave(const std::string &filename, int32_t *sampling_rate, | |||
bool *is_ok) { | |||
std::ifstream is(filename, std::ifstream::binary); | |||
return ReadWave(is, sampling_rate, is_ok); | |||
auto samples = ReadWave(is, sampling_rate, is_ok); | |||
is.close(); |
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.
is.close(); |
No need to call it explicitly.
sherpa-onnx/csrc/wave-writer.cc
Outdated
if (!os) { | ||
SHERPA_ONNX_LOGE("Write %s failed", filename.c_str()); | ||
os.close(); |
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.
os.close(); |
sherpa-onnx/csrc/wave-writer.cc
Outdated
return false; | ||
} | ||
|
||
os.close(); |
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.
os.close(); |
Note: This is C++, not C. You don't need to close it by yourself.
It is closed in the destructor.
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 for your contribution!
in same case , the api can be useful :