* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:14:43
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-11 14:35:27
+ * @LastEditTime: 2024-07-12 11:00:22
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
*/
#ifndef AI_VOICE_MODEL_H
#include "iostream"
#include "string"
#include "ChatContentItem.h"
+
+#define IS_AIAUDIO_TYPE_PCM 1 /*AI录音文件是否是pcm格式*/
namespace OHOS
{
AiVoiceModel(const AiVoiceModel &) = delete;
AiVoiceModel &operator=(const AiVoiceModel &) = delete;
- // 私有成员变量
+// 私有成员变量
+#if IS_AIAUDIO_TYPE_PCM
std::string AIAIAudioPath = "/user/userdata/AiRecording/AIAudio.pcm"; // AI录音的文件路径
- std::string userQuestionStr; // 用户提出的问题
- std::string aiAnswerStr; // AI回答的问题
- bool entryTimeoutFlag{false}; // 进入超时界面标志
- uint8_t ChatContentListCount{0}; // 列表数量
- static const uint16_t MaxChatContentListCount = 2; // 对话列表最大数量
- ChatContentItem chatTtems[MaxChatContentListCount] = {0, "", false}; // 对话项数组
- bool entryTextViewState{false}; // 进入返回结果界面的标志
+#else
+ std::string AIAIAudioPath = "/user/userdata/AiRecording/AIAudio.sbc"; // AI录音的文件路径
+#endif
+ std::string userQuestionStr; // 用户提出的问题
+ std::string aiAnswerStr; // AI回答的问题
+ bool entryTimeoutFlag{false}; // 进入超时界面标志
+ uint8_t ChatContentListCount{0}; // 列表数量
+ static const uint16_t MaxChatContentListCount = 2; // 对话列表最大数量
+ ChatContentItem chatTtems[MaxChatContentListCount] = {0, "", false}; // 对话项数组
+ bool entryTextViewState{false}; // 进入返回结果界面的标志
};
}
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:14:50
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-11 14:36:14
+ * @LastEditTime: 2024-07-12 10:59:18
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
*/
#include "aivoice/include/AiVoiceModel.h"
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_delete_files fail!!");
}
+#if IS_AIAUDIO_TYPE_PCM
const char *defaultArgs[6] = {"01", "pcm", "16000", "1", "16", audioPath.c_str()};
+#else
+ const char *defaultArgs[6] = {"01", "sbc", "16000", "1", "16", audioPath.c_str()};
+#endif
AudioCaptureSample(6, (const char **)defaultArgs);
}
return;
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-06-20 15:11:17
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-09 18:27:33
+ * @LastEditTime: 2024-07-12 10:49:59
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
*/
#include "AppViewIDs.h"
if (showView == AIVOICE_THINKING_VIEWID) // 聆听中->思考中界面
{
// osal_msleep(500);
- //model->CheckFileAndSendAIIsReady();
+ // model->CheckFileAndSendAIIsReady();
model->AIVoice_StartTimer();
}
else if (showView == AIVOICE_STARTCHAT_VIEWID) // 聆听中->开始对话界面:(右滑不想录音了)
// view_->ChangeView(AIVOICE_THINKING_VIEWID, AIVOICE_STARTCHAT_VIEWID); // 思考中->开始对话界面
ChangeViewAndLogicOperator(AIVOICE_THINKING_VIEWID, AIVOICE_STARTCHAT_VIEWID);
}
+ else if (scrollView == view_->GetAiVoiceScrollView(AIVOICE_CONNECT_TIMEOUT_VIEWID))
+ {
+ // view_->ChangeView(AIVOICE_THINKING_VIEWID, AIVOICE_STARTCHAT_VIEWID); // 连接超时->开始对话界面
+ ChangeViewAndLogicOperator(AIVOICE_CONNECT_TIMEOUT_VIEWID, AIVOICE_STARTCHAT_VIEWID);
+ }
AiVoicePresenter::X_DRAG_FLAG = false;
}
return true;
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-05-07 11:25:58
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-03 09:34:11
+ * @LastEditTime: 2024-07-12 11:18:00
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceConnectTimeoutView.cpp
*/
#include "aivoice/include/AiVoicePresenter.h"
#include <UiConfig.h>
namespace OHOS
{
+ static constexpr const int16_t LABEL_ROLL_SPEED = 70;
static AivoiceConnectTimeoutView *g_pAivoiceConnectTimeoutView{nullptr};
if (label[i] != nullptr)
{
delete label[i];
- label[i];
+ label[i] = nullptr;
}
}
label->SetLineBreakMode(labelconfig.lineBreakMode);
label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);
+ label->SetRollSpeed(LABEL_ROLL_SPEED);
return label;
}
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceConnectTimeoutView::scrollView new fail!");
return false;
}
+ UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(AiVoicePresenter::GetInstance());
+ if (dragListener == nullptr)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AivoiceThinkingView::dragListener new fail!");
+ return false;
+ }
+ scrollView->SetOnDragListener(dragListener);
scrollView->SetPosition(0, 0, 466, 466);
scrollView->SetTouchable(true);
scrollView->SetDraggable(true);
.fontSize = 30,
.lineHeigh = 35,
.textId = STR_AI_INTELLIGENT_ASSISTANT,
- .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
+ .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
};
title = AivoiceConnectTimeoutLabelInit(labelconfig);
if (title == nullptr)
labelconfig.left = 53;
labelconfig.width = 360;
int textId[] = {STR_CONNECT_TIMEOUT, STR_PLEASE_RESTART_CHAT};
- for (int i = 0; i < sizeof(textId) / sizeof(textId[0]); i++)
+ for (int i = 0; i < 2; i++)
{
labelconfig.top = 222 + i * labelconfig.height;
labelconfig.textId = textId[i];
* @Author: luozheng 1732036298@qq.com
* @Date: 2024-05-07 11:25:58
* @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-05 20:24:47
+ * @LastEditTime: 2024-07-12 11:14:36
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceReturnResultTextView.cpp
*/
#include "aivoice/include/AiVoicePresenter.h"
static constexpr const int16_t ONE_HALF_NUM = 2;
+ static constexpr const int16_t LABEL_ROLL_SPEED = 70;
+
static AivoiceReturnResultTextView *g_pAivoiceReturnResultTextView{nullptr};
AivoiceReturnResultTextView::AivoiceReturnResultTextView()
label->SetLineBreakMode(labelconfig.lineBreakMode);
label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);
+ label->SetRollSpeed(LABEL_ROLL_SPEED);
return label;
}
.fontSize = 30,
.lineHeight = 35,
.textId = STR_AI_INTELLIGENT_ASSISTANT,
- .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
+ .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
};
title = AivoiceReturnResultTextLabelInit(labelconfig);
if (title == nullptr)
.fontSize = 30,
.lineHeight = 35,
.textId = STR_CONTINUE_CHAT,
- .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
+ .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
};
continueChat = AivoiceReturnResultTextLabelInit(labelconfig);
if (continueChat == nullptr)