Skip to content

Commit

Permalink
cleanup code and fix some compile error
Browse files Browse the repository at this point in the history
Signed-off-by: imliubo <imliubo@makingfun.xyz>
  • Loading branch information
imliubo committed Dec 27, 2024
1 parent e879ee0 commit b39d375
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 207 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
.DS_Store
13 changes: 11 additions & 2 deletions README.md
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)
56 changes: 56 additions & 0 deletions example/RecordPlay/RecordPlay.ino
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);
}
22 changes: 0 additions & 22 deletions example/atoms3.ino

This file was deleted.

Binary file removed example/canon.pcm
Binary file not shown.
8 changes: 4 additions & 4 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "M5EchoBase",
"description": "Library for M5Stack M5EchoBase",
"keywords": "M5GFX,M5Stack,M5EchoBase",
"name": "M5Atomic-EchoBase",
"description": "Library for M5Stack Atomic EchoBase",
"keywords": "M5GFX,M5Stack,M5Atomic EchoBase",
"authors": {
"name": "M5Stack, Aspen",
"url": "http://www.m5stack.com"
},
"repository": {
"type": "git",
"url": "https://github.com/m5stack/M5EchoBase.git"
"url": "https://github.com/m5stack/M5Atomic-EchoBase.git"
},
"version": "1.0.0",
"frameworks": ["arduino"],
Expand Down
8 changes: 4 additions & 4 deletions library.properties
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
Loading

0 comments on commit b39d375

Please sign in to comment.