-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup code and fix some compile error
Signed-off-by: imliubo <imliubo@makingfun.xyz>
- Loading branch information
Showing
10 changed files
with
245 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
# M5EchoBase | ||
# M5Atomic-EchoBase | ||
|
||
## Library for M5Stack M5EchoBase | ||
## Overview | ||
|
||
<img src="https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/products/atom/Atomic%20Echo%20Base/4.webp" alt="basic" width="350" height="350"> | ||
|
||
### SKU:A149 | ||
|
||
The **Atomic Echo Base** is a voice recognition base designed specifically for the M5 Atom series. It uses an integrated solution with the ES8311 mono audio decoder, MEMS microphone, and NS4150B power amplifier. The ES8311 offers 24-bit audio resolution and a sample rate of 16KHz to 64KHz, supporting I2S communication and high-fidelity audio processing. The MEMS microphone with high signal-to-noise ratio (SNR) is suitable for automatic speech recognition, while the built-in speaker ensures efficient audio output. The device supports full-duplex communication, enabling simultaneous voice transmission and reception, enhancing interactive features such as speech recognition, wake-up, and audio playback. It is ideal for applications in smart homes and education. | ||
|
||
## License | ||
|
||
- [M5Atomic-EchoBase- MIT](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#include <Arduino.h> | ||
#include <M5EchoBase.h> | ||
|
||
#define RECORD_SIZE (1024 * 96) // Define the size of the record buffer to 96KB. | ||
|
||
M5EchoBase echobase(I2S_NUM_0); // Create an instance of the M5EchoBase class. | ||
static uint8_t *buffer = nullptr; // Pointer to hold the audio buffer. | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
|
||
// Initialize the EchoBase with ATOMS3 pinmap. | ||
echobase.init(16000 /*Sample Rate*/, 38 /*I2C SDA*/, 39 /*I2C SCL*/, 7 /*I2S DIN*/, 6 /*I2S WS*/, 5 /*I2S DOUT*/, | ||
8 /*I2S BCK*/, Wire); | ||
|
||
// Initialize the EchoBase with ATOM pinmap. | ||
// echobase.init(16000 /*Sample Rate*/, 25 /*I2C SDA*/, 21 /*I2C SCL*/, 23 /*I2S DIN*/, 19 /*I2S WS*/, 22 /*I2S | ||
// DOUT*/, 33 /*I2S BCK*/, Wire); | ||
|
||
echobase.setSpeakerVolume(50); // Set speaker volume to 50%. | ||
echobase.setMicGain(ES8311_MIC_GAIN_6DB); // Set microphone gain to 6dB. | ||
|
||
buffer = (uint8_t *)malloc(RECORD_SIZE); // Allocate memory for the record buffer. | ||
// Check if memory allocation was successful. | ||
if (buffer == nullptr) { | ||
// If memory allocation fails, enter an infinite loop. | ||
while (true) { | ||
Serial.println("Failed to allocate memory :("); | ||
delay(1000); | ||
} | ||
} | ||
|
||
Serial.println("EchoBase ready, start recording and playing!"); | ||
} | ||
|
||
void loop() | ||
{ | ||
// Recording | ||
echobase.setMute(true); | ||
delay(10); | ||
echobase.record(buffer, RECORD_SIZE); // Record audio into buffer. | ||
delay(100); | ||
|
||
// Playing | ||
echobase.setMute(false); | ||
delay(10); | ||
echobase.play(buffer, RECORD_SIZE); // Play audio from buffer. | ||
delay(100); | ||
} |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
name=M5EchoBase | ||
name=M5Atomic-EchoBase | ||
version=1.0.0 | ||
author=M5Stack | ||
maintainer=M5Stack | ||
sentence=Library for M5Stack EchoBase | ||
paragraph=M5Stack, EchoBase, See more on http://M5Stack.com | ||
sentence=Library for M5Stack Atomic EchoBase | ||
paragraph=M5Stack, Atomic EchoBase, See more on http://m5stack.com | ||
category=Sensor | ||
url=https://github.com/m5stack/M5EchoBase.git | ||
url=https://github.com/m5stack/M5Atomic-EchoBase.git | ||
architectures=esp32 | ||
includes=M5EchoBase.h |
Oops, something went wrong.