void SetIsLimitDisplayed(bool value);
bool GetIsLimitDisplayed(void);
+ void SetAI_4G_state(bool state);
+ bool GetAI_4G_state(void);
+ void SetAI_BT_state(bool state);
+ bool GetAI_BT_state(void);
+
private:
AiVoiceModel();
~AiVoiceModel();
int16_t curView{0};
bool isClickable{false};
bool isLimitDisplayed{false};//AI答案是否显示到极限了
+
+ bool AI_4G_state{false}; //4gAI状态
+ bool AI_BT_state{false}; //蓝牙AI状态
};
}
#include <sys/stat.h>
#include "bleService.h"
#include <custom_save_runtime.h>
+#include "cat1_ws.h"
namespace OHOS
{
// 声明定时器变量
if (it != selectAiModelToTextId.end())
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[QuerySelectedAiModelIsConnect] SelectAiModel = %d", it->second.second);
- inquire_AI_is_ready(it->second.second);
+ if(GetAI_4G_state() == true)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[QuerySelectedAiModelIsConnect] GetAI_4G_state = true");
+ uapi_start_asr();
+ }
+ else
+ {
+ inquire_AI_is_ready(it->second.second);
+ }
}
}
int32_t argc = 1;
uint8_t *argv = (uint8_t *)"stop";
AudioCaptureSample(argc, (const char **)&argv);
+ if(GetAI_4G_state() == true){
+ uapi_stop_asr();
+ }
uapi_save_runtime_log(RUNTIME_LOG_RECORD_STOP_AI);//TOOD*
return;
}
return ConfigModel::GetInstance()->GetSelectAiModel();
}
+ void AiVoiceModel::SetAI_4G_state(bool state)
+ {
+ AI_4G_state = state;
+ }
+ bool AiVoiceModel::GetAI_4G_state(void)
+ {
+ return AI_4G_state;
+ }
+ void AiVoiceModel::SetAI_BT_state(bool state)
+ {
+ AI_BT_state = state;
+ }
+ bool AiVoiceModel::GetAI_BT_state(void)
+ {
+ return AI_BT_state;
+ }
+
/*获取已选择的ai模型的textid*/
int AiVoiceModel::GetAiModelTextId()
{
#include "bleService.h"
#include "player/include/PlayersModel.h"
+#include "cat1_ws.h"
+
namespace OHOS
{
#define BLE_CONNECT_INTERVAL_HIGH_AI 10
bool appBluetoothConnectState = model->GetAPPBluetoothIsConnect();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "netWork4GState = %d,appBluetoothConnectState = %d", netWork4GState, appBluetoothConnectState);
+ //暂时4g可以用
+ netWork4GState = true;
+ model->SetAI_4G_state(netWork4GState);
+
if (netWork4GState) // 1.手表4G网络正常
{
// 通过4G调用大模型
+ ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_AIMODE_CONNECTING); // LOADING
}
else if (appBluetoothConnectState) // 3.只有与APP蓝牙连接正常
{
WebSocketClient *asr_client;
-//
-
-void uapi_start_asr()
+//查询是否可以对话
+void uapi_start_asr(void)
{
char *jsonString = "{\"header\":{\"event\":\"StartTranscription\",\"trace_id\": \
\"3fa6b9e6a30b407ea38ad7ae69e6c291\"},\"payload\":{\"format\":\"MP3\",\"sample_rate\":16000}}";
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_websocket_message succ erro\n");
}
-void uapi_stop_asr()
+//停止对话
+void uapi_stop_asr(void)
{
char *jsonString ="{\"header\":{\"event\":\"StopTranscription\",\"trace_id\":\"3fa6b9e6a30b407ea38ad7ae69e6c291\"}}";
fclose(fp);
}
#include "audio_capture_wrapper.h"
+#include <ui_service.h>
// {"status":20000000,"msg":"success","task_id":"80228c9f62821ffe3f867e1a5042d887","event":"TranscriptionStarted","result":null}
// {"status":20000000,
}
if(strcmp(event_str,"TranscriptionStarted")==0)
{
- streamingRecordAndSend_AI(0);
+ //查询结果
+ // streamingRecordAndSend_AI(0);
+ bool state = true;
+ SendMsgToUIService(UI_AI_JUMP_TO_LISTENING_VIEW, 0, &state, sizeof(bool));
}
cJSON_Delete(root);
--- /dev/null
+#ifndef __CAT1_WS_H__
+#define __CAT1_WS_H__
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+void uapi_start_asr(void);
+
+void uapi_stop_asr(void);
+
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+#endif
\ No newline at end of file