c-api add wave write to buffer. (#1962)
Co-authored-by: jian.chen03 <jian.chen03@transwarp.io>
This commit is contained in:
@@ -1337,6 +1337,16 @@ int32_t SherpaOnnxWriteWave(const float *samples, int32_t n,
|
||||
return sherpa_onnx::WriteWave(filename, sample_rate, samples, n);
|
||||
}
|
||||
|
||||
int64_t SherpaOnnxWaveFileSize(int32_t n_samples) {
|
||||
return sherpa_onnx::WaveFileSize(n_samples);
|
||||
}
|
||||
|
||||
SHERPA_ONNX_API void SherpaOnnxWriteWaveToBuffer(const float *samples,
|
||||
int32_t n, int32_t sample_rate,
|
||||
char *buffer) {
|
||||
sherpa_onnx::WriteWave(buffer, sample_rate, samples, n);
|
||||
}
|
||||
|
||||
const SherpaOnnxWave *SherpaOnnxReadWave(const char *filename) {
|
||||
int32_t sample_rate = -1;
|
||||
bool is_ok = false;
|
||||
|
||||
@@ -1049,6 +1049,18 @@ SHERPA_ONNX_API int32_t SherpaOnnxWriteWave(const float *samples, int32_t n,
|
||||
int32_t sample_rate,
|
||||
const char *filename);
|
||||
|
||||
// the amount of bytes needed to store a wave file which contains a
|
||||
// single channel and has 16-bit samples.
|
||||
SHERPA_ONNX_API int64_t SherpaOnnxWaveFileSize(int32_t n_samples);
|
||||
|
||||
// Similar to SherpaOnnxWriteWave , it writes wave to allocated buffer;
|
||||
//
|
||||
// in some case (http tts api return wave binary file, server do not need to
|
||||
// write wave to fs)
|
||||
SHERPA_ONNX_API void SherpaOnnxWriteWaveToBuffer(const float *samples,
|
||||
int32_t n, int32_t sample_rate,
|
||||
char *buffer);
|
||||
|
||||
SHERPA_ONNX_API typedef struct SherpaOnnxWave {
|
||||
// samples normalized to the range [-1, 1]
|
||||
const float *samples;
|
||||
|
||||
Reference in New Issue
Block a user