Enable to stop TTS generation (#1041)

This commit is contained in:
Fangjun Kuang
2024-06-22 18:18:36 +08:00
committed by GitHub
parent 96ab843173
commit 9dd0e03568
32 changed files with 249 additions and 70 deletions

View File

@@ -44,13 +44,20 @@ static void Handler(int32_t /*sig*/) {
fprintf(stderr, "\nCaught Ctrl + C. Exiting\n");
}
static void AudioGeneratedCallback(const float *s, int32_t n,
float /*progress*/) {
static int32_t AudioGeneratedCallback(const float *s, int32_t n,
float /*progress*/) {
if (n > 0) {
std::lock_guard<std::mutex> lock(g_buffer.mutex);
g_buffer.samples.push({s, s + n});
g_cv.notify_all();
}
if (g_killed) {
return 0; // stop generating
}
// continue generating
return 1;
}
static void StartPlayback(const std::string &device_name, int32_t sample_rate) {