Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e62b27

Browse files
authored
Merge pull request #29 from m5stack/dev
Dev
2 parents bbe8371 + 3c8885b commit 0e62b27

27 files changed

+442
-2
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"M5GFX": "*",
1515
"ArduinoJson": "*"
1616
},
17-
"version": "1.6.0",
17+
"version": "1.7.0",
1818
"frameworks": "arduino",
1919
"platforms": "espressif32"
2020
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=M5ModuleLLM
2-
version=1.6.0
2+
version=1.7.0
33
author=M5Stack
44
maintainer=M5Stack
55
sentence=M5ModuleLLM is a library for M5ModuleLLM

src/api/api_asr.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ String ApiAsr::setup(ApiAsrSetupConfig_t config, String request_id, String langu
3838
}
3939
}
4040
if (language == "zh_CN") doc["data"]["model"] = "sherpa-ncnn-streaming-zipformer-zh-14M-2023-02-23";
41+
42+
for (const auto& pair : config.extra_params) {
43+
const String& key = pair.first;
44+
const String& value = pair.second;
45+
46+
if (value == "bool_true") {
47+
doc["data"][key] = true;
48+
} else if (value == "bool_false") {
49+
doc["data"][key] = false;
50+
} else if (value.indexOf('.') != -1) {
51+
doc["data"][key] = value.toFloat();
52+
} else if (value.length() > 0 && (isDigit(value.charAt(0)) || value.charAt(0) == '-')) {
53+
doc["data"][key] = value.toInt();
54+
} else {
55+
doc["data"][key] = value;
56+
}
57+
}
4158
serializeJson(doc, cmd);
4259
}
4360

src/api/api_asr.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ struct ApiAsrSetupConfig_t {
1818
float rule1 = 2.4;
1919
float rule2 = 1.2;
2020
float rule3 = 30.0;
21+
22+
std::map<String, String> extra_params;
23+
24+
template <typename T>
25+
void setParam(const String& key, T value)
26+
{
27+
extra_params[key] = String(value);
28+
}
29+
30+
void setParam(const String& key, bool value)
31+
{
32+
extra_params[key] = value ? "bool_true" : "bool_false";
33+
}
34+
35+
void setParam(const String& key, float value)
36+
{
37+
char buffer[16];
38+
dtostrf(value, 1, 6, buffer);
39+
extra_params[key] = String(buffer);
40+
}
2141
};
2242

2343
class ApiAsr {

src/api/api_audio.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ String ApiAudio::setup(ApiAudioSetupConfig_t config, String request_id)
2727
doc["data"]["playcard"] = config.playcard;
2828
doc["data"]["playdevice"] = config.playdevice;
2929
doc["data"]["playVolume"] = config.playVolume;
30+
31+
for (const auto& pair : config.extra_params) {
32+
const String& key = pair.first;
33+
const String& value = pair.second;
34+
35+
if (value == "bool_true") {
36+
doc["data"][key] = true;
37+
} else if (value == "bool_false") {
38+
doc["data"][key] = false;
39+
} else if (value.indexOf('.') != -1) {
40+
doc["data"][key] = value.toFloat();
41+
} else if (value.length() > 0 && (isDigit(value.charAt(0)) || value.charAt(0) == '-')) {
42+
doc["data"][key] = value.toInt();
43+
} else {
44+
doc["data"][key] = value;
45+
}
46+
}
3047
serializeJson(doc, cmd);
3148
}
3249

src/api/api_audio.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@ struct ApiAudioSetupConfig_t {
1616
int playcard = 0;
1717
int playdevice = 1;
1818
float playVolume = 0.15;
19+
20+
std::map<String, String> extra_params;
21+
22+
template <typename T>
23+
void setParam(const String& key, T value)
24+
{
25+
extra_params[key] = String(value);
26+
}
27+
28+
void setParam(const String& key, bool value)
29+
{
30+
extra_params[key] = value ? "bool_true" : "bool_false";
31+
}
32+
33+
void setParam(const String& key, float value)
34+
{
35+
char buffer[16];
36+
dtostrf(value, 1, 6, buffer);
37+
extra_params[key] = String(buffer);
38+
}
1939
};
2040

2141
class ApiAudio {

src/api/api_camera.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@ String ApiCamera::setup(ApiCameraSetupConfig_t config, String request_id)
2626
doc["data"]["enoutput"] = config.enoutput;
2727
doc["data"]["frame_width"] = config.frame_width;
2828
doc["data"]["frame_height"] = config.frame_height;
29+
30+
for (const auto& pair : config.extra_params) {
31+
const String& key = pair.first;
32+
const String& value = pair.second;
33+
34+
if (value == "bool_true") {
35+
doc["data"][key] = true;
36+
} else if (value == "bool_false") {
37+
doc["data"][key] = false;
38+
} else if (value.indexOf('.') != -1) {
39+
doc["data"][key] = value.toFloat();
40+
} else if (value.length() > 0 && (isDigit(value.charAt(0)) || value.charAt(0) == '-')) {
41+
doc["data"][key] = value.toInt();
42+
} else {
43+
doc["data"][key] = value;
44+
}
45+
}
2946
serializeJson(doc, cmd);
3047
}
3148

src/api/api_camera.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ struct ApiCameraSetupConfig_t {
1515
bool enoutput = false;
1616
int frame_width = 320;
1717
int frame_height = 320;
18+
std::map<String, String> extra_params;
19+
20+
template <typename T>
21+
void setParam(const String& key, T value)
22+
{
23+
extra_params[key] = String(value);
24+
}
25+
26+
void setParam(const String& key, bool value)
27+
{
28+
extra_params[key] = value ? "bool_true" : "bool_false";
29+
}
30+
31+
void setParam(const String& key, float value)
32+
{
33+
char buffer[16];
34+
dtostrf(value, 1, 6, buffer);
35+
extra_params[key] = String(buffer);
36+
}
1837
};
1938

2039
class ApiCamera {

src/api/api_depth_anything.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ String ApiDepthAnything::setup(ApiDepthAnythingSetupConfig_t config, String requ
2828
inputArray.add(str);
2929
}
3030
doc["data"]["enoutput"] = config.enoutput;
31+
32+
for (const auto& pair : config.extra_params) {
33+
const String& key = pair.first;
34+
const String& value = pair.second;
35+
36+
if (value == "bool_true") {
37+
doc["data"][key] = true;
38+
} else if (value == "bool_false") {
39+
doc["data"][key] = false;
40+
} else if (value.indexOf('.') != -1) {
41+
doc["data"][key] = value.toFloat();
42+
} else if (value.length() > 0 && (isDigit(value.charAt(0)) || value.charAt(0) == '-')) {
43+
doc["data"][key] = value.toInt();
44+
} else {
45+
doc["data"][key] = value;
46+
}
47+
}
3148
serializeJson(doc, cmd);
3249
}
3350

src/api/api_depth_anything.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ struct ApiDepthAnythingSetupConfig_t {
1313
String response_format = "jpeg.base64.stream";
1414
std::vector<String> input = {"depth_anything.jpeg.raw"};
1515
bool enoutput = true;
16+
std::map<String, String> extra_params;
17+
18+
template <typename T>
19+
void setParam(const String& key, T value)
20+
{
21+
extra_params[key] = String(value);
22+
}
23+
24+
void setParam(const String& key, bool value)
25+
{
26+
extra_params[key] = value ? "bool_true" : "bool_false";
27+
}
28+
29+
void setParam(const String& key, float value)
30+
{
31+
char buffer[16];
32+
dtostrf(value, 1, 6, buffer);
33+
extra_params[key] = String(buffer);
34+
}
1635
};
1736

1837
class ApiDepthAnything {

0 commit comments

Comments
 (0)