Add C API for speaker embedding extractor. (#711)

This commit is contained in:
Fangjun Kuang
2024-03-28 18:05:40 +08:00
committed by GitHub
parent 638f48f47a
commit 2e0bccad36
23 changed files with 739 additions and 80 deletions

View File

@@ -55,14 +55,16 @@ void PybindOfflineTts(py::module *m) {
.def(
"generate",
[](const PyClass &self, const std::string &text, int64_t sid,
float speed, std::function<void(py::array_t<float>, float)> callback)
float speed,
std::function<void(py::array_t<float>, float)> callback)
-> GeneratedAudio {
if (!callback) {
return self.Generate(text, sid, speed);
}
std::function<void(const float *, int32_t, float)> callback_wrapper =
[callback](const float *samples, int32_t n, float progress) {
std::function<void(const float *, int32_t, float)>
callback_wrapper = [callback](const float *samples, int32_t n,
float progress) {
// CAUTION(fangjun): we have to copy samples since it is
// freed once the call back returns.