diff --git a/src/speech_service.cpp b/src/speech_service.cpp index 1ef48f21..3f2fc2ee 100644 --- a/src/speech_service.cpp +++ b/src/speech_service.cpp @@ -1483,7 +1483,8 @@ void speech_service::handle_speech_to_file(const tts_partial_result_t &result) { } m_current_task->counter.value += result.text.size(); - m_current_task->files.push_back(result.wav_file_path); + if (!result.wav_file_path.isEmpty()) + m_current_task->files.push_back(result.wav_file_path); qDebug() << "partial speech to file progress:" << m_current_task->counter.progress(); @@ -1556,11 +1557,27 @@ void speech_service::handle_tts_queue() { auto &result = m_tts_queue.front(); - m_player.setMedia(QMediaContent{QUrl::fromLocalFile(result.wav_file_path)}); + if (!result.wav_file_path.isEmpty()) { + m_player.setMedia( + QMediaContent{QUrl::fromLocalFile(result.wav_file_path)}); - m_player.play(); + m_player.play(); - emit tts_partial_speech_playing(result.text, result.task_id); + emit tts_partial_speech_playing(result.text, result.task_id); + } else if (result.last) { + auto task = result.task_id; + + tts_stop_speech(task); + if (m_tts_queue.empty()) { + emit tts_partial_speech_playing("", task); + } else { + m_tts_queue.pop(); + } + emit tts_play_speech_finished(task); + } else { + if (!m_tts_queue.empty()) m_tts_queue.pop(); + handle_tts_queue(); + } } void speech_service::handle_tts_engine_error() { diff --git a/src/tts_engine.cpp b/src/tts_engine.cpp index 4f85dfff..7892a89e 100644 --- a/src/tts_engine.cpp +++ b/src/tts_engine.cpp @@ -454,8 +454,12 @@ void tts_engine::process() { if (!encode_speech_impl(new_text, output_file)) { unlink(output_file.c_str()); - if (m_call_backs.error) m_call_backs.error(); - break; + LOGE("speech encoding error"); + if (m_call_backs.speech_encoded) { + m_call_backs.speech_encoded("", "", task.last); + } + + continue; } if (!model_supports_speed()) apply_speed(output_file);