audio — player and recorder
This module implements player and recorder
player: encapsulates the ADF esp_audio, support local and online resources.
recorder: record and encoding the voice into file.
Below is the detailed audio support for the host:
AW88298 |
ES7210 |
ES8311 |
I2S Philips |
I2S PDM |
|
|---|---|---|---|---|---|
CoreS3 |
✔ |
✔ |
|||
BOX3 |
✔ |
✔ |
Micropython Example:
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4 5import os, sys, io 6import M5 7from M5 import * 8from audio import Recorder 9from audio import Player 10 11 12recorder = None 13player = None 14 15 16def setup(): 17 global recorder, player 18 19 M5.begin() 20 Widgets.fillScreen(0x222222) 21 22 recorder = Recorder(8000, 16, True) 23 recorder.record("file://flash/res/audio/test.amr", 5, True) 24 player = Player(None) 25 player.play("file://flash/res/audio/test.amr", pos=0, volume=100, sync=True) 26 27 28def loop(): 29 global recorder, player 30 M5.update() 31 32 33if __name__ == "__main__": 34 try: 35 setup() 36 while True: 37 loop() 38 except (Exception, KeyboardInterrupt) as e: 39 try: 40 from utility import print_error_msg 41 42 print_error_msg(e) 43 except ImportError: 44 print("please update to latest firmware")
UIFLOW2 Example:
