GithubHelp home page GithubHelp logo

sqldiablo / esphome_audio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gnumpi/esphome_audio

0.0 0.0 0.0 243 KB

Custom audio components for ESPHome

License: Other

Shell 0.36% C++ 52.74% Python 29.49% C 17.41%

esphome_audio's Introduction

ESPHome - Audio Components

ADF-Pipeline

Target Version: ESPHome-2023.12.9

ESPHome-target ESPHome-latest

The purpose of this ESPHome component is to offer a wrapper framework that enables access to the elements from the Espressif Audio Development Framework (ADF) within the ESPHome environment.

The following elements are available for now:

Pipeline elements:

  • I2SReader
  • PCMSource
  • HTTPStreamReaderAndDecoder
  • I2SWriter
  • PCMSink

ESPHome components:

new platform: 'adf_pipeline'

  • The included extension for the 'i2s_audio' provides i2s configurations as pipeline elements.

Pipeline controller:

  • ADFMicrophone: 'esphome.microphone' platform implementation
  • ADFSpeaker: 'esphome.speaker' platform implementation
  • ADFMediaPlayer: 'esphome.media_player' platform implementation

Pipeline controllers are responsible for constructing an audio pipeline and provide methods for controlling the pipeline (e.g. start, stop, pause ).

Configuration

external_components:
  - source:
      type: git
      url: https://github.com/gnumpi/esphome_audio
      ref: main
    components: [ adf_pipeline, i2s_audio ]


# define the i2s controller and their pins as before
i2s_audio:
  - id: i2s_in
    i2s_lrclk_pin: GPIO5
    i2s_bclk_pin: GPIO6
  - id: i2s_out
    i2s_lrclk_pin: GPIO46
    i2s_bclk_pin: GPIO9

# expose the i2s components as pipeline elements
adf_pipeline:
    # create an I2SWriter pipeline element
    # using the i2s_out configuration
  - platform: i2s_audio
    type: sink
    id: adf_i2s_out
    i2s_audio_id: i2s_out
    i2s_dout_pin: GPIO10

    # create an I2SReader pipeline element
    # using the i2s_in configuration
  - platform: i2s_audio
    type: source
    id: adf_i2s_in
    i2s_audio_id: i2s_in
    i2s_din_pin: GPIO4
    channel: left
    sample_rate: 16000
    bits_per_sample: 16bit

# create a new microphone component which
# is implemented as an adf_pipeline
microphone:
  - platform: adf_pipeline
    id: adf_microphone
    #define the pipeline
    pipeline:
        # take the I2SReader pipeline element
        # as the first element (SOURCE)
      - adf_i2s_in
        # The microphone implementation implicitly
        # creates a PCMSink pipeline_element which
        # provides the raw audio data to other esphome components
        # using the microphone platform interface.
        # It is added as the last element (sink) for the pipeline.
      - self

# create a new speaker component which
# is implemented as an adf_pipeline
speaker:
  - platform: adf_pipeline
    id: adf_speaker
    #define the pipeline
    pipeline:
        # The speaker implementation implicitly
        # creates a PCMSource pipeline_element to
        # which other ESPHome components can write to
        # using the speaker platform interface.
        # It is added as the first element, as a source to
        # the pipeline
      - self
        # add the I2SWriter pipeline element as a sink.
      - adf_i2s_out


# create a new media_player component which
# is implemented as an adf_pipeline
media_player:
  - platform: adf_pipeline
    id: adf_media_player
    name: s3-dev_media_player
    internal: false
    pipeline:
        # The media_player implementation implicitly
        # creates a HTTPStreamReaderAndDecoder pipeline_element,
        # which can be controlled using the media_player interface.
        # It is added as the first element, as source to
        # the pipeline
      - self
        # add the I2SWriter pipeline element as a sink.
      - adf_i2s_out

voice_assistant:
  microphone: adf_microphone
  #if a media player is defined it should be used instead of the speaker
  media_player: adf_media_player

Notes:

  • using the same element in two pipelines (e.g. using adf_i2s_out in the speaker and the media_player) is not supported yet
  • using the adf_pipeline component disables the verification of server certificates by setting the idf-sdk option "CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY". This is quick and dirty hack for allowing streaming from internet radio stations, be aware of the potential security issue.

esphome_audio's People

Contributors

gnumpi avatar nighi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.