Skip to content
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

Merged
merged 4 commits into from
Mar 10, 2025
Merged

c-api add wave write to buffer. #1962

merged 4 commits into from
Mar 10, 2025

Conversation

cjsdurj
Copy link
Contributor

@cjsdurj cjsdurj commented Mar 6, 2025

in same case , the api can be useful :

  • a tts server which sent wave output to its client and not do not need to save a tmp file to filesystem。

@cjsdurj cjsdurj closed this Mar 6, 2025
@cjsdurj cjsdurj reopened this Mar 6, 2025
Copy link
Collaborator

@csukuangfj csukuangfj left a 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.

@@ -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();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is.close();

No need to call it explicitly.

if (!os) {
SHERPA_ONNX_LOGE("Write %s failed", filename.c_str());
os.close();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
os.close();

return false;
}

os.close();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
os.close();

Note: This is C++, not C. You don't need to close it by yourself.
It is closed in the destructor.

Copy link
Collaborator

@csukuangfj csukuangfj left a 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!

@csukuangfj csukuangfj merged commit b87fce9 into k2-fsa:master Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants