@@ -10,7 +10,7 @@ Application::Application(const Configure &configure, bool setting) {
1010 translator = CreateRef<Translate>(configure.baiDuTranslator );
1111 if (configure.claude .enable ) {
1212 bot = CreateRef<Claude>(configure.claude );
13- convid = " ClaudeOnly " ;
13+ convid = " Claude " ;
1414 ClaudeHitsory ();
1515 } else {
1616 bot = CreateRef<ChatGPT>(configure.openAi );
@@ -29,8 +29,12 @@ Application::Application(const Configure &configure, bool setting) {
2929 Utils::SaveFile (live2D.model , " Lconfig.txt" );
3030 Utils::OpenProgram (live2D.bin .c_str ());
3131 }
32- if (whisperData.enable && whisper && mwhisper)
32+ if (whisperData.enable && whisper && mwhisper) {
3333 listener->listen ();
34+ }
35+ if (vits) {
36+ VitsListener ();
37+ }
3438}
3539
3640GLuint Application::load_texture (const char *path) {
@@ -57,20 +61,33 @@ void Application::Vits(std::string text) {
5761 task.config = Utils::GetAbsolutePath (vitsData.config );
5862 task.text = text;
5963 task.sid = vitsData.speaker_id ;
60- static bool is_playing = false ;
6164 Utils::SaveYaml (" task.yaml" , Utils::toYaml (task));
65+ }
66+
67+ void Application::VitsListener () {
68+ static bool is_playing = false ;
6269
6370 std::thread ([&]() {
64- std::string result = Utils::exec (Utils::GetAbsolutePath (bin + VitsConvertor + " VitsConvertor" + exeSuffix));
71+ std::thread ([&]() {
72+ Utils::exec (Utils::GetAbsolutePath (bin + VitsConvertor + " VitsConvertor" + exeSuffix));
73+ }).detach ();
74+ VitsTask task;
75+ while (AppRunning) {
76+ // std::string result = Utils::exec(Utils::GetAbsolutePath(bin + VitsConvertor + "VitsConvertor" + exeSuffix));
77+
78+ // if (result.find("Synthesized and saved!")) {
79+ if (UFile::Exists (task.outpath )) {
80+ // 等待音频完成后再播放下一个
81+ while (is_playing) {
82+ std::this_thread::sleep_for (std::chrono::milliseconds (100 ));
83+ }
84+ is_playing = true ;
85+ listener->playRecorded (whisperData.enable );
86+ is_playing = false ;
6587
66- if (result.find (" Successfully saved!" )) {
67- // 等待音频完成后再播放下一个
68- while (is_playing) {
69- std::this_thread::sleep_for (std::chrono::milliseconds (100 ));
88+ std::remove (task.outpath .c_str ());
7089 }
71- is_playing = true ;
72- listener->playRecorded (whisperData.enable );
73- is_playing = false ;
90+ // }
7491 }
7592 }).detach ();
7693}
@@ -93,7 +110,8 @@ void Application::render_code_box() {
93110 style.Colors [ImGuiCol_ScrollbarGrabHovered] = ImVec4 (0 .8f , 0 .8f , 0 .8f , 1 .0f );
94111 style.Colors [ImGuiCol_ScrollbarGrabActive] = ImVec4 (0 .9f , 0 .9f , 0 .9f , 1 .0f );
95112
96- ImGui::Begin (" Code Box" , nullptr , ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoTitleBar);
113+ ImGui::Begin (" Code Box" , nullptr ,
114+ ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoTitleBar);
97115 ImGui::PushStyleVar (ImGuiStyleVar_FrameRounding, 5 .0f );
98116
99117 static bool show_codes = false ;
@@ -319,6 +337,9 @@ void Application::render_chat_box() {
319337 if (ImGui::Button (reinterpret_cast <const char *>(u8" 重置会话" ), ImVec2 (200 , 30 ))) {
320338 chat_history.clear ();
321339 bot->Reset ();
340+ if (configure.claude .enable ){
341+ FirstTime = Utils::getCurrentTimestamp ();
342+ }
322343 save (convid);
323344 }
324345 if (ImGui::Button (reinterpret_cast <const char *>(u8" 删除当前会话" ), ImVec2 (200 , 30 )) &&
@@ -554,7 +575,8 @@ void Application::render_input_box() {
554575 ImGui::SetClipboardText (i.c_str ());
555576 }
556577 if (vits && vitsData.enable ) {
557- std::string VitsText = translator->translate (Utils::ExtractNormalText (response), vitsData.lanType );
578+ std::string VitsText = translator->translate (Utils::ExtractNormalText (response),
579+ vitsData.lanType );
558580 Vits (VitsText);
559581 } else if (whisperData.enable ) {
560582 listener->listen ();
@@ -633,7 +655,8 @@ void Application::render_setting_box() {
633655 TEXT_BUFFER );
634656 ImGui::Checkbox (reinterpret_cast <const char *>(u8" 使用远程代理" ), &configure.openAi .useWebProxy );
635657 if (!configure.openAi .useWebProxy )
636- ImGui::InputText (reinterpret_cast <const char *>(u8" 对OpenAI使用的代理" ), configure.openAi .proxy .data (),
658+ ImGui::InputText (reinterpret_cast <const char *>(u8" 对OpenAI使用的代理" ),
659+ configure.openAi .proxy .data (),
637660 TEXT_BUFFER );
638661 else {
639662 if (ImGui::BeginCombo (reinterpret_cast <const char *>(u8" 远程代理" ),
@@ -747,13 +770,15 @@ void Application::render_setting_box() {
747770 if (ImGui::CollapsingHeader (" VITS" )) {
748771 static char search_text[256 ] = " " ;
749772 ImGui::Checkbox (reinterpret_cast <const char *>(u8" 启用Vits" ), &configure.vits .enable );
750- ImGui::InputText (reinterpret_cast <const char *>(u8" Vits 模型位置" ), configure.vits .model .data (), TEXT_BUFFER );
773+ ImGui::InputText (reinterpret_cast <const char *>(u8" Vits 模型位置" ), configure.vits .model .data (),
774+ TEXT_BUFFER );
751775 ImGui::InputText (reinterpret_cast <const char *>(u8" Vits 配置文件位置" ), configure.vits .config .data (),
752776 TEXT_BUFFER );
753777 ImGui::InputText (reinterpret_cast <const char *>(u8" Vits的语言类型" ), configure.vits .lanType .data (),
754778 TEXT_BUFFER );
755779 // 开始下拉列表
756- if (ImGui::BeginCombo (reinterpret_cast <const char *>(u8" 角色" ), speakers[configure.vits .speaker_id ].c_str ())) {
780+ if (ImGui::BeginCombo (reinterpret_cast <const char *>(u8" 角色" ),
781+ speakers[configure.vits .speaker_id ].c_str ())) {
757782 // 在下拉框中添加一个文本输入框
758783 ImGui::InputTextWithHint (" ##Search" , reinterpret_cast <const char *>(u8" 搜索" ), search_text,
759784 sizeof (search_text));
@@ -1363,7 +1388,8 @@ void Application::RuntimeDetector() {
13631388 reinterpret_cast <const char *>(u8" 安装VitsConvertor成功" ));
13641389 } else if (!mwhisper) {
13651390 ShowConfirmationDialog (reinterpret_cast <const char *>(u8" 下载通知" ),
1366- reinterpret_cast <const char *>(u8" 检测到你并没安装Whisper Model,是否下载?" ), mwhisper,
1391+ reinterpret_cast <const char *>(u8" 检测到你并没安装Whisper Model,是否下载?" ),
1392+ mwhisper,
13671393 [this ]() { WhisperModelDownload (Utils::GetFileName (whisperData.model )); },
13681394 reinterpret_cast <const char *>(u8" 安装Whisper Model失败" ),
13691395 reinterpret_cast <const char *>(u8" 安装Whisper Model成功" ));
0 commit comments