Skip to content

Commit c2bf248

Browse files
committed
[update] pack deb
1 parent 71fe7f2 commit c2bf248

43 files changed

Lines changed: 639 additions & 728 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ext_components/StackFlow/stackflow/StackFlowUtil.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,17 +265,37 @@ std::string StackFlows::unit_call(const std::string &unit_name, const std::strin
265265
return value;
266266
}
267267

268-
std::list<std::string> StackFlows::get_config_file_paths(const std::string &base_model_path,
268+
std::list<std::string> StackFlows::get_config_file_paths(std::string &base_model_path,
269+
std::string &base_model_config_path,
269270
const std::string &mode_name)
270271
{
271-
std::shared_ptr<std::string> base_path((std::string *)(&base_model_path), [](std::string *Npt) {});
272-
if (base_path->empty()) base_path = std::make_shared<std::string>("/opt/m5stack/data/");
272+
if (base_model_path.empty()) {
273+
base_model_path = sample_unescapeString(unit_call("sys", "sql_select", "config_base_mode_path"));
274+
if (base_model_path.empty()) {
275+
base_model_path = "/opt/m5stack/data/";
276+
}
277+
}
278+
if (base_model_config_path.empty()) {
279+
base_model_config_path = sample_unescapeString(unit_call("sys", "sql_select", "config_base_mode_config_path"));
280+
if (base_model_config_path.empty()) {
281+
base_model_config_path = "/opt/m5stack/etc/";
282+
}
283+
}
284+
std::string config_model_d = sample_unescapeString(unit_call("sys", "sql_select", "config_model_d"));
285+
if (config_model_d.empty()) config_model_d = "/opt/m5stack/data/models/";
286+
273287
std::list<std::string> config_file_paths;
274288
config_file_paths.push_back(std::string("./") + mode_name + ".json");
275-
config_file_paths.push_back(std::string("./asr_mode_") + mode_name + ".json");
276-
config_file_paths.push_back((*base_path) + "../share/" + mode_name + ".json");
277-
config_file_paths.push_back((*base_path) + "../share/asr_mode_" + mode_name + ".json");
278-
config_file_paths.push_back((*base_path) + mode_name + ".json");
279-
config_file_paths.push_back((*base_path) + "asr_mode_" + mode_name + ".json");
289+
config_file_paths.push_back(std::string("./mode_") + mode_name + ".json");
290+
config_file_paths.push_back(base_model_path + mode_name + std::string("/") + mode_name + ".json");
291+
config_file_paths.push_back(base_model_path + mode_name + std::string("/") + std::string("./mode_") + mode_name +
292+
".json");
293+
config_file_paths.push_back(config_model_d + mode_name + ".json");
294+
config_file_paths.push_back(config_model_d + std::string("./mode_") + mode_name + ".json");
295+
config_file_paths.push_back(base_model_config_path + mode_name + ".json");
296+
config_file_paths.push_back(base_model_config_path + std::string("./mode_") + mode_name + ".json");
297+
config_file_paths.push_back(base_model_path + std::string("../share/") + mode_name + ".json");
298+
config_file_paths.push_back(base_model_path + std::string("../share/") + std::string("./mode_") + mode_name +
299+
".json");
280300
return config_file_paths;
281301
}

ext_components/StackFlow/stackflow/StackFlowUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ bool decode_stream(const std::string &in, std::string &out, std::unordered_map<i
3232
int decode_base64(const std::string &in, std::string &out);
3333
int encode_base64(const std::string &in, std::string &out);
3434
std::string unit_call(const std::string &unit_name, const std::string &unit_action, const std::string &data);
35-
std::list<std::string> get_config_file_paths(const std::string &base_model_path, const std::string &mode_name);
35+
std::list<std::string> get_config_file_paths(std::string &base_model_path, std::string &base_model_config_path, const std::string &mode_name);
3636
}; // namespace StackFlows

projects/llm_framework/main_asr/SConstruct

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ INCLUDE += [ADir('../include/sherpa'), ADir('../include/sherpa/sherpa-ncnn')]
2424
LINK_SEARCH_PATH += [ADir('../static_lib/sherpa/ncnn')]
2525
REQUIREMENTS += ['ncnn', 'sherpa-ncnn-core']
2626

27-
STATIC_FILES += [AFile('sherpa-ncnn-streaming-zipformer-20M-2023-02-17.json'), AFile('sherpa-ncnn-streaming-zipformer-zh-14M-2023-02-23.json')]
28-
27+
STATIC_FILES += Glob('mode_*.json')
2928

3029
env['COMPONENTS'].append({'target':'llm_asr',
3130
'SRCS':SRCS,

projects/llm_framework/main_asr/sherpa-ncnn-streaming-zipformer-20M-2023-02-17.json renamed to projects/llm_framework/main_asr/mode_sherpa-ncnn-streaming-zipformer-20M-2023-02-17.json

File renamed without changes.

projects/llm_framework/main_asr/sherpa-ncnn-streaming-zipformer-zh-14M-2023-02-23.json renamed to projects/llm_framework/main_asr/mode_sherpa-ncnn-streaming-zipformer-zh-14M-2023-02-23.json

File renamed without changes.

projects/llm_framework/main_asr/src/main.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class llm_task {
9292
return -1;
9393
}
9494
nlohmann::json file_body;
95-
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, model_);
95+
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, base_model_config_path_, model_);
9696
try {
9797
for (auto file_name : config_file_paths) {
9898
std::ifstream config_file(file_name);
@@ -265,27 +265,11 @@ class llm_asr : public StackFlow {
265265
int task_count_;
266266
std::string audio_url_;
267267
std::unordered_map<int, std::shared_ptr<llm_task>> llm_task_;
268-
int _load_config()
269-
{
270-
if (base_model_path_.empty()) {
271-
base_model_path_ = sys_sql_select("config_base_mode_path");
272-
}
273-
if (base_model_config_path_.empty()) {
274-
base_model_config_path_ = sys_sql_select("config_base_mode_config_path");
275-
}
276-
if (base_model_path_.empty() || base_model_config_path_.empty()) {
277-
return -1;
278-
} else {
279-
SLOGI("llm_asr::_load_config success");
280-
return 0;
281-
}
282-
}
283268

284269
public:
285270
llm_asr() : StackFlow("asr")
286271
{
287272
task_count_ = 1;
288-
repeat_event(1000, std::bind(&llm_asr::_load_config, this));
289273
event_queue_.appendListener(
290274
EVENT_TASK_PAUSE, std::bind(&llm_asr::_task_pause, this, std::placeholders::_1, std::placeholders::_2));
291275
}

projects/llm_framework/main_audio/SConstruct

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ REQUIREMENTS += ['ax_sys', 'ax_interpreter', 'ax_audio', 'ax_audio_3a', 'ax_fdk'
2727
REQUIREMENTS += ['tinyalsa', 'opus', 'samplerate', 'fdk-aac']
2828

2929
STATIC_FILES += [AFile('audio.json')]
30+
STATIC_FILES += Glob('mode_*.json')
3031

3132
env['COMPONENTS'].append({'target':'llm_audio',
3233
'SRCS':SRCS,

projects/llm_framework/main_audio/src/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ class llm_audio : public StackFlow {
139139
nlohmann::json config_body;
140140
nlohmann::json file_body;
141141
nlohmann::json error_body;
142-
std::list<std::string> config_file_paths = get_config_file_paths("/opt/m5stack/data", "audio");
142+
std::string base_model_path;
143+
std::string base_model_config_path;
144+
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path, base_model_config_path, "audio");
143145
try {
144146
config_body = nlohmann::json::parse(data);
145147
for (auto file_name : config_file_paths) {

projects/llm_framework/main_camera/SConstruct

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/libzlib.a')]
4343
STATIC_LIB += static_file * 4
4444

4545
STATIC_FILES += [AFile('camera.json')]
46+
STATIC_FILES += Glob('mode_*.json')
4647

4748
env['COMPONENTS'].append({'target':'llm_camera',
4849
'SRCS':SRCS,

projects/llm_framework/main_kws/SConstruct

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ LDFLAGS += ['-l:libcargs.a', '-l:libonnxruntime.a',
3131
'-l:libsherpa-onnx-core.a', '-l:libkaldi-native-fbank-core.a',
3232
'-l:libkaldi-decoder-core.a', '-l:libssentencepiece_core.a']
3333

34-
STATIC_FILES += [AFile('sherpa-onnx-kws-zipformer-gigaspeech-3.3M-2024-01-01.json'),
35-
AFile('sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01.json')]
34+
STATIC_FILES += Glob('mode_*.json')
3635

3736
env['COMPONENTS'].append({'target':'llm_kws',
3837
'SRCS':SRCS,

0 commit comments

Comments
 (0)