Skip to content

Commit 27dec95

Browse files
authored
Merge pull request #17 from Abandon-ht/dev
2 parents c263d32 + dfd4c1e commit 27dec95

24 files changed

+1345
-3
lines changed

docs/cn.md

Lines changed: 640 additions & 0 deletions
Large diffs are not rendered by default.

docs/en.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# LLM Module Arduino Quick Start
2+
3+
## Overview
4+
5+
The `LLM Module` can be used with various M5 controllers. This tutorial demonstrates how to control the LLM Module using the `M5Core` series in the `Arduino IDE` with the LLM Module driver library.
6+
7+
<img src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/static/assets/img/guide/llm/llm/llm_module_device_01.jpg" width="70%" />
8+
9+
## Environment Setup
10+
11+
- 1.Arduino IDE Installation: Refer to the [Arduino IDE Installation Guide](/en/arduino/arduino_ide) to complete the IDE installation.
12+
13+
- 2.Board Manager Installation: Refer to the [Basic Environment Setup Guide](/en/arduino/arduino_board) to complete the M5Stack board manager installation and select the `M5Core` development board.
14+
15+
<img src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/static/assets/img/arduino/m5core/quickstart_arduino_core_selectboard.png" width="70%" />
16+
17+
- 3.Library Installation: Refer to the [Library Management Guide](/en/arduino/arduino_library) to install the `LLM Module` driver library. (Follow prompts to install the dependency library `M5Unified`)
18+
19+
<img src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/static/assets/img/guide/llm/llm/llm_arduino_lib_01.jpg" width="70%" />
20+
<img src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/static/assets/img/guide/llm/llm/llm_arduino_lib_02.jpg" width="70%" />
21+
22+
## Program Compilation & Upload
23+
24+
Open the example program "kws_asr" in the driver library, click the upload button, and the program will automatically compile and upload.The wake-up word used in the example program is "HELLO". After waiting for the device to be initialized, it will be woken up using the keyword.
25+
26+
<img src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/static/assets/img/guide/llm/llm/llm_arduino_example_01.jpg" width="70%" />
27+
<img src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/static/assets/img/guide/llm/llm/llm_arduino_example_02.jpg" width="70%" />
28+
<img src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/static/assets/img/guide/llm/llm/llm_arduino_example_03.jpg" width="70%" />
29+
<img src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/static/assets/img/guide/llm/llm/llm_arduino_example_04.jpg" width="70%" />
30+
31+
- Examples:
32+
- `kws_asr`: Uses KWS to wake up and triggers ASR for speech-to-text conversion. (KWS+ASR)
33+
- `text_assistant`: Inputs text into the LLM model, performs inference, and outputs the result in text form. (LLM)
34+
- `tts`: Uses the TTS unit to convert text to speech for playback. (TTS)
35+
- `voice_assistant`: Uses KWS to wake up, triggers ASR for speech-to-text conversion, inputs the converted text into the LLM for inference, and outputs the inference result through TTS as speech. (KWS+ASR+LLM+TTS)
36+
37+
## Related Links
38+
39+
- [LLM Module Arduino Lib](https://github.com/m5stack/M5Module-LLM)
40+
- [LLM Module Arduino Lib API](/en/guide/llm/llm/arduino_api)
41+

src/M5ModuleLLM.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ bool M5ModuleLLM::begin(Stream* serialPort)
1212
msg.init(&comm);
1313
sys.init(&msg);
1414
llm.init(&msg);
15+
vlm.init(&msg);
1516
audio.init(&msg);
1617
tts.init(&msg);
1718
melotts.init(&msg);
1819
kws.init(&msg);
1920
asr.init(&msg);
2021
yolo.init(&msg);
2122
camera.init(&msg);
23+
depthanything.init(&msg);
2224
return true;
2325
}
2426

src/M5ModuleLLM.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
#include "utils/msg.h"
1010
#include "api/api_sys.h"
1111
#include "api/api_llm.h"
12+
#include "api/api_vlm.h"
1213
#include "api/api_audio.h"
1314
#include "api/api_tts.h"
1415
#include "api/api_melotts.h"
1516
#include "api/api_kws.h"
1617
#include "api/api_asr.h"
1718
#include "api/api_yolo.h"
19+
#include "api/api_depth_anything.h"
1820
#include "api/api_camera.h"
1921
#include "api/api_version.h"
2022

@@ -55,6 +57,12 @@ class M5ModuleLLM {
5557
*/
5658
m5_module_llm::ApiLlm llm;
5759

60+
/**
61+
* @brief VLM module api set
62+
*
63+
*/
64+
m5_module_llm::ApiVlm vlm;
65+
5866
/**
5967
* @brief Audio module api set
6068
*
@@ -97,6 +105,12 @@ class M5ModuleLLM {
97105
*/
98106
m5_module_llm::ApiYolo yolo;
99107

108+
/**
109+
* @brief DepthAnything module api set
110+
*
111+
*/
112+
m5_module_llm::ApiDepthAnything depthanything;
113+
100114
/**
101115
* @brief MSG module to handle module response message
102116
*

src/api/api_asr.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,24 @@ String ApiAsr::setup(ApiAsrSetupConfig_t config, String request_id, String langu
5151
10000);
5252
return work_id;
5353
}
54+
55+
String ApiAsr::exit(String work_id, String request_id)
56+
{
57+
String cmd;
58+
{
59+
JsonDocument doc;
60+
doc["request_id"] = request_id;
61+
doc["work_id"] = work_id;
62+
doc["action"] = "exit";
63+
serializeJson(doc, cmd);
64+
}
65+
66+
_module_msg->sendCmdAndWaitToTakeMsg(
67+
cmd.c_str(), request_id,
68+
[&work_id](ResponseMsg_t& msg) {
69+
// Copy work id
70+
work_id = msg.work_id;
71+
},
72+
100);
73+
return work_id;
74+
}

src/api/api_asr.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ class ApiAsr {
3434
String setup(ApiAsrSetupConfig_t config = ApiAsrSetupConfig_t(), String request_id = "asr_setup",
3535
String language = "en_US");
3636

37+
/**
38+
* @brief Exit module ASR, return ASR work_id
39+
*
40+
* @param work_id
41+
* @param request_id
42+
* @return String
43+
*/
44+
String exit(String work_id, String request_id = "asr_exit");
45+
3746
private:
3847
ModuleMsg* _module_msg = nullptr;
3948
};

src/api/api_audio.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,24 @@ String ApiAudio::setup(ApiAudioSetupConfig_t config, String request_id)
4040
5000);
4141
return work_id;
4242
}
43+
44+
String ApiAudio::exit(String work_id, String request_id)
45+
{
46+
String cmd;
47+
{
48+
JsonDocument doc;
49+
doc["request_id"] = request_id;
50+
doc["work_id"] = work_id;
51+
doc["action"] = "exit";
52+
serializeJson(doc, cmd);
53+
}
54+
55+
_module_msg->sendCmdAndWaitToTakeMsg(
56+
cmd.c_str(), request_id,
57+
[&work_id](ResponseMsg_t& msg) {
58+
// Copy work id
59+
work_id = msg.work_id;
60+
},
61+
100);
62+
return work_id;
63+
}

src/api/api_audio.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,23 @@ class ApiAudio {
2323
void init(ModuleMsg* moduleMsg);
2424

2525
/**
26-
* @brief Setup module audio, return work_id
26+
* @brief Setup module audio, return audio work_id
2727
*
2828
* @param config
2929
* @param request_id
3030
* @return String
3131
*/
3232
String setup(ApiAudioSetupConfig_t config = ApiAudioSetupConfig_t(), String request_id = "audio_setup");
3333

34+
/**
35+
* @brief Exit module audio, return audio work_id
36+
*
37+
* @param work_id
38+
* @param request_id
39+
* @return String
40+
*/
41+
String exit(String work_id, String request_id = "audio_exit");
42+
3443
private:
3544
ModuleMsg* _module_msg = nullptr;
3645
};

src/api/api_camera.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,24 @@ String ApiCamera::setup(ApiCameraSetupConfig_t config, String request_id)
3939
5000);
4040
return work_id;
4141
}
42+
43+
String ApiCamera::exit(String work_id, String request_id)
44+
{
45+
String cmd;
46+
{
47+
JsonDocument doc;
48+
doc["request_id"] = request_id;
49+
doc["work_id"] = work_id;
50+
doc["action"] = "exit";
51+
serializeJson(doc, cmd);
52+
}
53+
54+
_module_msg->sendCmdAndWaitToTakeMsg(
55+
cmd.c_str(), request_id,
56+
[&work_id](ResponseMsg_t& msg) {
57+
// Copy work id
58+
work_id = msg.work_id;
59+
},
60+
100);
61+
return work_id;
62+
}

src/api/api_camera.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,23 @@ class ApiCamera {
2222
void init(ModuleMsg* moduleMsg);
2323

2424
/**
25-
* @brief Setup module camera, return work_id
25+
* @brief Setup module camera, return camera work_id
2626
*
2727
* @param config
2828
* @param request_id
2929
* @return String
3030
*/
3131
String setup(ApiCameraSetupConfig_t config = ApiCameraSetupConfig_t(), String request_id = "camera_setup");
3232

33+
/**
34+
* @brief Exit module camera, return camera work_id
35+
*
36+
* @param work_id
37+
* @param request_id
38+
* @return String
39+
*/
40+
String exit(String work_id, String request_id = "camera_exit");
41+
3342
private:
3443
ModuleMsg* _module_msg = nullptr;
3544
};

0 commit comments

Comments
 (0)