Rdzleo dbdd304905 代码初始化:
本项目为触摸版项目代码复制而来,基于此版本进行按键功能的适配!
2026-03-23 11:14:56 +08:00
..
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00
2026-03-23 11:14:56 +08:00

ESP-Brookesia Audio Service

Overview

brookesia_service_audio is an audio service for the ESP-Brookesia ecosystem, providing:

  • Audio Playback: Supports playing audio files from URLs with playback controls such as pause, resume, and stop.
  • Audio Codec: Supports multiple audio codec formats (PCM, OPUS, G711A) with encoding and decoding capabilities.
  • Volume Control: Supports volume setting and querying, providing complete volume management capabilities.
  • Playback State Management: Tracks playback state in real-time (Idle, Playing, Paused) and notifies state changes through events.
  • Encoder Management: Supports encoder start, stop, and configuration, with configurable encoder read data size.
  • Decoder Management: Supports decoder start, stop, and data input, with streaming decoding support.
  • Persistent Storage: Optionally work with the brookesia_service_nvs service to persistently save volume and other information.

Table of Contents

Features

Audio Codec Formats

Audio Service supports the following audio codec formats:

Format Encode Decode Description
PCM Lossless audio format
OPUS Supports VBR and fixed bitrate configuration
G711A Telephone quality audio format

Playback Control

The following playback control operations are supported:

  • Play: Play audio files from a specified URL
  • Pause: Pause current playback
  • Resume: Resume playback from paused state
  • Stop: Stop current playback

Encoder Configuration

Encoder supports flexible configuration options:

  • Codec Format: PCM, OPUS, G711A
  • Channels: 1-4 channels
  • Sample Bits: 8, 16, 24, 32 bits
  • Sample Rate: 8000, 16000, 24000, 32000, 44100, 48000 Hz
  • Frame Duration: Configurable frame duration (milliseconds)
  • OPUS Extra Configuration: VBR switch, bitrate settings

Decoder Configuration

Decoder supports the following configuration:

  • Codec Format: PCM, OPUS, G711A
  • Channels: 1-4 channels
  • Sample Bits: 8, 16, 24, 32 bits
  • Sample Rate: 8000, 16000, 24000, 32000, 44100, 48000 Hz
  • Frame Duration: Configurable frame duration (milliseconds)

Event Notifications

Audio Service provides the following event notifications:

  • Playback State Changed: Triggered when playback state changes (Idle, Playing, Paused)
  • Encoder Event: Triggered when encoder events occur
  • Encoder Data Ready: Triggered when encoded data is ready

Development Environment Requirements

Before using this library, please ensure the following SDK development environment is installed:

Note

For SDK installation instructions, please refer to ESP-IDF Programming Guide - Installation

Adding to Project

brookesia_service_audio has been uploaded to the Espressif Component Registry. You can add it to your project in the following ways:

  1. Using Command Line

    Run the following command in your project directory:

    idf.py add-dependency "espressif/brookesia_service_audio"
    
  2. Modify Configuration File

    Create or modify the idf_component.yml file in your project directory:

    dependencies:
      espressif/brookesia_service_audio: "*"
    

For detailed instructions, please refer to Espressif Documentation - IDF Component Manager.