| | |
| | | Schedule([this]() { |
| | | // Play the success sound to indicate the device is ready |
| | | audio_service_.PlaySound(Lang::Sounds::OGG_SUCCESS); |
| | | Board::GetInstance().OnDeviceReady(); |
| | | }); |
| | | } |
| | | |
| | |
| | | |
| | | void Application::StopListening() { |
| | | xEventGroupSetBits(event_group_, MAIN_EVENT_STOP_LISTENING); |
| | | } |
| | | |
| | | void Application::SendListenDetect(const std::string& text, bool open_if_idle) { |
| | | Schedule([this, text, open_if_idle]() { |
| | | if (!protocol_ || text.empty()) { |
| | | return; |
| | | } |
| | | if (protocol_->IsAudioChannelOpened()) { |
| | | protocol_->SendWakeWordDetected(text); |
| | | return; |
| | | } |
| | | if (open_if_idle) { |
| | | WakeWordInvoke(text); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | void Application::HandleToggleChatEvent() { |
| | |
| | | SetDeviceState(kDeviceStateIdle); |
| | | } |
| | | audio_service_.EnableWakeWordDetection(true); |
| | | BoardMqtt_ResumePlaylistIfUnfinished(); |
| | | if (!Board::GetInstance().OnRestoredFromPowerOff(network_ready)) { |
| | | BoardMqtt_ResumePlaylistIfUnfinished(); |
| | | } |
| | | }); |
| | | } |
| | | |