gnumpi / esphome_audio

Custom audio components for ESPHome
Other
62 stars 23 forks source link

Will this work on an esp32 wrover board? #70

Open jfthomps opened 2 months ago

jfthomps commented 2 months ago

Hi, First, thanks for your work on this project! Will the microphone part of this work on an esp32 wrover board? I've been able to get the media player portion working, but not the microphone part. I'm trying to get it working with microwakeword. I've tried various configurations, but I'm currently using the following YAML.

Thanks for any help/suggestions.

esphome:
  name: voice-control2
  friendly_name: Voice Control 2
  name_add_mac_suffix: false
  platformio_options:
    board_build.flash_mode: dio

esp32:
  board: esp-wrover-kit
  framework:
    type: esp-idf
    version: recommended
    sdkconfig_options:
      #CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
      #CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
      #CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
      COMPILER_OPTIMIZATION_SIZE: "y"
      CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM: "16"
      CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM: "512"
      CONFIG_TCPIP_RECVMBOX_SIZE: "512"
      CONFIG_TCP_SND_BUF_DEFAULT: "65535"
      CONFIG_TCP_WND_DEFAULT: "512000"
      CONFIG_TCP_RECVMBOX_SIZE: "512"

psram:
  mode: octal
  speed: 80MHz

external_components:
  - source:
      type: git
      url: https://github.com/gnumpi/esphome_audio
      ref: dev-next
    components:
      - adf_pipeline
      - i2s_audio
    refresh: 0s

api:
  encryption:
    key: "********************************************"
  on_client_connected:
      then:
        - delay: 50ms
        - micro_wake_word.start:
  on_client_disconnected:
      then:
        - voice_assistant.stop:

ota:
  - platform: esphome
    id: ota_esphome
    password: !secret ota_password

logger:     
  logs: 
    sensor: INFO

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true

i2s_audio:
  - id: i2s_out
    i2s_lrclk_pin: GPIO5 # LRC
    i2s_bclk_pin: GPIO18 # BCLK
  - id: i2s_in
    i2s_lrclk_pin: GPIO33 # WS
    i2s_bclk_pin: GPIO32 # SCK

adf_pipeline:
  - platform: i2s_audio
    type: audio_out
    id: adf_i2s_out
    i2s_audio_id: i2s_out
    i2s_dout_pin: GPIO19
    adf_alc: true # not in esphome_audio example
    alc_max: .5 # not in esphome_audio example

  - platform: i2s_audio
    type: audio_in
    id: adf_i2s_in
    i2s_audio_id: i2s_in
    i2s_din_pin: GPIO35
    pdm: false
    channel: left
    sample_rate: 16000
    bits_per_sample: 32bit

microphone:
  - platform: adf_pipeline
    id: voice_control2_mic
    gain_log2: 3
    keep_pipeline_alive: true
    pipeline:
      - adf_i2s_in
      - self

media_player:
  - platform: adf_pipeline
    id: voice_control2_mediaplayer
    name: voice_control2_mediaplayer
    keep_pipeline_alive: true
    internal: false
    pipeline:
      - self
      - adf_i2s_out
micro_wake_word:
  models:
    - model: hey_jarvis
  on_wake_word_detected:
    - media_player.stop:
    - voice_assistant.start:

voice_assistant:
  id: assist
  microphone: voice_control2_mic
  media_player: voice_control2_mediaplayer
  use_wake_word: true
  noise_suppression_level: 4
  auto_gain: 31dBFS
  volume_multiplier: 4.0
  on_client_connected:
    - micro_wake_word.start:
  on_client_disconnected:
    - voice_assistant.stop:
    - micro_wake_word.stop:
  on_end:
    then:
      - voice_assistant.stop:
      - delay: 100ms
      - wait_until:
          not:
            voice_assistant.is_running:
      - micro_wake_word.start:
  on_error:
    then:
      - voice_assistant.stop:
      - wait_until:
          not:
            voice_assistant.is_running:
      - micro_wake_word.start: