mirror of
https://github.com/m5stack/StackFlow.git
synced 2026-05-20 11:32:11 -07:00
[update] pack deb
This commit is contained in:
@@ -265,17 +265,37 @@ std::string StackFlows::unit_call(const std::string &unit_name, const std::strin
|
||||
return value;
|
||||
}
|
||||
|
||||
std::list<std::string> StackFlows::get_config_file_paths(const std::string &base_model_path,
|
||||
std::list<std::string> StackFlows::get_config_file_paths(std::string &base_model_path,
|
||||
std::string &base_model_config_path,
|
||||
const std::string &mode_name)
|
||||
{
|
||||
std::shared_ptr<std::string> base_path((std::string *)(&base_model_path), [](std::string *Npt) {});
|
||||
if (base_path->empty()) base_path = std::make_shared<std::string>("/opt/m5stack/data/");
|
||||
if (base_model_path.empty()) {
|
||||
base_model_path = sample_unescapeString(unit_call("sys", "sql_select", "config_base_mode_path"));
|
||||
if (base_model_path.empty()) {
|
||||
base_model_path = "/opt/m5stack/data/";
|
||||
}
|
||||
}
|
||||
if (base_model_config_path.empty()) {
|
||||
base_model_config_path = sample_unescapeString(unit_call("sys", "sql_select", "config_base_mode_config_path"));
|
||||
if (base_model_config_path.empty()) {
|
||||
base_model_config_path = "/opt/m5stack/etc/";
|
||||
}
|
||||
}
|
||||
std::string config_model_d = sample_unescapeString(unit_call("sys", "sql_select", "config_model_d"));
|
||||
if (config_model_d.empty()) config_model_d = "/opt/m5stack/data/models/";
|
||||
|
||||
std::list<std::string> config_file_paths;
|
||||
config_file_paths.push_back(std::string("./") + mode_name + ".json");
|
||||
config_file_paths.push_back(std::string("./asr_mode_") + mode_name + ".json");
|
||||
config_file_paths.push_back((*base_path) + "../share/" + mode_name + ".json");
|
||||
config_file_paths.push_back((*base_path) + "../share/asr_mode_" + mode_name + ".json");
|
||||
config_file_paths.push_back((*base_path) + mode_name + ".json");
|
||||
config_file_paths.push_back((*base_path) + "asr_mode_" + mode_name + ".json");
|
||||
config_file_paths.push_back(std::string("./mode_") + mode_name + ".json");
|
||||
config_file_paths.push_back(base_model_path + mode_name + std::string("/") + mode_name + ".json");
|
||||
config_file_paths.push_back(base_model_path + mode_name + std::string("/") + std::string("./mode_") + mode_name +
|
||||
".json");
|
||||
config_file_paths.push_back(config_model_d + mode_name + ".json");
|
||||
config_file_paths.push_back(config_model_d + std::string("./mode_") + mode_name + ".json");
|
||||
config_file_paths.push_back(base_model_config_path + mode_name + ".json");
|
||||
config_file_paths.push_back(base_model_config_path + std::string("./mode_") + mode_name + ".json");
|
||||
config_file_paths.push_back(base_model_path + std::string("../share/") + mode_name + ".json");
|
||||
config_file_paths.push_back(base_model_path + std::string("../share/") + std::string("./mode_") + mode_name +
|
||||
".json");
|
||||
return config_file_paths;
|
||||
}
|
||||
@@ -32,5 +32,5 @@ bool decode_stream(const std::string &in, std::string &out, std::unordered_map<i
|
||||
int decode_base64(const std::string &in, std::string &out);
|
||||
int encode_base64(const std::string &in, std::string &out);
|
||||
std::string unit_call(const std::string &unit_name, const std::string &unit_action, const std::string &data);
|
||||
std::list<std::string> get_config_file_paths(const std::string &base_model_path, const std::string &mode_name);
|
||||
std::list<std::string> get_config_file_paths(std::string &base_model_path, std::string &base_model_config_path, const std::string &mode_name);
|
||||
}; // namespace StackFlows
|
||||
|
||||
@@ -24,8 +24,7 @@ INCLUDE += [ADir('../include/sherpa'), ADir('../include/sherpa/sherpa-ncnn')]
|
||||
LINK_SEARCH_PATH += [ADir('../static_lib/sherpa/ncnn')]
|
||||
REQUIREMENTS += ['ncnn', 'sherpa-ncnn-core']
|
||||
|
||||
STATIC_FILES += [AFile('sherpa-ncnn-streaming-zipformer-20M-2023-02-17.json'), AFile('sherpa-ncnn-streaming-zipformer-zh-14M-2023-02-23.json')]
|
||||
|
||||
STATIC_FILES += Glob('mode_*.json')
|
||||
|
||||
env['COMPONENTS'].append({'target':'llm_asr',
|
||||
'SRCS':SRCS,
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
return -1;
|
||||
}
|
||||
nlohmann::json file_body;
|
||||
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, model_);
|
||||
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, base_model_config_path_, model_);
|
||||
try {
|
||||
for (auto file_name : config_file_paths) {
|
||||
std::ifstream config_file(file_name);
|
||||
@@ -265,27 +265,11 @@ private:
|
||||
int task_count_;
|
||||
std::string audio_url_;
|
||||
std::unordered_map<int, std::shared_ptr<llm_task>> llm_task_;
|
||||
int _load_config()
|
||||
{
|
||||
if (base_model_path_.empty()) {
|
||||
base_model_path_ = sys_sql_select("config_base_mode_path");
|
||||
}
|
||||
if (base_model_config_path_.empty()) {
|
||||
base_model_config_path_ = sys_sql_select("config_base_mode_config_path");
|
||||
}
|
||||
if (base_model_path_.empty() || base_model_config_path_.empty()) {
|
||||
return -1;
|
||||
} else {
|
||||
SLOGI("llm_asr::_load_config success");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
llm_asr() : StackFlow("asr")
|
||||
{
|
||||
task_count_ = 1;
|
||||
repeat_event(1000, std::bind(&llm_asr::_load_config, this));
|
||||
event_queue_.appendListener(
|
||||
EVENT_TASK_PAUSE, std::bind(&llm_asr::_task_pause, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ REQUIREMENTS += ['ax_sys', 'ax_interpreter', 'ax_audio', 'ax_audio_3a', 'ax_fdk'
|
||||
REQUIREMENTS += ['tinyalsa', 'opus', 'samplerate', 'fdk-aac']
|
||||
|
||||
STATIC_FILES += [AFile('audio.json')]
|
||||
STATIC_FILES += Glob('mode_*.json')
|
||||
|
||||
env['COMPONENTS'].append({'target':'llm_audio',
|
||||
'SRCS':SRCS,
|
||||
|
||||
@@ -139,7 +139,9 @@ public:
|
||||
nlohmann::json config_body;
|
||||
nlohmann::json file_body;
|
||||
nlohmann::json error_body;
|
||||
std::list<std::string> config_file_paths = get_config_file_paths("/opt/m5stack/data", "audio");
|
||||
std::string base_model_path;
|
||||
std::string base_model_config_path;
|
||||
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path, base_model_config_path, "audio");
|
||||
try {
|
||||
config_body = nlohmann::json::parse(data);
|
||||
for (auto file_name : config_file_paths) {
|
||||
|
||||
@@ -43,6 +43,7 @@ static_file += [AFile('../static_lib/libopencv-4.6-aarch64-none/lib/libzlib.a')]
|
||||
STATIC_LIB += static_file * 4
|
||||
|
||||
STATIC_FILES += [AFile('camera.json')]
|
||||
STATIC_FILES += Glob('mode_*.json')
|
||||
|
||||
env['COMPONENTS'].append({'target':'llm_camera',
|
||||
'SRCS':SRCS,
|
||||
|
||||
@@ -31,8 +31,7 @@ LDFLAGS += ['-l:libcargs.a', '-l:libonnxruntime.a',
|
||||
'-l:libsherpa-onnx-core.a', '-l:libkaldi-native-fbank-core.a',
|
||||
'-l:libkaldi-decoder-core.a', '-l:libssentencepiece_core.a']
|
||||
|
||||
STATIC_FILES += [AFile('sherpa-onnx-kws-zipformer-gigaspeech-3.3M-2024-01-01.json'),
|
||||
AFile('sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01.json')]
|
||||
STATIC_FILES += Glob('mode_*.json')
|
||||
|
||||
env['COMPONENTS'].append({'target':'llm_kws',
|
||||
'SRCS':SRCS,
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
}
|
||||
|
||||
nlohmann::json file_body;
|
||||
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, model_);
|
||||
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, base_model_config_path_, model_);
|
||||
try {
|
||||
for (auto file_name : config_file_paths) {
|
||||
std::ifstream config_file(file_name);
|
||||
@@ -263,27 +263,11 @@ private:
|
||||
int task_count_;
|
||||
std::string audio_url_;
|
||||
std::unordered_map<int, std::shared_ptr<llm_task>> llm_task_;
|
||||
int _load_config()
|
||||
{
|
||||
if (base_model_path_.empty()) {
|
||||
base_model_path_ = sys_sql_select("config_base_mode_path");
|
||||
}
|
||||
if (base_model_config_path_.empty()) {
|
||||
base_model_config_path_ = sys_sql_select("config_base_mode_config_path");
|
||||
}
|
||||
if (base_model_path_.empty() || base_model_config_path_.empty()) {
|
||||
return -1;
|
||||
} else {
|
||||
SLOGI("llm_kws::_load_config success");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
llm_kws() : StackFlow("kws")
|
||||
{
|
||||
task_count_ = 1;
|
||||
repeat_event(1000, std::bind(&llm_kws::_load_config, this));
|
||||
}
|
||||
|
||||
void play_awake_wav(const std::string &wav_file)
|
||||
|
||||
@@ -34,14 +34,11 @@ static_file = Glob('../static_lib/module-llm/libabsl_*')
|
||||
static_file += [AFile('../static_lib/module-llm/libre2.a'), AFile('../static_lib/module-llm/libsentencepiece.a'), AFile('../static_lib/module-llm/libsentencepiece_train.a')]
|
||||
STATIC_LIB += static_file * 4
|
||||
|
||||
STATIC_FILES += [AFile('qwen2.5-0.5B-prefill-20e.json'),
|
||||
AFile('llama3.2-1B-prefill-ax630c.json'),
|
||||
AFile('openbuddy-llama3.2-1b-ax630c.json'),
|
||||
AFile('qwen2.5-coder-0.5B-ax630c.json'),
|
||||
AFile('llama3.2-1B-prefill-ax630c_tokenizer.py'),
|
||||
STATIC_FILES += [AFile('llama3.2-1B-prefill-ax630c_tokenizer.py'),
|
||||
AFile('openbuddy-llama3.2-1b-ax630c_tokenizer.py'),
|
||||
AFile('qwen2.5-coder-0.5B-ax630c_tokenizer.py')
|
||||
]
|
||||
STATIC_FILES += Glob('mode_*.json')
|
||||
|
||||
env['COMPONENTS'].append({'target':'llm_llm',
|
||||
'SRCS':SRCS,
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
return -1;
|
||||
}
|
||||
nlohmann::json file_body;
|
||||
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, model_);
|
||||
std::list<std::string> config_file_paths = get_config_file_paths(base_model_path_, base_model_config_path_, model_);
|
||||
try {
|
||||
for (auto file_name : config_file_paths) {
|
||||
std::ifstream config_file(file_name);
|
||||
@@ -230,27 +230,11 @@ class llm_llm : public StackFlow {
|
||||
private:
|
||||
int task_count_;
|
||||
std::unordered_map<int, std::shared_ptr<llm_task>> llm_task_;
|
||||
int _load_config()
|
||||
{
|
||||
if (base_model_path_.empty()) {
|
||||
base_model_path_ = sys_sql_select("config_base_mode_path");
|
||||
}
|
||||
if (base_model_config_path_.empty()) {
|
||||
base_model_config_path_ = sys_sql_select("config_base_mode_config_path");
|
||||
}
|
||||
if (base_model_path_.empty() || base_model_config_path_.empty()) {
|
||||
return -1;
|
||||
} else {
|
||||
SLOGI("llm_llm::_load_config success");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
llm_llm() : StackFlow("llm")
|
||||
{
|
||||
task_count_ = 2;
|
||||
repeat_event(1000, std::bind(&llm_llm::_load_config, this));
|
||||
}
|
||||
|
||||
void task_output(const std::weak_ptr<llm_task> llm_task_obj_weak,
|
||||
|
||||
@@ -26,7 +26,7 @@ REQUIREMENTS += ['onnxruntime', 'samplerate']
|
||||
INCLUDE += [ADir('../include')]
|
||||
INCLUDE += [ADir('src/runner'), ADir('../include/onnxruntime/core/session')]
|
||||
|
||||
STATIC_FILES += [AFile('melotts_zh-cn.json')]
|
||||
STATIC_FILES += Glob('mode_*.json')
|
||||
|
||||
env['COMPONENTS'].append({'target':'llm_melotts',
|
||||
'SRCS':SRCS,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user