void ble_set_ai_Question_str_(char *buf)
{
+ printf("ble_set_ai_Question_str_ %s\n",buf);
OHOS::AiVoiceModel::GetInstance().SetUserQuestionStr(std::string(buf));
}
void ble_set_ai_Answer_str_(char *buf, uint8_t type)
{
- chat_filter_result_chars(buf);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ble_set_ai_Answer_str_:%s,type:%d",buf,type);
+ // chat_filter_result_chars(buf);
OHOS::AiVoiceModel::GetInstance().SetAiAnswerStrStr(std::string(buf), type);
}
bleInstruct_t.ble_app_reply = ble_app_reply_;
}
+ /*
+ * WebSocket 聊天结果过滤回调包装,匹配 ws_register_chat_filter_callback 的签名
+ */
+ static void ws_chat_filter_cb_wrapper(char *result)
+ {
+ /* 复用现有过滤实现,忽略返回长度 */
+ chat_filter_result_chars(result);
+ }
+
+ void net4g_AI_init(void)
+ {
+ ws_register_chat_filter_callback(ws_chat_filter_cb_wrapper);
+ ws_register_ai_question_callback(ble_set_ai_Question_str_);
+ ws_register_ai_answer_callback(ble_set_ai_Answer_str_);
+ }
+
#endif
#ifdef __cplusplus
#include <asm/delay.h>
#include <aivoice/include/AiVoiceModelC.h>
#include <los_base.h>
- extern void set_need_tts_reconnect(uint8_t flag);
void remove_4GAI_vote(void)
{
void AiVoicePresenter::OnStart()
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnStart");
- Presenter<AiVoiceView>::OnStart();
ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);
// 开启一个60s取消长亮屏timer
model->ai_start_screen60s_timer();
add_4GAI_vote(); // 4g投票
+ net4g_AI_init();
uapi_ble_connect_param_update(BLE_CONNECT_INTERVAL_HIGH_AI);
Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_ASSISTANT, 100);
}
void AiVoicePresenter::OnStop(void)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnStop start");
- Presenter<AiVoiceView>::OnStop();
ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);
model->StatusResume();
model->AIVoice_StopTimer();
uapi_stop_all_websocket_servers();
uapi_destroy_all_websocket_servers();
#endif
-
- // dinit_ai_task();
- // ai_cleanup_resources();
uapi_ble_connect_param_update(BLE_CONNECT_INTERVAL_SLOW);
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnStop end");
break;
case AIVOICE_RETURN_RESULT_TEXT_VIEWID:
- // set_need_tts_reconnect(0); // 停止tts重连
AiVoiceModel::GetInstance().ClearQuestionAndAiAnswerStr(); // 清空上次用户问题和Ai回答字符串
AiVoiceModel::GetInstance().SetIsClickable(false);
AiVoiceModel::GetInstance().SetIsLimitDisplayed(false);
AiVoiceModel::GetInstance().start_ai_isready_timer();
break;
case AIVOICE_RETURN_RESULT_TEXT_VIEWID:
- // set_need_tts_reconnect(1); // 开始tts重连
break;
case AIVOICE_LISTENING_VIEWID:
- // set_stop_send_ai_flag(0); // 开始发送AI数据
AiVoiceModel::GetInstance().StartListenAndRecordingUserQuestion();
AiVoiceModel::GetInstance().start_listening_timer();
break;
}
MEDIA_INFO_LOG("sessionId:%d", sessionId);
g_captureInterruptListener = std::make_shared<CaptureInterruptListener>();
- g_sample.interrupt = { g_streamType, sessionId, g_captureInterruptListener };
- // g_sample.interrupt = { AUDIO_STREAM_VOICE_ASSISTANT, sessionId, g_captureInterruptListener };
+ g_sample.interrupt = { AUDIO_STREAM_VOICE_RECORD, sessionId, g_captureInterruptListener };
if (g_amInstance.ActivateAudioInterrupt(g_sample.interrupt) == INTERRUPT_FAILED) {
}
audioCapturerInfo.sessionID = sessionId;
audioCapturerInfo.inputSource = AUDIO_MIC;
- audioCapturerInfo.streamType = g_streamType;
- // audioCapturerInfo.streamType = AUDIO_STREAM_VOICE_ASSISTANT;
+ audioCapturerInfo.streamType = AUDIO_STREAM_VOICE_RECORD;
ret = AudioCaptureSetInfo(audioCapturerInfo);
if (ret != 0) {
MEDIA_ERR_LOG("AudioCapture set failed");