|
@@ -271,6 +271,7 @@ void Application::ToggleChatState() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//开启音频
|
|
|
void Application::StartListening() {
|
|
void Application::StartListening() {
|
|
|
if (device_state_ == kDeviceStateActivating) {
|
|
if (device_state_ == kDeviceStateActivating) {
|
|
|
SetDeviceState(kDeviceStateIdle);
|
|
SetDeviceState(kDeviceStateIdle);
|
|
@@ -461,6 +462,7 @@ void Application::Start() {
|
|
|
SetDeviceState(kDeviceStateIdle);
|
|
SetDeviceState(kDeviceStateIdle);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
+ //后台控制指令
|
|
|
protocol_->OnIncomingJson([this, display](const cJSON* root) {
|
|
protocol_->OnIncomingJson([this, display](const cJSON* root) {
|
|
|
// Parse JSON data
|
|
// Parse JSON data
|
|
|
auto type = cJSON_GetObjectItem(root, "type");
|
|
auto type = cJSON_GetObjectItem(root, "type");
|
|
@@ -853,8 +855,21 @@ void Application::SetDeviceState(DeviceState state) {
|
|
|
display->SetStatus(Lang::Strings::SPEAKING);
|
|
display->SetStatus(Lang::Strings::SPEAKING);
|
|
|
ResetDecoder();
|
|
ResetDecoder();
|
|
|
codec->EnableOutput(true);
|
|
codec->EnableOutput(true);
|
|
|
|
|
+ //成功打断,但是8次左右,系统会崩溃
|
|
|
|
|
+ Schedule([this]() {
|
|
|
|
|
+ if (device_state_ == kDeviceStateSpeaking) {
|
|
|
|
|
+ background_task_->WaitForCompletion();
|
|
|
|
|
+ if (keep_listening_) {
|
|
|
|
|
+ protocol_->SendStartListening(kListeningModeAutoStop);
|
|
|
|
|
+ // SetDeviceState(kDeviceStateListening);
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ SetDeviceState(kDeviceStateIdle);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
#if CONFIG_USE_AUDIO_PROCESSOR
|
|
#if CONFIG_USE_AUDIO_PROCESSOR
|
|
|
- audio_processor_.Stop();
|
|
|
|
|
|
|
+ // audio_processor_.Stop();
|
|
|
#endif
|
|
#endif
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|