Skip to content

Commit 423427d

Browse files
author
LittleMouse
committed
[update] update model ctx len
1 parent a3d0913 commit 423427d

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

projects/llm_framework/main_cosy_voice/models/mode_CosyVoice2-0.5B-ax650.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"n_timesteps": 10,
5555
"b_use_mmap_load_embed": true,
5656
"b_dynamic_load_axmodel_layer": false,
57-
"precompute_len": 100,
57+
"precompute_len": 200,
5858
"cmm_size": 1227676,
5959
"ext_scripts": [
6060
"tokenizer_CosyVoice2-0.5B-ax650.py",

projects/llm_framework/main_cosy_voice/src/main.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <unistd.h>
1616
#include <base64.h>
1717
#include <fstream>
18+
#include <future>
1819
#include <stdexcept>
1920
#include <samplerate.h>
2021
#include <semaphore.h>
@@ -407,22 +408,36 @@ class llm_task {
407408
timer time_total;
408409
time_total.start();
409410
try {
410-
int llm_ret = 0;
411-
auto llm_thread_func = [this, &text, &prompt_text_embeds, &prompt_speech_embeds, &llm_ret]() {
411+
int llm_ret = 0;
412+
std::promise<int> prom;
413+
std::future<int> fut = prom.get_future();
414+
auto llm_thread_func = [this, &text, &prompt_text_embeds, &prompt_speech_embeds, &llm_ret, &prom]() {
412415
llm_ret = lLaMa_->Run(text, prompt_text_embeds, prompt_speech_embeds, g_token_buffer, g_buffer_mutex,
413416
g_buffer_cv, g_llm_finished);
417+
prom.set_value(llm_ret);
414418
};
415419
std::thread llm_thread(llm_thread_func);
416420
llm_thread.detach();
421+
422+
if (fut.wait_for(std::chrono::milliseconds(10)) == std::future_status::ready) {
423+
int llm_ret = fut.get();
424+
if (llm_ret == -1) {
425+
SLOGE("Error, Generate failed");
426+
if (out_callback_) out_callback_("Error, Generate failed", true);
427+
return llm_ret;
428+
}
429+
}
430+
417431
int prompt_token_len = prompt_speech_embeds_flow.size() / lToken2Wav._attr.flow_embed_size;
418432
if (prompt_token_len < 75) {
419433
SLOGE("Error, prompt speech token len %d < 75", prompt_token_len);
420434
if (llm_thread.joinable()) llm_thread.join();
435+
if (out_callback_) {
436+
out_callback_("Error, prompt speech token len %d < 75", true);
437+
}
421438
return -1;
422439
}
423-
if (llm_ret == -1) {
424-
return llm_ret;
425-
}
440+
426441
int prompt_token_align_len = 75;
427442
std::vector<float> prompt_speech_embeds_flow1;
428443
prompt_speech_embeds_flow1.insert(prompt_speech_embeds_flow1.begin(), prompt_speech_embeds_flow.begin(),

0 commit comments

Comments
 (0)