Open indevor opened 4 months ago
freez on detect "wake_word" log:
`[22:51:39][D][micro_wake_word:362]: Wake word sliding average probability is 0.692 and most recent probability is 0.996
[22:51:39][D][micro_wake_word:128]: Wake Word Detected
[22:51:39][D][micro_wake_word:177]: State changed from DETECTING_WAKE_WORD to STOP_MICROPHONE
[22:51:39][D][micro_wake_word:134]: Stopping Microphone
[22:51:39][D][esp_adf_pipeline:070]: Called 'stop' while in RUNNING state.
[22:51:39][D][micro_wake_word:177]: State changed from STOP_MICROPHONE to STOPPING_MICROPHONE
[22:51:39][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from RUNNING to ABORTING. (REQ: 1)
[22:51:39][D][adf_audio_element:324]: [i2s_in] Checking State for stopping, got 3
[22:51:39][D][adf_audio_element:324]: [pcm_reader] Checking State for stopping, got 3
[22:51:39][D][esp-idf:000][i2s_in]: W (7526630) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[22:51:39][D][esp-idf:000][i2s_in]: W (7526632) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[22:51:39][D][esp-idf:000][i2s_in]: W (7526635) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[22:51:39][D][esp-idf:000][i2s_in]: W (7526638) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[22:51:39][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from ABORTING to STOPPED. (REQ: 1)
[22:51:39][D][micro_wake_word:177]: State changed from STOPPING_MICROPHONE to IDLE
[22:51:39][D][media_player:061]: 'media_player' - Setting
[22:51:39][D][media_player:065]: Command: STOP
[22:51:39][D][esp_adf_pipeline:070]: Called 'stop' while in UNINITIALIZED state.
[22:51:39][D][light:036]: 'Test Media Assistant V2 Light' Setting:
[22:51:39][D][light:051]: Brightness: 75%
[22:51:39][D][light:059]: Red: 0%, Green: 100%, Blue: 0%
[22:51:39][D][light:109]: Effect: 'Pulse'
[22:51:39][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from STOPPED to DESTROYING. (REQ: 1)
[22:51:39][D][esp_adf_pipeline:507]: Called deinit_all
[22:51:39][D][esp-idf:000]: I (7526662) AUDIO_PIPELINE: audio_pipeline_unlinked
[22:51:39][D][esp-idf:000]: W (7526664) AUDIO_ELEMENT: [i2s_in] Element has not create when AUDIO_ELEMENT_TERMINATE
[22:51:39][D][esp-idf:000]: W (7526665) AUDIO_ELEMENT: [pcm_reader] Element has not create when AUDIO_ELEMENT_TERMINATE
[22:51:39][D][esp-idf:000]: I (7526667) I2S: DMA queue destroyed
[22:51:39][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from DESTROYING to UNINITIALIZED. (REQ: 1)
[22:51:39][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from UNINITIALIZED to UNINITIALIZED. (REQ: 1)
[22:51:40][D][voice_assistant:447]: State changed from STREAMING_RESPONSE to IDLE
[22:51:40][D][voice_assistant:453]: Desired state set to IDLE`
external_components: - source: type: git url: https://github.com/gnumpi/esphome ref: adf-mods components: [ api, media_player, speaker, voice_assistant ] - source: type: git url: https://github.com/gnumpi/esphome_audio ref: dev-next components: [ adf_pipeline, i2s_audio ]
The announcement media_player state has been merged into ESPHome 2024.5.0, so there is no need of including adf-mods anymore.
- The response from the voice assistant is spoken in a slow voice. There is also a wait after you say a voice command. I have noticed that the louder the command is spoken, the less the pause. On average there is a pause of 10-12 seconds after the command is said. Method of phrase ending: aggressive.
I just merged a new config parameter for the media_player into dev-next. It lets you configure the audio settings used for announcements. Now, the media_player will try to detect the announcement audio settings if the new config is not set. This consumes some extra time though.
Here is an example:
media_player:
- platform: adf_pipeline
id: adf_media_player
name: s3-dev_media_player
internal: false
keep_pipeline_alive: false
announcement_audio:
sample_rate: 16000
bits_per_sample: 16
num_channels: 1
pipeline:
- self
- resampler
- adf_i2s_out
- If you play this file WAV 44100, 706 kbps, 16bit, mono
currently, only mp3 files are supported. There is a PR in the queue though which will add a couple of other audio codecs.
- Also RadioBrowser does not work.
can you try different radio stations and see if there is a pattern which do work and which don't?
Here is an example:
this error occurs here: ( announcement_audio: )
[announcement_audio] is an invalid option for [media_player.adf_pipeline]. Did you mean [on_announcement]?
can you try different radio stations and see if there is a pattern which do work and which don't?
all radio links are working, checked separately. radio less than 128 kbps did not find, but I think it's not the bitrate.
[announcement_audio] is an invalid option for [media_player.adf_pipeline]. Did you mean [on_announcement]?
please try adding a refresh parameter:
- source:
type: git
url: https://github.com/gnumpi/esphome_audio
ref: dev-next
components: [ adf_pipeline, i2s_audio ]
refresh: 0s
the sound is fine now.
the problem with freezing remains: wake up by voice (ok) - give a command (ok) - give a second command (freez, pulse green light)
micro_wake_word:
model: alexa
on_wake_word_detected:
- media_player.stop:
- light.turn_on:
id: led_ring
blue: 0%
red: 0%
green: 100%
brightness: 75%
effect: pulse
- voice_assistant.start:
INFO Processing expected disconnect from ESPHome API for test-media-assistant-v2 @ 192.168.1.73
WARNING Disconnected from API
INFO Successfully connected to test-media-assistant-v2 @ 192.168.1.73 in 1.054s
INFO Successful handshake with test-media-assistant-v2 @ 192.168.1.73 in 0.086s
[16:13:26][D][micro_wake_word:177]: State changed from IDLE to START_MICROPHONE
[16:13:26][D][light:036]: 'Test Media Assistant V2 Light' Setting:
[16:13:26][D][light:051]: Brightness: 25%
[16:13:26][D][light:059]: Red: 0%, Green: 0%, Blue: 100%
[16:13:26][D][micro_wake_word:115]: Starting Microphone
[16:13:26][D][esp_adf_pipeline:060]: Starting request, current state UNINITIALIZED
[16:13:26][D][micro_wake_word:177]: State changed from START_MICROPHONE to STARTING_MICROPHONE
[16:13:26][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from UNINITIALIZED to INITIALIZING. (REQ: 0)
[16:13:26][D][esp-idf:000]: I (6354) I2S: DMA Malloc info, datalen=blocksize=1024, dma_buf_count=4
[16:13:26][D][i2s_audio:072]: Installing driver : yes
[16:13:26][D][esp_adf_pipeline:486]: pipeline tag 0, i2s_in
[16:13:26][D][esp_adf_pipeline:486]: pipeline tag 1, pcm_reader
[16:13:26][D][esp-idf:000]: I (6360) AUDIO_PIPELINE: link el->rb, el:0x3d8200c0, tag:i2s_in, rb:0x3d82039c
[16:13:26][D][esp_adf_pipeline:496]: Setting up event listener.
[16:13:26][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from INITIALIZING to CREATED. (REQ: 0)
[16:13:26][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from CREATED to PREPARING. (REQ: 0)
[16:13:26][D][adf_audio_element:108]: Preparing [i2s_in]...
[16:13:26][D][esp-idf:000]: I (6371) AUDIO_ELEMENT: [i2s_in-0x3d8200c0] Element task created
[16:13:26][D][adf_audio_element:108]: Preparing [pcm_reader]...
[16:13:26][D][esp-idf:000]: I (6376) AUDIO_ELEMENT: [pcm_reader-0x3d820254] Element task created
[16:13:26][D][esp_audio_sinks:054]: Set bitdepth to 32
[16:13:26][D][esp_adf_pipeline:334]: wait for preparation, done
[16:13:26][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from PREPARING to STARTING. (REQ: 0)
[16:13:26][D][adf_audio_element:165]: Resuming [i2s_in]...
[16:13:26][D][adf_audio_element:172]: [i2s_in] Sending resume command.
[16:13:26][D][esp-idf:000][i2s_in]: I (6387) AUDIO_ELEMENT: [i2s_in] AEL_MSG_CMD_RESUME,state:1
[16:13:26][D][adf_audio_element:191]: [pcm_reader] Checking State, got 64
[16:13:26][I][esp_adf_pipeline:124]: [ i2s_in ] status: 12
[16:13:26][D][adf_audio_element:191]: [i2s_in] Checking State, got 78
[16:13:26][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from STARTING to RUNNING. (REQ: 0)
[16:13:26][D][micro_wake_word:177]: State changed from STARTING_MICROPHONE to DETECTING_WAKE_WORD
[16:13:31][D][micro_wake_word:362]: Wake word sliding average probability is 0.713 and most recent probability is 0.980
[16:13:31][D][micro_wake_word:128]: Wake Word Detected
[16:13:31][D][micro_wake_word:177]: State changed from DETECTING_WAKE_WORD to STOP_MICROPHONE
[16:13:31][D][micro_wake_word:134]: Stopping Microphone
[16:13:31][D][esp_adf_pipeline:070]: Called 'stop' while in RUNNING state.
[16:13:31][D][micro_wake_word:177]: State changed from STOP_MICROPHONE to STOPPING_MICROPHONE
[16:13:31][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from RUNNING to ABORTING. (REQ: 1)
[16:13:31][D][adf_audio_element:324]: [i2s_in] Checking State for stopping, got 3
[16:13:31][D][esp-idf:000][i2s_in]: W (11299) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:31][D][esp-idf:000][i2s_in]: W (11301) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:31][D][esp-idf:000][i2s_in]: W (11303) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:31][D][esp-idf:000][i2s_in]: W (11305) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:31][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from ABORTING to STOPPED. (REQ: 1)
[16:13:31][D][micro_wake_word:177]: State changed from STOPPING_MICROPHONE to IDLE
[16:13:31][D][media_player:061]: 'media_player' - Setting
[16:13:31][D][media_player:065]: Command: STOP
[16:13:31][D][esp_adf_pipeline:070]: Called 'stop' while in UNINITIALIZED state.
[16:13:31][D][light:036]: 'Test Media Assistant V2 Light' Setting:
[16:13:31][D][light:051]: Brightness: 75%
[16:13:31][D][light:059]: Red: 0%, Green: 100%, Blue: 0%
[16:13:31][D][light:109]: Effect: 'Pulse'
[16:13:31][D][voice_assistant:439]: State changed from IDLE to START_MICROPHONE
[16:13:31][D][voice_assistant:445]: Desired state set to START_PIPELINE
[16:13:31][D][voice_assistant:163]: Starting Microphone
[16:13:31][D][esp_adf_pipeline:060]: Starting request, current state STOPPED
[16:13:31][D][voice_assistant:439]: State changed from START_MICROPHONE to STARTING_MICROPHONE
[16:13:31][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from STOPPED to PREPARING. (REQ: 0)
[16:13:31][D][adf_audio_element:108]: Preparing [i2s_in]...
[16:13:31][D][adf_audio_element:108]: Preparing [pcm_reader]...
[16:13:31][D][esp_adf_pipeline:334]: wait for preparation, done
[16:13:31][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from PREPARING to STARTING. (REQ: 0)
[16:13:31][D][adf_audio_element:165]: Resuming [i2s_in]...
[16:13:31][D][adf_audio_element:172]: [i2s_in] Sending resume command.
[16:13:31][D][esp-idf:000][i2s_in]: I (11366) AUDIO_ELEMENT: [i2s_in] AEL_MSG_CMD_RESUME,state:1
[16:13:31][D][adf_audio_element:191]: [pcm_reader] Checking State, got 65
[16:13:31][I][esp_adf_pipeline:124]: [ i2s_in ] status: 12
[16:13:31][D][adf_audio_element:191]: [i2s_in] Checking State, got 78
[16:13:31][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from STARTING to RUNNING. (REQ: 0)
[16:13:31][D][voice_assistant:439]: State changed from STARTING_MICROPHONE to START_PIPELINE
[16:13:31][D][voice_assistant:210]: Requesting start...
[16:13:31][D][voice_assistant:439]: State changed from START_PIPELINE to STARTING_PIPELINE
[16:13:31][D][voice_assistant:460]: Client started, streaming microphone
[16:13:31][D][voice_assistant:439]: State changed from STARTING_PIPELINE to STREAMING_MICROPHONE
[16:13:31][D][voice_assistant:445]: Desired state set to STREAMING_MICROPHONE
[16:13:31][D][voice_assistant:563]: Event Type: 1
[16:13:31][D][voice_assistant:566]: Assist Pipeline running
[16:13:31][D][voice_assistant:563]: Event Type: 3
[16:13:31][D][voice_assistant:577]: STT started
[16:13:31][D][light:036]: 'Test Media Assistant V2 Light' Setting:
[16:13:31][D][light:051]: Brightness: 25%
[16:13:31][D][light:059]: Red: 0%, Green: 0%, Blue: 100%
[16:13:31][D][light:109]: Effect: 'Wakeword'
[16:13:32][D][voice_assistant:563]: Event Type: 11
[16:13:32][D][voice_assistant:717]: Starting STT by VAD
[16:13:34][D][voice_assistant:563]: Event Type: 12
[16:13:34][D][voice_assistant:721]: STT by VAD end
[16:13:34][D][voice_assistant:439]: State changed from STREAMING_MICROPHONE to STOP_MICROPHONE
[16:13:34][D][voice_assistant:445]: Desired state set to AWAITING_RESPONSE
[16:13:34][D][esp_adf_pipeline:070]: Called 'stop' while in RUNNING state.
[16:13:34][D][voice_assistant:439]: State changed from STOP_MICROPHONE to STOPPING_MICROPHONE
[16:13:34][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from RUNNING to ABORTING. (REQ: 1)
[16:13:34][D][adf_audio_element:324]: [i2s_in] Checking State for stopping, got 3
[16:13:34][D][adf_audio_element:324]: [pcm_reader] Checking State for stopping, got 3
[16:13:34][D][voice_assistant:563]: Event Type: 4
[16:13:34][D][voice_assistant:591]: Speech recognised as: "включи даст"
[16:13:34][D][voice_assistant:563]: Event Type: 5
[16:13:34][D][voice_assistant:596]: Intent started
[16:13:34][D][esp-idf:000][i2s_in]: W (13907) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:34][D][esp-idf:000][i2s_in]: W (13909) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:34][D][esp-idf:000][i2s_in]: W (13911) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:34][D][esp-idf:000][i2s_in]: W (13914) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:34][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from ABORTING to STOPPED. (REQ: 1)
[16:13:34][D][voice_assistant:439]: State changed from STOPPING_MICROPHONE to AWAITING_RESPONSE
[16:13:34][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from STOPPED to DESTROYING. (REQ: 1)
[16:13:34][D][esp_adf_pipeline:507]: Called deinit_all
[16:13:34][D][esp-idf:000]: I (13925) AUDIO_PIPELINE: audio_pipeline_unlinked
[16:13:34][D][esp-idf:000]: W (13927) AUDIO_ELEMENT: [i2s_in] Element has not create when AUDIO_ELEMENT_TERMINATE
[16:13:34][D][esp-idf:000]: W (13929) AUDIO_ELEMENT: [pcm_reader] Element has not create when AUDIO_ELEMENT_TERMINATE
[16:13:34][D][esp-idf:000]: I (13931) I2S: DMA queue destroyed
[16:13:34][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from DESTROYING to UNINITIALIZED. (REQ: 1)
[16:13:34][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from UNINITIALIZED to UNINITIALIZED. (REQ: 1)
[16:13:34][D][voice_assistant:563]: Event Type: 6
[16:13:34][D][voice_assistant:563]: Event Type: 7
[16:13:34][D][voice_assistant:619]: Response: "объекта даст не существует"
[16:13:34][D][light:036]: 'Test Media Assistant V2 Light' Setting:
[16:13:34][D][light:051]: Brightness: 100%
[16:13:34][D][light:059]: Red: 100%, Green: 0%, Blue: 0%
[16:13:34][D][light:109]: Effect: 'Pulse'
[16:13:34][D][voice_assistant:563]: Event Type: 8
[16:13:34][D][voice_assistant:639]: Response URL: "http://192.168.1.114:8123/api/tts_proxy/11218599c3a26e823f1af531775540ed7f042d66_ru_7238ee98e6_marytts.mp3"
[16:13:34][D][voice_assistant:439]: State changed from AWAITING_RESPONSE to STREAMING_RESPONSE
[16:13:34][D][voice_assistant:445]: Desired state set to STREAMING_RESPONSE
[16:13:34][D][media_player:061]: 'media_player' - Setting
[16:13:34][D][media_player:068]: Media URL: http://192.168.1.114:8123/api/tts_proxy/11218599c3a26e823f1af531775540ed7f042d66_ru_7238ee98e6_marytts.mp3
[16:13:34][D][media_player:074]: Announcement: yes
[16:13:34][D][esp_audio_sources:058]: Set new uri: http://192.168.1.114:8123/api/tts_proxy/11218599c3a26e823f1af531775540ed7f042d66_ru_7238ee98e6_marytts.mp3
[16:13:34][D][adf_media_player:054]: Got control call in state IDLE
[16:13:34][D][adf_media_player:055]: req_track stream uri: http://192.168.1.114:8123/api/tts_proxy/11218599c3a26e823f1af531775540ed7f042d66_ru_7238ee98e6_marytts.mp3
[16:13:34][D][esp_adf_pipeline:060]: Starting request, current state UNINITIALIZED
[16:13:34][D][voice_assistant:563]: Event Type: 2
[16:13:34][D][voice_assistant:653]: Assist Pipeline ended
[16:13:34][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from UNINITIALIZED to INITIALIZING. (REQ: 0)
[16:13:34][I][adf_media_player:189]: got new pipeline state: 1, while in MP state IDLE
[16:13:34][I][adf_media_player:252]: current mp state: IDLE
[16:13:34][I][adf_media_player:253]: anouncement: false
[16:13:34][I][adf_media_player:254]: play_intent: false
[16:13:34][I][adf_media_player:255]: current_uri_: yes
[16:13:34][D][light:036]: 'Test Media Assistant V2 Light' Setting:
[16:13:34][D][light:047]: State: OFF
[16:13:34][D][light:109]: Effect: 'None'
[16:13:34][D][light:036]: 'Test Media Assistant V2 Light' Setting:
[16:13:34][D][light:047]: State: ON
[16:13:34][D][light:051]: Brightness: 25%
[16:13:34][D][light:059]: Red: 0%, Green: 0%, Blue: 100%
[16:13:34][D][micro_wake_word:177]: State changed from IDLE to START_MICROPHONE
[16:13:34][D][micro_wake_word:115]: Starting Microphone
[16:13:34][D][esp_adf_pipeline:060]: Starting request, current state UNINITIALIZED
[16:13:34][D][micro_wake_word:177]: State changed from START_MICROPHONE to STARTING_MICROPHONE
[16:13:34][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from UNINITIALIZED to INITIALIZING. (REQ: 0)
[16:13:34][D][esp-idf:000]: I (14182) MP3_DECODER: MP3 init
[16:13:34][D][esp-idf:000]: I (14185) I2S: DMA Malloc info, datalen=blocksize=2048, dma_buf_count=4
[16:13:34][D][i2s_audio:072]: Installing driver : yes
[16:13:34][D][esp_adf_pipeline:486]: pipeline tag 0, http
[16:13:34][D][esp_adf_pipeline:486]: pipeline tag 1, decoder
[16:13:34][D][esp_adf_pipeline:486]: pipeline tag 2, resampler
[16:13:34][D][esp_adf_pipeline:486]: pipeline tag 3, i2s_out
[16:13:34][D][esp-idf:000]: I (14195) AUDIO_PIPELINE: link el->rb, el:0x3d820084, tag:http, rb:0x3d82075c
[16:13:34][D][esp-idf:000]: I (14196) AUDIO_PIPELINE: link el->rb, el:0x3d820270, tag:decoder, rb:0x3d82179c
[16:13:34][D][esp-idf:000]: I (14198) AUDIO_PIPELINE: link el->rb, el:0x3d82040c, tag:resampler, rb:0x3d8227dc
[16:13:34][D][esp_adf_pipeline:496]: Setting up event listener.
[16:13:34][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from INITIALIZING to CREATED. (REQ: 0)
[16:13:34][I][adf_media_player:189]: got new pipeline state: 2, while in MP state IDLE
[16:13:34][I][adf_media_player:252]: current mp state: IDLE
[16:13:34][I][adf_media_player:253]: anouncement: false
[16:13:34][I][adf_media_player:254]: play_intent: false
[16:13:34][I][adf_media_player:255]: current_uri_: yes
[16:13:34][D][esp-idf:000]: I (14212) I2S: DMA Malloc info, datalen=blocksize=1024, dma_buf_count=4
[16:13:34][D][i2s_audio:072]: Installing driver : yes
[16:13:34][D][esp_adf_pipeline:486]: pipeline tag 0, i2s_in
[16:13:34][D][esp_adf_pipeline:486]: pipeline tag 1, pcm_reader
[16:13:34][D][esp-idf:000]: I (14219) AUDIO_PIPELINE: link el->rb, el:0x3d823134, tag:i2s_in, rb:0x3d8233f0
[16:13:34][D][esp_adf_pipeline:496]: Setting up event listener.
[16:13:34][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from INITIALIZING to CREATED. (REQ: 0)
[16:13:34][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from CREATED to PREPARING. (REQ: 0)
[16:13:34][I][adf_media_player:189]: got new pipeline state: 3, while in MP state IDLE
[16:13:34][D][adf_i2s_out:127]: Set final i2s settings: 16000
[16:13:34][I][adf_media_player:252]: current mp state: PLAYING
[16:13:34][I][adf_media_player:253]: anouncement: false
[16:13:34][I][adf_media_player:254]: play_intent: false
[16:13:34][I][adf_media_player:255]: current_uri_: yes
[16:13:34][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from CREATED to PREPARING. (REQ: 0)
[16:13:34][D][esp_audio_sources:063]: Prepare elements called (initial_call)!
[16:13:34][D][esp_audio_sources:097]: Use fixed settings: no
[16:13:34][D][esp_audio_sources:098]: Streamer status: 1
[16:13:34][D][esp_audio_sources:099]: decoder status: 1
[16:13:34][D][esp_audio_sources:100]: stream uri: http://192.168.1.114:8123/api/tts_proxy/11218599c3a26e823f1af531775540ed7f042d66_ru_7238ee98e6_marytts.mp3
[16:13:34][D][adf_audio_element:108]: Preparing [http]...
[16:13:34][D][esp-idf:000]: I (14248) AUDIO_THREAD: The http task allocate stack on external memory
[16:13:34][D][esp-idf:000]: I (14250) AUDIO_ELEMENT: [http-0x3d820084] Element task created
[16:13:34][D][adf_audio_element:108]: Preparing [decoder]...
[16:13:34][D][esp-idf:000]: I (14253) AUDIO_THREAD: The decoder task allocate stack on external memory
[16:13:34][D][esp-idf:000]: I (14255) AUDIO_ELEMENT: [decoder-0x3d820270] Element task created
[16:13:34][D][adf_audio_element:108]: Preparing [i2s_in]...
[16:13:34][D][esp-idf:000]: I (14259) AUDIO_ELEMENT: [i2s_in-0x3d823134] Element task created
[16:13:34][D][adf_audio_element:108]: Preparing [resampler]...
[16:13:34][D][esp-idf:000]: I (14262) AUDIO_THREAD: The resampler task allocate stack on external memory
[16:13:34][D][esp-idf:000]: I (14264) AUDIO_ELEMENT: [resampler-0x3d82040c] Element task created
[16:13:34][D][adf_audio_element:108]: Preparing [pcm_reader]...
[16:13:34][D][esp-idf:000]: I (14267) AUDIO_ELEMENT: [pcm_reader-0x3d8232a8] Element task created
[16:13:34][D][adf_audio_element:108]: Preparing [i2s_out]...
[16:13:34][D][esp-idf:000]: I (14270) AUDIO_ELEMENT: [i2s_out-0x3d8205c4] Element task created
[16:13:34][D][esp_adf_pipeline:334]: wait for preparation, done
[16:13:34][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from PREPARING to STARTING. (REQ: 0)
[16:13:34][D][adf_audio_element:165]: Resuming [i2s_in]...
[16:13:34][D][adf_audio_element:172]: [i2s_in] Sending resume command.
[16:13:34][D][esp-idf:000][i2s_in]: I (14280) AUDIO_ELEMENT: [i2s_in] AEL_MSG_CMD_RESUME,state:1
[16:13:34][D][adf_audio_element:191]: [i2s_in] Checking State, got 78
[16:13:34][I][esp_adf_pipeline:124]: [ i2s_in ] status: 12
[16:13:34][D][adf_audio_element:191]: [http] Checking State, got 72
[16:13:34][D][adf_audio_element:191]: [decoder] Checking State, got 72
[16:13:34][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from STARTING to RUNNING. (REQ: 0)
[16:13:34][D][micro_wake_word:177]: State changed from STARTING_MICROPHONE to DETECTING_WAKE_WORD
[16:13:34][D][esp-idf:000][http]: I (14298) HTTP_CLIENT: Body received in fetch header state, 0x3fccffab, 1440
[16:13:34][D][esp-idf:000][http]: I (14301) HTTP_STREAM: total_bytes=21210
[16:13:34][I][HTTPStreamReader:193]: [ * ] Receive music info from mp3 decoder, sample_rates=24000, bits=16, ch=1
[16:13:34][D][adf_i2s_out:114]: update i2s clk settings: rate:24000 bits:16 ch:1
[16:13:34][D][esp-idf:000]: I (14350) I2S: DMA Malloc info, datalen=blocksize=1024, dma_buf_count=4
[16:13:34][D][adf_i2s_out:127]: Set final i2s settings: 24000
[16:13:34][D][esp_audio_processors:090]: Received request from: HTTPStreamReader
[16:13:34][D][esp_audio_processors:095]: New settings: SRC: rate: 24000, ch: 1 DST: rate: 24000, ch: 1
[16:13:34][D][adf_audio_element:108]: Preparing [http]...
[16:13:34][D][adf_audio_element:108]: Preparing [decoder]...
[16:13:34][D][esp-idf:000][decoder]: W (14361) AUDIO_ELEMENT: OUT-[decoder] AEL_IO_ABORT
[16:13:34][D][esp-idf:000][decoder]: W (14364) MP3_DECODER: output aborted -3
[16:13:34][D][esp-idf:000][decoder]: I (14367) MP3_DECODER: Closed
[16:13:34][D][esp_audio_sources:153]: Preparation done!
[16:13:34][D][esp_adf_pipeline:334]: wait for preparation, done
[16:13:34][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from PREPARING to STARTING. (REQ: 0)
[16:13:34][I][adf_media_player:189]: got new pipeline state: 5, while in MP state PLAYING
[16:13:34][I][adf_media_player:252]: current mp state: PLAYING
[16:13:34][I][adf_media_player:253]: anouncement: false
[16:13:34][I][adf_media_player:254]: play_intent: false
[16:13:34][I][adf_media_player:255]: current_uri_: yes
[16:13:34][D][adf_audio_element:165]: Resuming [http]...
[16:13:34][D][adf_audio_element:172]: [http] Sending resume command.
[16:13:34][D][adf_audio_element:165]: Resuming [decoder]...
[16:13:34][D][adf_audio_element:172]: [decoder] Sending resume command.
[16:13:34][D][esp-idf:000][decoder]: I (14428) AUDIO_ELEMENT: [decoder] AEL_MSG_CMD_RESUME,state:1
[16:13:34][D][esp-idf:000][decoder]: I (14436) MP3_DECODER: MP3 opened
[16:13:34][I][esp_adf_pipeline:124]: [ decoder ] status: 12
[16:13:34][I][HTTPStreamReader:193]: [ * ] Receive music info from mp3 decoder, sample_rates=24000, bits=16, ch=1
[16:13:35][D][esp-idf:000][http]: W (15399) HTTP_STREAM: No more data,errno:0, total_bytes:21210, rlen = 0
[16:13:35][D][esp-idf:000][http]: I (15402) AUDIO_ELEMENT: IN-[http] AEL_IO_DONE,0
[16:13:35][I][esp_adf_pipeline:124]: [ http ] status: 15
[16:13:35][I][esp_adf_pipeline:127]: current state: RUNNING
[16:13:35][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from RUNNING to FINISHING. (REQ: 0)
[16:13:35][I][adf_media_player:189]: got new pipeline state: 7, while in MP state PLAYING
[16:13:35][I][adf_media_player:252]: current mp state: PLAYING
[16:13:35][I][adf_media_player:253]: anouncement: false
[16:13:35][I][adf_media_player:254]: play_intent: false
[16:13:35][I][adf_media_player:255]: current_uri_: yes
[16:13:36][D][esp-idf:000][decoder]: I (15783) AUDIO_ELEMENT: IN-[decoder] AEL_IO_DONE,-2
[16:13:36][D][esp-idf:000][decoder]: I (15973) MP3_DECODER: Closed
[16:13:36][I][esp_adf_pipeline:124]: [ decoder ] status: 15
[16:13:36][I][esp_adf_pipeline:127]: current state: FINISHING
[16:13:36][D][esp-idf:000][resampler]: I (16058) AUDIO_ELEMENT: IN-[resampler] AEL_IO_DONE,-2
[16:13:36][I][esp_adf_pipeline:124]: [ resampler ] status: 15
[16:13:36][I][esp_adf_pipeline:127]: current state: FINISHING
[16:13:36][D][esp-idf:000][i2s_out]: I (16122) AUDIO_ELEMENT: IN-[i2s_out] AEL_IO_DONE,-2
[16:13:36][I][esp_adf_pipeline:124]: [ i2s_out ] status: 15
[16:13:36][I][esp_adf_pipeline:127]: current state: FINISHING
[16:13:36][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from FINISHING to STOPPED. (REQ: 1)
[16:13:36][I][adf_media_player:189]: got new pipeline state: 4, while in MP state PLAYING
[16:13:36][I][adf_media_player:252]: current mp state: IDLE
[16:13:36][I][adf_media_player:253]: anouncement: false
[16:13:36][I][adf_media_player:254]: play_intent: false
[16:13:36][I][adf_media_player:255]: current_uri_: yes
[16:13:36][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from STOPPED to DESTROYING. (REQ: 1)
[16:13:36][I][adf_media_player:189]: got new pipeline state: 11, while in MP state IDLE
[16:13:36][I][adf_media_player:252]: current mp state: IDLE
[16:13:36][I][adf_media_player:253]: anouncement: false
[16:13:36][I][adf_media_player:254]: play_intent: false
[16:13:36][I][adf_media_player:255]: current_uri_: yes
[16:13:36][D][esp_adf_pipeline:507]: Called deinit_all
[16:13:36][D][esp-idf:000]: I (16333) AUDIO_PIPELINE: audio_pipeline_unlinked
[16:13:36][D][esp-idf:000]: W (16335) AUDIO_ELEMENT: [http] Element has not create when AUDIO_ELEMENT_TERMINATE
[16:13:36][D][esp-idf:000]: W (16336) AUDIO_ELEMENT: [decoder] Element has not create when AUDIO_ELEMENT_TERMINATE
[16:13:36][D][esp-idf:000]: W (16338) AUDIO_ELEMENT: [resampler] Element has not create when AUDIO_ELEMENT_TERMINATE
[16:13:36][D][esp-idf:000]: W (16340) AUDIO_ELEMENT: [i2s_out] Element has not create when AUDIO_ELEMENT_TERMINATE
[16:13:36][D][esp-idf:000]: I (16342) I2S: DMA queue destroyed
[16:13:36][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from DESTROYING to UNINITIALIZED. (REQ: 1)
[16:13:36][I][adf_media_player:189]: got new pipeline state: 0, while in MP state IDLE
[16:13:36][I][adf_media_player:252]: current mp state: IDLE
[16:13:36][I][adf_media_player:253]: anouncement: false
[16:13:36][I][adf_media_player:254]: play_intent: false
[16:13:36][I][adf_media_player:255]: current_uri_: yes
[16:13:36][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from UNINITIALIZED to UNINITIALIZED. (REQ: 1)
[16:13:36][I][adf_media_player:189]: got new pipeline state: 0, while in MP state IDLE
[16:13:36][I][adf_media_player:252]: current mp state: IDLE
[16:13:36][I][adf_media_player:253]: anouncement: false
[16:13:36][I][adf_media_player:254]: play_intent: false
[16:13:36][I][adf_media_player:255]: current_uri_: yes
[16:13:42][D][micro_wake_word:362]: Wake word sliding average probability is 0.731 and most recent probability is 0.992
[16:13:42][D][micro_wake_word:128]: Wake Word Detected
[16:13:42][D][micro_wake_word:177]: State changed from DETECTING_WAKE_WORD to STOP_MICROPHONE
[16:13:42][D][micro_wake_word:134]: Stopping Microphone
[16:13:42][D][esp_adf_pipeline:070]: Called 'stop' while in RUNNING state.
[16:13:42][D][micro_wake_word:177]: State changed from STOP_MICROPHONE to STOPPING_MICROPHONE
[16:13:42][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from RUNNING to ABORTING. (REQ: 1)
[16:13:42][D][adf_audio_element:324]: [i2s_in] Checking State for stopping, got 3
[16:13:42][D][adf_audio_element:324]: [pcm_reader] Checking State for stopping, got 3
[16:13:42][D][esp-idf:000][i2s_in]: W (21573) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:42][D][esp-idf:000][i2s_in]: W (21575) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:42][D][esp-idf:000][i2s_in]: W (21577) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:42][D][esp-idf:000][i2s_in]: W (21580) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[16:13:42][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from ABORTING to STOPPED. (REQ: 1)
[16:13:42][D][micro_wake_word:177]: State changed from STOPPING_MICROPHONE to IDLE
[16:13:42][D][media_player:061]: 'media_player' - Setting
[16:13:42][D][media_player:065]: Command: STOP
[16:13:42][D][esp_adf_pipeline:070]: Called 'stop' while in UNINITIALIZED state.
[16:13:42][D][light:036]: 'Test Media Assistant V2 Light' Setting:
[16:13:42][D][light:051]: Brightness: 75%
[16:13:42][D][light:059]: Red: 0%, Green: 100%, Blue: 0%
[16:13:42][D][light:109]: Effect: 'Pulse'
[16:13:42][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from STOPPED to DESTROYING. (REQ: 1)
[16:13:42][D][esp_adf_pipeline:507]: Called deinit_all
[16:13:42][D][esp-idf:000]: I (21604) AUDIO_PIPELINE: audio_pipeline_unlinked
[16:13:42][D][esp-idf:000]: W (21606) AUDIO_ELEMENT: [i2s_in] Element has not create when AUDIO_ELEMENT_TERMINATE
[16:13:42][D][esp-idf:000]: W (21607) AUDIO_ELEMENT: [pcm_reader] Element has not create when AUDIO_ELEMENT_TERMINATE
[16:13:42][D][esp-idf:000]: I (21609) I2S: DMA queue destroyed
[16:13:42][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from DESTROYING to UNINITIALIZED. (REQ: 1)
[16:13:42][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from UNINITIALIZED to UNINITIALIZED. (REQ: 1)
If you turn on the music in the player after that everything is ok, but the voice assistant doesn't respond ( pulse green light still ).
first command
[16:46:29][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from DESTROYING to UNINITIALIZED. (REQ: 1)
[16:46:29][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from UNINITIALIZED to UNINITIALIZED. (REQ: 1)
[16:46:29][D][voice_assistant:563]: Event Type: 6
[16:46:29][D][voice_assistant:563]: Event Type: 7
[16:46:29][D][voice_assistant:563]: Event Type: 6 - doesn't happen after the second command [16:46:29][D][voice_assistant:563]: Event Type: 7 - doesn't happen after the second command, I think there's something wrong.
yes, I just found a bug which prevents setting the MP_ANNOUNCE define correctly. I am about to submit a fix, just waiting for some tests to finish
yes, I just found a bug which prevents setting the MP_ANNOUNCE define correctly. I am about to submit a fix, just waiting for some tests to finish
done! Could you try again?
yes, I just found a bug which prevents setting the MP_ANNOUNCE define correctly. I am about to submit a fix, just waiting for some tests to finish
done! Could you try again?
cool, I'm already compiling, testing and will report back. thanks for your work and speed
the response speed became slow, but the freeze error disappeared
my code
substitutions:
device_name: "test-media-assistant-v2"
friendly_name: "Test Media Assistant V2"
device_description: "Media Assistant V2"
esp_board: "esp32-s3-devkitc-1"
framework_type: "esp-idf"
# Mic
i2s_lrclk_in_pin: GPIO3 # Mic WS
i2s_bclk_in_pin: GPIO2 # Mic CK
i2s_din_pin: GPIO1 # Mic SD/DA
auto_gain: 31dBFS # MIC gain
# Speaker
i2s_lrclk_out_pin: GPIO21 # Spk LRC
i2s_bclk_out_pin: GPIO14 # Spk BCLK
i2s_dout_pin: GPIO45 # Spk DIN
# Phases of the Voice Assistant
# IDLE: The voice assistant is ready to be triggered by a wake-word
voice_assist_idle_phase_id: '1'
# LISTENING: The voice assistant is ready to listen to a voice command (after being triggered by the wake word)
voice_assist_listening_phase_id: '2'
# THINKING: The voice assistant is currently processing the command
voice_assist_thinking_phase_id: '3'
# REPLYING: The voice assistant is replying to the command
voice_assist_replying_phase_id: '4'
# NOT_READY: The voice assistant is not ready
voice_assist_not_ready_phase_id: '10'
# ERROR: The voice assistant encountered an error
voice_assist_error_phase_id: '11'
# MUTED: The voice assistant is muted and will not reply to a wake-word
voice_assist_muted_phase_id: '12'
external_components:
- source:
type: git
url: https://github.com/gnumpi/esphome_audio
ref: dev-next
components: [ adf_pipeline, i2s_audio ]
refresh: 0s
#- source:
#type: git
#url: https://github.com/gnumpi/esphome
#ref: adf-mods
#components: [ api, media_player, speaker, voice_assistant ]
esphome:
name: ${device_name}
comment: ${device_description}
friendly_name: ${friendly_name}
min_version: 2024.2.0
platformio_options:
build_flags: -DBOARD_HAS_PSRAM
board_build.flash_mode: dio
#board_upload.maximum_size: 16777216
on_boot:
priority: 600
then:
# Run the script to refresh the LED status
# If after 30 seconds, the device is still initializing (It did not yet connect to Home Assistant), turn off the init_in_progress variable and run the script to refresh the LED status
- delay: 30s
- if:
condition:
lambda: return id(init_in_progress);
then:
- lambda: id(init_in_progress) = false;
esp32:
board: ${esp_board}
variant: ESP32S3
flash_size: 8MB
framework:
type: ${framework_type}
version: recommended
sdkconfig_options:
# need to set a s3 compatible board for the adf-sdk to compile
# board specific code is not used though
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
CONFIG_ESP32_S3_BOX_BOARD: "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"
logger:
globals:
# Global initialisation variable. Initialized to true and set to false once everything is connected. Only used to have a smooth "plugging" experience
- id: init_in_progress
type: bool
restore_value: no
initial_value: 'true'
# Global variable tracking the phase of the voice assistant (defined above). Initialized to not_ready
- id: voice_assistant_phase
type: int
restore_value: no
initial_value: ${voice_assist_not_ready_phase_id}
psram:
mode: octal
speed: 80MHz
# Enable Home Assistant API
api:
encryption:
key: "MitAC+hwLqT4vWNVudIUXyYcIS89yx/NAadUsGTiBXk="
ota:
password: "f48e29bb666abfe11cffe5904612ce9d"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Optional manual IP
manual_ip:
static_ip: 192.168.1.73
gateway: 192.168.1.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Freenove-Cam01 Fallback Hotspot"
password: "48zf4JyppQ8P"
i2s_audio: # I2s audio pins
- id: i2s_in
i2s_lrclk_pin: $i2s_lrclk_in_pin # Mic WS
i2s_bclk_pin: $i2s_bclk_in_pin # Mic CK
- id: i2s_out
i2s_lrclk_pin: $i2s_lrclk_out_pin # Spk LRC
i2s_bclk_pin: $i2s_bclk_out_pin # Spk BCLK
adf_pipeline: # ADF pieline pins
- platform: i2s_audio
type: audio_out
id: adf_i2s_out
i2s_audio_id: i2s_out
i2s_dout_pin: GPIO45
sample_rate: 16000
bits_per_sample: 32bit # Spk DIN
- platform: i2s_audio
type: audio_in
id: adf_i2s_in
i2s_audio_id: i2s_in
i2s_din_pin: $i2s_din_pin # Mic SD/DA
channel: left
sample_rate: 16000
bits_per_sample: 32bit
pdm: false
microphone:
- platform: adf_pipeline
id: adf_microphone
gain_log2: 3
keep_pipeline_alive: false
pipeline:
- adf_i2s_in
- self
media_player:
- platform: adf_pipeline
id: adf_media_player
name: media_player
keep_pipeline_alive: false
internal: false
announcement_audio:
sample_rate: 16000
bits_per_sample: 16
num_channels: 1
pipeline:
- self
- resampler
- adf_i2s_out
micro_wake_word:
model: alexa
on_wake_word_detected:
- media_player.stop:
- light.turn_on:
id: led_ring
blue: 0%
red: 0%
green: 100%
brightness: 75%
effect: pulse
- voice_assistant.start:
voice_assistant:
microphone: adf_microphone
media_player: adf_media_player
use_wake_word: false
#vad_threshold: 3
noise_suppression_level: 4
auto_gain: 31dBFS
volume_multiplier: 4.0
on_client_connected:
- lambda: id(init_in_progress) = false;
- if:
condition:
switch.is_on: use_wake_word
then:
- micro_wake_word.start:
- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
- script.execute: reset_led
else:
- lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
on_client_disconnected:
- lambda: id(voice_assistant_phase) = ${voice_assist_not_ready_phase_id};
- voice_assistant.stop
- micro_wake_word.stop
- light.turn_on:
id: led_ring
blue: 0%
red: 100%
green: 100%
brightness: 50%
effect: connecting
on_listening:
- light.turn_on:
id: led_ring
blue: 100%
red: 0%
green: 0%
brightness: 25%
effect: wakeword
on_tts_start:
- light.turn_on:
id: led_ring
blue: 0%
red: 100%
green: 0%
brightness: 100%
effect: pulse
on_end:
then:
- light.turn_off:
id: led_ring
- voice_assistant.stop
- wait_until:
not:
media_player.is_playing:
- script.execute: reset_led
- if:
condition:
switch.is_on: use_wake_word
then:
- micro_wake_word.start:
on_error:
- light.turn_on:
id: led_ring
blue: 0%
red: 100%
green: 0%
brightness: 100%
effect: none
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- lambda: |-
if (code == "wake-provider-missing" || code == "wake-engine-missing") {
id(use_wake_word).turn_off();
}
- if:
condition:
switch.is_on: use_wake_word
then:
- micro_wake_word.start:
- script.execute: reset_led
script:
- id: reset_led
then:
- if:
condition:
switch.is_on: use_wake_word
then:
- light.turn_on:
id: led_ring
blue: 100%
red: 0%
green: 0%
brightness: 25%
effect: none
else:
- light.turn_off: led_ring
button:
- platform: restart
id: restart_btn
name: "${friendly_name} REBOOT"
switch:
- platform: template
name: Enable Voice Assistant
id: use_wake_word
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
icon: mdi:assistant
# When the switch is turned on (on Home Assistant):
# Start the voice assistant component
# Set the correct phase and run the script to refresh the LED status
on_turn_on:
- logger.log: "switch on"
- if:
condition:
lambda: return !id(init_in_progress);
then:
- logger.log: "condition 1"
- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
- voice_assistant.stop
- delay: 1s
- if:
condition:
not:
- voice_assistant.is_running
then:
- logger.log: "Starting MWW"
#- voice_assistant.start_continuous
- micro_wake_word.start:
- script.execute: reset_led
on_turn_off:
- if:
condition:
lambda: return !id(init_in_progress);
then:
- voice_assistant.stop
- micro_wake_word.stop
- lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
- script.execute: reset_led
- platform: template
name: Pipeline
id: pipeline_switch
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
light:
- platform: esp32_rmt_led_strip
id: led_ring
name: "${friendly_name} Light"
pin: GPIO48
num_leds: 1
rmt_channel: 0
rgb_order: GRB
chipset: ws2812
default_transition_length: 0s
effects:
- pulse:
name: "Pulse"
transition_length: 0.5s
update_interval: 0.5s
- addressable_twinkle:
name: "Working"
twinkle_probability: 5%
progress_interval: 4ms
- addressable_color_wipe:
name: "Wakeword"
colors:
- red: 0%
green: 50%
blue: 0%
num_leds: 12
add_led_interval: 20ms
reverse: false
- addressable_color_wipe:
name: "Connecting"
colors:
- red: 60%
green: 60%
blue: 60%
num_leds: 12
- red: 60%
green: 60%
blue: 0%
num_leds: 12
add_led_interval: 100ms
reverse: truethe response speed became slow, but the freeze error disappeared
If I see it correctly in your logs, then you are using a TTS voice with 24000 sampling rate, you should set this value in the announcement_audio settings.
If I see it correctly in your logs, then you are using a TTS voice with 24000 sampling rate, you should set this value in the _announcementaudio settings.
yes, but it worked in the previous step. if you have made changes to this, I will update the script.
If I see it correctly in your logs, then you are using a TTS voice with 24000 sampling rate, you should set this value in the _announcementaudio settings.
yes, but it worked in the previous step. if you have made changes to this, I will update the script.
because of the bug I just fixed, the new announcement_audio settings were not used. But they are now ...
you can also leave announcement_audio unset, then it should detected the audio format automatically, but this takes a while which can be problematic if you request playing an audio stream via voice command.
Got it, thanks. It's working now. No error, continuing the test. The radio is not working yet. The mp3 from the media folder plays without problems.
if you give commands quickly, it happens again.
[19:54:11][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from ABORTING to STOPPED. (REQ: 1)
[19:54:11][D][micro_wake_word:177]: State changed from STOPPING_MICROPHONE to IDLE
[19:54:11][D][media_player:061]: 'media_player' - Setting
[19:54:11][D][media_player:065]: Command: STOP
[19:54:11][D][esp_adf_pipeline:070]: Called 'stop' while in UNINITIALIZED state.
[19:54:11][D][light:036]: 'Test Media Assistant V2 Light' Setting:
[19:54:11][D][light:051]: Brightness: 75%
[19:54:11][D][light:059]: Red: 0%, Green: 100%, Blue: 0%
[19:54:11][D][light:109]: Effect: 'Pulse'
[19:54:11][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from STOPPED to DESTROYING. (REQ: 1)
[19:54:11][D][esp_adf_pipeline:507]: Called deinit_all
[19:54:11][D][esp-idf:000]: I (49163) AUDIO_PIPELINE: audio_pipeline_unlinked
[19:54:11][D][esp-idf:000]: W (49164) AUDIO_ELEMENT: [i2s_in] Element has not create when AUDIO_ELEMENT_TERMINATE
[19:54:11][D][esp-idf:000]: W (49166) AUDIO_ELEMENT: [pcm_reader] Element has not create when AUDIO_ELEMENT_TERMINATE
[19:54:11][D][esp-idf:000]: I (49168) I2S: DMA queue destroyed
[19:54:11][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from DESTROYING to UNINITIALIZED. (REQ: 1)
[19:54:11][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from UNINITIALIZED to UNINITIALIZED. (REQ: 1)
[19:54:11][D][voice_assistant:439]: State changed from STREAMING_RESPONSE to IDLE
[19:54:11][D][voice_assistant:445]: Desired state set to IDLE
I've also noticed this error:
[19:57:33][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from PREPARING to STARTING. (REQ: 0)
[19:57:33][D][adf_audio_element:165]: Resuming [i2s_in]...
[19:57:33][D][adf_audio_element:172]: [i2s_in] Sending resume command.
[19:57:33][D][esp-idf:000][i2s_in]: I (45377) AUDIO_ELEMENT: [i2s_in] AEL_MSG_CMD_RESUME,state:1
[19:57:33][D][adf_audio_element:191]: [pcm_reader] Checking State, got 64
[19:57:33][I][esp_adf_pipeline:124]: [ i2s_in ] status: 12
[19:57:33][D][adf_audio_element:191]: [i2s_in] Checking State, got 78
[19:57:33][D][esp_adf_pipeline:437]: [ADFMicrophone] Pipeline changed from STARTING to RUNNING. (REQ: 0)
[19:57:33][D][micro_wake_word:177]: State changed from STARTING_MICROPHONE to DETECTING_WAKE_WORD
[19:57:33][D][esp_adf_pipeline:334]: wait for preparation, done
[19:57:33][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from PREPARING to STARTING. (REQ: 0)
[19:57:33][I][adf_media_player:189]: got new pipeline state: 5, while in MP state ANNOUNCING
[19:57:33][I][adf_media_player:252]: current mp state: ANNOUNCING
[19:57:33][I][adf_media_player:253]: anouncement: yes
[19:57:33][I][adf_media_player:254]: play_intent: false
[19:57:33][I][adf_media_player:255]: current_uri_: false
[19:57:33][D][adf_audio_element:165]: Resuming [http]...
[19:57:33][D][adf_audio_element:172]: [http] Sending resume command.
[19:57:33][D][adf_audio_element:165]: Resuming [decoder]...
[19:57:33][D][adf_audio_element:172]: [decoder] Sending resume command.
[19:57:33][D][esp-idf:000][decoder]: I (45417) AUDIO_ELEMENT: [decoder] AEL_MSG_CMD_RESUME,state:1
[19:57:33][D][esp-idf:000][decoder]: I (45441) MP3_DECODER: MP3 opened
[19:57:33][D][adf_audio_element:165]: Resuming [i2s_out]...
[19:57:33][D][adf_audio_element:172]: [i2s_out] Sending resume command.
ERROR Fatal error: protocol.data_received() call failed.
protocol: <aioesphomeapi._frame_helper.noise.APINoiseFrameHelper object at 0x7fbe364b85c0>
transport: <_SelectorSocketTransport fd=6 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
File "/usr/lib/python3.11/asyncio/selector_events.py", line 1009, in _read_ready__data_received
self._protocol.data_received(data)
File "aioesphomeapi/_frame_helper/noise.py", line 136, in aioesphomeapi._frame_helper.noise.APINoiseFrameHelper.data_received
File "aioesphomeapi/_frame_helper/noise.py", line 163, in aioesphomeapi._frame_helper.noise.APINoiseFrameHelper.data_received
File "aioesphomeapi/_frame_helper/noise.py", line 319, in aioesphomeapi._frame_helper.noise.APINoiseFrameHelper._handle_frame
File "/usr/local/lib/python3.11/dist-packages/noise/state.py", line 74, in decrypt_with_ad
plaintext = self.cipher.decrypt(self.k, self.n, ad, ciphertext)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/noise/backends/default/ciphers.py", line 13, in decrypt
return self.cipher.decrypt(nonce=self.format_nonce(n), data=ciphertext, associated_data=ad)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "src/chacha20poly1305_reuseable/__init__.py", line 127, in chacha20poly1305_reuseable.ChaCha20Poly1305Reusable.decrypt
File "src/chacha20poly1305_reuseable/__init__.py", line 147, in chacha20poly1305_reuseable.ChaCha20Poly1305Reusable.decrypt
File "src/chacha20poly1305_reuseable/__init__.py", line 263, in chacha20poly1305_reuseable._decrypt_with_fixed_nonce_len
File "src/chacha20poly1305_reuseable/__init__.py", line 273, in chacha20poly1305_reuseable._decrypt_data
cryptography.exceptions.InvalidTag
WARNING test-media-assistant-v2 @ 192.168.1.73: Connection error occurred: test-media-assistant-v2 @ 192.168.1.73: Invalid encryption key: received_name=test-media-assistant-v2
INFO Processing unexpected disconnect from ESPHome API for test-media-assistant-v2 @ 192.168.1.73
WARNING Disconnected from API
INFO Successfully connected to test-media-assistant-v2 @ 192.168.1.73 in 0.003s
INFO Successful handshake with test-media-assistant-v2 @ 192.168.1.73 in 0.068s
[19:57:34][D][esp-idf:000][http]: W (45751) HTTP_STREAM: No more data,errno:0, total_bytes:12993, rlen = 0
[19:57:34][D][esp-idf:000][http]: I (45753) AUDIO_ELEMENT: IN-[http] AEL_IO_DONE,0
[19:57:34][I][esp_adf_pipeline:124]: [ http ] status: 15
[19:57:34][I][esp_adf_pipeline:127]: current state: RUNNING
[19:57:34][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from RUNNING to FINISHING. (REQ: 0)
[19:57:34][I][adf_media_player:189]: got new pipeline state: 7, while in MP state ANNOUNCING
[19:57:34][I][adf_media_player:252]: current mp state: ANNOUNCING
[19:57:34][I][adf_media_player:253]: anouncement: yes
[19:57:34][I][adf_media_player:254]: play_intent: false
[19:57:34][I][adf_media_player:255]: current_uri_: false
[19:57:34][D][esp-idf:000][decoder]: I (46114) AUDIO_ELEMENT: IN-[decoder] AEL_IO_DONE,-2
[19:57:34][D][esp-idf:000][decoder]: I (46325) MP3_DECODER: Closed
[19:57:34][I][esp_adf_pipeline:124]: [ decoder ] status: 15
[19:57:34][I][esp_adf_pipeline:127]: current state: FINISHING
[19:57:34][D][esp-idf:000][resampler]: I (46431) AUDIO_ELEMENT: IN-[resampler] AEL_IO_DONE,-2
[19:57:34][I][esp_adf_pipeline:124]: [ resampler ] status: 15
[19:57:34][I][esp_adf_pipeline:127]: current state: FINISHING
[19:57:34][D][esp-idf:000][i2s_out]: I (46484) AUDIO_ELEMENT: IN-[i2s_out] AEL_IO_DONE,-2
Got it, thanks. It's working now. No error, continuing the test. The radio is not working yet. The mp3 from the media folder plays without problems.
That's strange that none of the radio streams is working for you. I also have some issues with 192kbp mp3 streams which fail to decode every now and then. With 128kbp I don't have any issues. The http client somehow detects the mp3 stream sometimes as an aac stream, I don't see why. Also I don't know if the decoder even uses this information, unfortunately these codecs are closed source. Debugging the adf-sdk exceeds the time I want to spend for a private project like this, so I won't do it at the moment.
if you give commands quickly, it happens again.
oh, thanks for reporting. It seems it tries to free some components which haven't been setup yet when stopping directly after starting the creation process. I will look into that.
I've also noticed this error:
Do you use logging via Wifi? I think this error is not related to the media player itself.
That's strange that none of the radio streams is working for you. I also have some issues with 192kbp mp3 streams which fail to decode every now and then. With 128kbp I don't have any issues. The http client somehow detects the mp3 stream sometimes as an aac stream, I don't see why. Also I don't know if the decoder even uses this information, unfortunately these codecs are closed source. Debugging the adf-sdk exceeds the time I want to spend for a private project like this, so I won't do it at the moment.
can you send me a link to the 128kbs radio that works for you?
Do you use logging via Wifi? I think this error is not related to the media player itself.
I don't know what you mean.
Oh I get it, yes all logs go through wifi, not through UART or wire
can you send me a link to the 128kbs radio that works for you?
sure, e.g these never make any problems on any of my devices:
while e.g. this refuses to work every now and then:
while copying I realised that this is also the only https stream, this could also be the reason
All your links work through programs like VLC or AIMP, but not through the media player. I don't understand how to open your link through a media player. I have a little idea:
I also came across this: https://github.com/sehraf/esphome-components
UDP streaming , I think you can convert everything on the fly via ffmpeg to mp3
yes sure, you can also simply use https://music-assistant.io/ to stream radio stations and Spotify to the adf media_player. This works great.
But it would be nice to know whats going on and to support all streams natively. But you are right, there are workarounds available so let's solve other issues first ;)
yes sure, you can also simply use https://music-assistant.io/ to stream radio stations and Spotify to the adf media_player. This works great.
But it would be nice to know whats going on and to support all streams natively. But you are right, there are workarounds available so let's solve other issues first ;)
I ran through “music assistant”, with customization (forced mp3 in the player settings) and the radio works without problems
continuing the test
[18:40:03][D][media_player:061]: 'media_player' - Setting
[18:40:03][D][media_player:068]: Media URL: http://192.168.1.114:8097/single/media_player.alexa_media_player/d07baa67bc284abeb3edcf9c4cecb708.mp3?ts=1716478803
[18:40:03][D][esp_audio_sources:058]: Set new uri: http://192.168.1.114:8097/single/media_player.alexa_media_player/d07baa67bc284abeb3edcf9c4cecb708.mp3?ts=1716478803
[18:40:03][D][adf_media_player:054]: Got control call in state IDLE
[18:40:03][D][adf_media_player:055]: req_track stream uri: http://192.168.1.114:8097/single/media_player.alexa_media_player/d07baa67bc284abeb3edcf9c4cecb708.mp3?ts=1716478803
[18:40:03][D][esp_adf_pipeline:060]: Starting request, current state UNINITIALIZED
[18:40:03][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from UNINITIALIZED to INITIALIZING. (REQ: 0)
[18:40:03][I][adf_media_player:189]: got new pipeline state: 1, while in MP state IDLE
[18:40:03][I][adf_media_player:252]: current mp state: IDLE
[18:40:03][I][adf_media_player:253]: anouncement: false
[18:40:03][I][adf_media_player:254]: play_intent: false
[18:40:03][I][adf_media_player:255]: current_uri_: yes
[18:40:03][D][esp-idf:000]: I (77975950) MP3_DECODER: MP3 init
[18:40:03][D][esp-idf:000]: I (77975953) I2S: DMA Malloc info, datalen=blocksize=1024, dma_buf_count=4
[18:40:03][D][i2s_audio:072]: Installing driver : yes
[18:40:03][D][esp_adf_pipeline:486]: pipeline tag 0, http
[18:40:03][D][esp_adf_pipeline:486]: pipeline tag 1, decoder
[18:40:03][D][esp_adf_pipeline:486]: pipeline tag 2, resampler
[18:40:03][D][esp_adf_pipeline:486]: pipeline tag 3, i2s_out
[18:40:03][D][esp-idf:000]: I (77975963) AUDIO_PIPELINE: link el->rb, el:0x3d820084, tag:http, rb:0x3d820774
[18:40:03][D][esp-idf:000]: I (77975964) AUDIO_PIPELINE: link el->rb, el:0x3d820278, tag:decoder, rb:0x3d8217b4
[18:40:03][D][esp-idf:000]: I (77975966) AUDIO_PIPELINE: link el->rb, el:0x3d820414, tag:resampler, rb:0x3d8227f4
[18:40:03][D][esp_adf_pipeline:496]: Setting up event listener.
[18:40:03][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from INITIALIZING to CREATED. (REQ: 0)
[18:40:03][I][adf_media_player:189]: got new pipeline state: 2, while in MP state IDLE
[18:40:03][I][adf_media_player:252]: current mp state: IDLE
[18:40:03][I][adf_media_player:253]: anouncement: false
[18:40:03][I][adf_media_player:254]: play_intent: false
[18:40:03][I][adf_media_player:255]: current_uri_: yes
[18:40:03][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from CREATED to PREPARING. (REQ: 0)
[18:40:03][I][adf_media_player:189]: got new pipeline state: 3, while in MP state IDLE
[18:40:03][D][adf_i2s_out:127]: Set final i2s settings: 44100
[18:40:03][I][adf_media_player:252]: current mp state: PLAYING
[18:40:03][I][adf_media_player:253]: anouncement: false
[18:40:03][I][adf_media_player:254]: play_intent: false
[18:40:03][I][adf_media_player:255]: current_uri_: yes
[18:40:03][D][esp_audio_sources:063]: Prepare elements called (initial_call)!
[18:40:03][D][esp_audio_sources:097]: Use fixed settings: no
[18:40:03][D][esp_audio_sources:098]: Streamer status: 1
[18:40:03][D][esp_audio_sources:099]: decoder status: 1
[18:40:03][D][esp_audio_sources:100]: stream uri: http://192.168.1.114:8097/single/media_player.alexa_media_player/d07baa67bc284abeb3edcf9c4cecb708.mp3?ts=1716478803
[18:40:03][D][adf_audio_element:108]: Preparing [http]...
[18:40:03][D][esp-idf:000]: I (77976015) AUDIO_THREAD: The http task allocate stack on external memory
[18:40:03][D][esp-idf:000]: I (77976017) AUDIO_ELEMENT: [http-0x3d820084] Element task created
[18:40:03][D][adf_audio_element:108]: Preparing [decoder]...
[18:40:03][D][esp-idf:000]: I (77976020) AUDIO_THREAD: The decoder task allocate stack on external memory
[18:40:03][D][esp-idf:000]: I (77976022) AUDIO_ELEMENT: [decoder-0x3d820278] Element task created
[18:40:03][D][adf_audio_element:108]: Preparing [resampler]...
[18:40:03][D][esp-idf:000]: I (77976033) AUDIO_THREAD: The resampler task allocate stack on external memory
[18:40:03][D][esp-idf:000]: I (77976035) AUDIO_ELEMENT: [resampler-0x3d820414] Element task created
[18:40:03][D][adf_audio_element:108]: Preparing [i2s_out]...
[18:40:03][D][esp-idf:000]: I (77976046) AUDIO_ELEMENT: [i2s_out-0x3d8205cc] Element task created
[18:40:03][D][adf_audio_element:165]: Resuming [http]...
[18:40:03][D][adf_audio_element:172]: [http] Sending resume command.
[18:40:03][D][adf_audio_element:165]: Resuming [decoder]...
[18:40:03][D][adf_audio_element:172]: [decoder] Sending resume command.
[18:40:03][D][adf_audio_element:191]: [http] Checking State, got 72
[18:40:03][D][adf_audio_element:191]: [decoder] Checking State, got 8
[18:40:03][D][esp-idf:000][http]: I (77976072) HTTP_STREAM: total_bytes=0
[18:40:03][D][adf_audio_element:191]: [http] Checking State, got 74
[18:40:03][D][adf_audio_element:191]: [decoder] Checking State, got 72
[18:40:05][I][HTTPStreamReader:193]: [ * ] Receive music info from mp3 decoder, sample_rates=44100, bits=16, ch=2
[18:40:05][D][adf_i2s_out:127]: Set final i2s settings: 44100
[18:40:05][D][adf_audio_element:108]: Preparing [http]...
[18:40:05][D][adf_audio_element:108]: Preparing [decoder]...
[18:40:05][D][esp-idf:000][decoder]: W (77977990) AUDIO_ELEMENT: OUT-[decoder] AEL_IO_ABORT
[18:40:05][D][esp-idf:000][decoder]: W (77977993) MP3_DECODER: output aborted -3
[18:40:05][D][esp-idf:000][decoder]: I (77977996) MP3_DECODER: Closed
[18:40:05][D][esp_audio_sources:153]: Preparation done!
[18:40:05][D][esp_adf_pipeline:334]: wait for preparation, done
[18:40:05][D][esp_adf_pipeline:437]: [MediaPlayer] Pipeline changed from PREPARING to STARTING. (REQ: 0)
[18:40:05][I][adf_media_player:189]: got new pipeline state: 5, while in MP state PLAYING
[18:40:05][I][adf_media_player:252]: current mp state: PLAYING
[18:40:05][I][adf_media_player:253]: anouncement: false
[18:40:05][I][adf_media_player:254]: play_intent: false
[18:40:05][I][adf_media_player:255]: current_uri_: yes
[18:40:05][D][adf_audio_element:165]: Resuming [http]...
[18:40:05][D][adf_audio_element:172]: [http] Sending resume command.
[18:40:05][D][adf_audio_element:165]: Resuming [decoder]...
[18:40:05][D][adf_audio_element:172]: [decoder] Sending resume command.
[18:40:05][D][esp-idf:000][decoder]: I (77978044) AUDIO_ELEMENT: [decoder] AEL_MSG_CMD_RESUME,state:1
[18:40:05][D][esp-idf:000][http]: I (77978055) HTTP_STREAM: total_bytes=0
[18:40:05][D][esp-idf:000][decoder]: I (77978053) MP3_DECODER: MP3 opened
[18:40:07][I][esp_adf_pipeline:124]: [ decoder ] status: 12
[18:40:07][I][HTTPStreamReader:193]: [ * ] Receive music info from mp3 decoder, sample_rates=44100, bits=16, ch=2
Hello everyone, i have the same problem. The Audio output is very slow.
Can anyone help me? Many thanks in advance.
The output of the assistant is low and when I play an mp3 file or a radio stream, which also uses mp3, the sound output is very slow.
if i set the announcement_audio settings, then the audio output for the assistant is better but for mp3s it remains slow.
announcement_audio:
sample_rate: 16000
bits_per_sample: 32
num_channels: 1
here is my used script and log. Using esphome version 2024.5.5 HW: Max98357 + INMP441 + esp32s3
substitutions:
node_name: esp32-s3-n16r8
device_name: "media-assistant-buero"
friendly_name: "Büro Media Assistant"
device_description: "XIAO ESP32 S3"
esp_board: "esp32-s3-devkitc-1"
framework_type: "esp-idf"
framework_version: "4.4.7"
din: "GPIO1" # MAX98357A - DIN
lrclk: "GPIO7" # MAX98357A - LRCLK / INMP441 - WS
bclk: "GPIO8" # MAX98357A - BCLK / INMP441 - SCK
sd: "GPIO2" # INMP441 - SD
l_r: "left" # INMP441 - L/R (3.3v = right / GND = left)
di: "GPIO9" # WS2812 - DI
api_key: "xxx"
# Phases of the Voice Assistant
# IDLE: The voice assistant is ready to be triggered by a wake-word
voice_assist_idle_phase_id: '1'
# LISTENING: The voice assistant is ready to listen to a voice command (after being triggered by the wake word)
voice_assist_listening_phase_id: '2'
# THINKING: The voice assistant is currently processing the command
voice_assist_thinking_phase_id: '3'
# REPLYING: The voice assistant is replying to the command
voice_assist_replying_phase_id: '4'
# NOT_READY: The voice assistant is not ready
voice_assist_not_ready_phase_id: '10'
# ERROR: The voice assistant encountered an error
voice_assist_error_phase_id: '11'
# MUTED: The voice assistant is muted and will not reply to a wake-word
voice_assist_muted_phase_id: '12'
globals:
# Global initialisation variable. Initialized to true and set to false once everything is connected. Only used to have a smooth "plugging" experience
- id: init_in_progress
type: bool
restore_value: no
initial_value: 'true'
# Global variable tracking the phase of the voice assistant (defined above). Initialized to not_ready
- id: voice_assistant_phase
type: int
restore_value: no
initial_value: ${voice_assist_not_ready_phase_id}
external_components:
- source:
type: git
url: https://github.com/gnumpi/esphome_audio
ref: dev-next
#type: local
#path: /Users/siekmann/Privat/Projects/espHome/esphome_audio/esphome/components
components: [ adf_pipeline, i2s_audio ]
refresh: 0s
esphome:
name: ${device_name}
min_version: 2024.2.0
platformio_options:
build_flags: -DBOARD_HAS_PSRAM
board_build.flash_mode: dio
board_upload.maximum_size: 16777216
on_boot:
priority: 100
then:
# Run the script to refresh the LED status
# If after 30 seconds, the device is still initializing (It did not yet connect to Home Assistant), turn off the init_in_progress variable and run the script to refresh the LED status
- delay: 30s
- if:
condition:
lambda: return id(init_in_progress);
then:
- lambda: id(init_in_progress) = false;
- light.turn_on:
id: led_ww
red: 100%
brightness: 60%
effect: fast pulse
esp32:
board: ${esp_board}
variant: ESP32S3
flash_size: 8MB
framework:
type: ${framework_type}
version: ${framework_version}
sdkconfig_options:
# need to set a s3 compatible board for the adf-sdk to compile
# board specific code is not used though
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
CONFIG_ESP32_S3_BOX_BOARD: "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"
CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY: "y"
#CONFIG_LOG_DEFAULT_LEVEL_DEBUG: "y"
#CONFIG_LOG_DEFAULT_LEVEL: "4"
logger:
hardware_uart : UART0
level: VERBOSE
logs:
micro_wake_word: WARN
psram:
mode: octal
speed: 80MHz
wifi:
output_power: 8.5dB
enable_rrm: true
ssid: "xxx"
password: "xxx"
fast_connect: true
api:
encryption:
key: ${api_key}
ota:
password: "xxx"
i2s_audio:
# - id: i2s_in
# i2s_lrclk_pin: GPIO5
# i2s_bclk_pin: GPIO6
# - id: i2s_out
# i2s_lrclk_pin: GPIO46
# i2s_bclk_pin: GPIO9
- id: i2s_dplx
i2s_lrclk_pin: ${lrclk}
i2s_bclk_pin: ${bclk}
access_mode: duplex
adf_pipeline:
- platform: i2s_audio
type: audio_out
id: adf_i2s_out
# i2s_audio_id: i2s_out
# i2s_dout_pin: GPIO10
i2s_audio_id: i2s_dplx
i2s_dout_pin: ${din}
sample_rate: 16000
bits_per_sample: 32bit
fixed_settings: true
- platform: i2s_audio
type: audio_in
id: adf_i2s_in
# i2s_audio_id: i2s_in
# i2s_din_pin: GPIO4
i2s_audio_id: i2s_dplx
i2s_din_pin: ${sd}
pdm: false
channel: ${l_r}
sample_rate: 16000
bits_per_sample: 32bit
fixed_settings: true
microphone:
- platform: adf_pipeline
id: adf_microphone
#gain_log2: 3
keep_pipeline_alive: true # unterschied -> true
pipeline:
- adf_i2s_in
#- resampler
- self
media_player:
- platform: adf_pipeline
id: adf_media_player
name: ${friendly_name} Media Player
keep_pipeline_alive: true # unterschied -> true
internal: false
announcement_audio:
sample_rate: 16000
bits_per_sample: 32
num_channels: 1
pipeline:
- self
- resampler # unterschied
- adf_i2s_out
micro_wake_word:
model: okay_nabu
on_wake_word_detected:
- media_player.stop:
- light.turn_on:
id: led_ww
blue: 0%
red: 0%
green: 100%
effect: "Slow Pulse"
- voice_assistant.start:
voice_assistant:
microphone: adf_microphone
media_player: adf_media_player
use_wake_word: false
#vad_threshold: 3
noise_suppression_level: 1
auto_gain: 31dBFS
volume_multiplier: 14.0
on_client_connected:
- lambda: id(init_in_progress) = false;
- light.turn_on:
id: led_ww
blue: 50%
red: 100%
green: 100%
brightness: 50%
effect: "Slow Pulse"
- if:
condition:
switch.is_on: use_wake_word
then:
- logger.log: "Starting wake word detection on client connecting..."
- micro_wake_word.start:
- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
- script.execute: reset_led
else:
- lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
on_client_disconnected:
- lambda: id(voice_assistant_phase) = ${voice_assist_not_ready_phase_id};
- voice_assistant.stop
- micro_wake_word.stop
- light.turn_on:
id: led_ww
blue: 0%
red: 100%
green: 100%
brightness: 50%
effect: "Slow Pulse"
on_listening:
then:
- logger.log: "Listening for commands..."
- light.turn_on:
id: led_ww
blue: 100%
red: 0%
green: 0%
brightness: 25%
effect: "Fast Pulse"
on_tts_start:
then:
- logger.log: "Starting TTS..."
- light.turn_on:
id: led_ww
blue: 0%
red: 0%
green: 100%
brightness: 75%
effect: "Fast Pulse"
on_end:
then:
- logger.log: "Voice assistant session ended."
- light.turn_off:
id: led_ww
- voice_assistant.stop
- wait_until:
not:
media_player.is_playing:
- script.execute: reset_led
- if:
condition:
switch.is_on: use_wake_word
then:
- logger.log: "Restarting wake word detection..."
#- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
- micro_wake_word.start:
- script.execute: reset_led
on_error:
- light.turn_on:
id: led_ww
blue: 0%
red: 100%
green: 0%
brightness: 100%
effect: none
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- lambda: |-
if (code == "wake-provider-missing" || code == "wake-engine-missing") {
id(use_wake_word).turn_off();
}
- if:
condition:
switch.is_on: use_wake_word
then:
- micro_wake_word.start:
- script.execute: reset_led
script:
- id: reset_led
then:
- if:
condition:
switch.is_on: use_wake_word
then:
- light.turn_on:
id: led_ww
blue: 100%
red: 0%
green: 0%
brightness: 25%
effect: none
else:
- light.turn_off: led_ww
button:
- platform: restart
name: Restart
entity_category: diagnostic
disabled_by_default: false
icon: mdi:restart
device_class: restart
switch:
- platform: template
name: Enable Voice Assistant
id: use_wake_word
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
icon: mdi:assistant
# When the switch is turned on (on Home Assistant):
# Start the voice assistant component
# Set the correct phase and run the script to refresh the LED status
on_turn_on:
- logger.log: "switch on"
- if:
condition:
lambda: return !id(init_in_progress);
then:
- logger.log: "condition 1"
- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
- voice_assistant.stop:
- delay: 1s
- if:
condition:
not:
- voice_assistant.is_running
then:
- logger.log: "Starting MWW"
- micro_wake_word.start:
- script.execute: reset_led
else:
- logger.log: "Voice assistant is still running"
on_turn_off:
- if:
condition:
lambda: return !id(init_in_progress);
then:
- voice_assistant.stop
- lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
- script.execute: reset_led
- platform: template
name: Pipeline
id: pipeline_switch
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
on_turn_off:
- media_player.stop
on_turn_on:
- media_player.play_media: "https://dl.espressif.com/dl/audio/ff-16b-2c-44100hz.mp3"
light:
- platform: esp32_rmt_led_strip
rgb_order: GRB
pin: GPIO48
num_leds: 1
rmt_channel: 0
chipset: WS2812
name: "led"
id: led_ww
disabled_by_default: false
#entity_category: diagnostic
icon: mdi:led-on
default_transition_length: 0s
effects:
- pulse:
name: "Slow Pulse"
transition_length: 250ms
update_interval: 250ms
min_brightness: 50%
max_brightness: 100%
- pulse:
name: "Fast Pulse"
transition_length: 100ms
update_interval: 100ms
min_brightness: 50%
max_brightness: 100%
Voice Assistant log:
09:52:45][C][ota:096]: Over-The-Air Updates:
[09:52:45][C][ota:097]: Address: media-assistant-buero.local:3232
[09:52:45][C][ota:100]: Using Password.
[09:52:45][C][ota:103]: OTA version: 2.
[09:52:45][C][api:139]: API Server:
[09:52:45][C][api:140]: Address: media-assistant-buero.local:6053
[09:52:45][C][api:142]: Using noise encryption: YES
[09:52:45][C][esp_adf_pipeline.microphone:020]: ADF-Microphone
[09:52:45][C][adf_media_player:016]: ESP-ADF-MediaPlayer:
[09:52:45][C][adf_media_player:018]: MP_ANNOUNCE enabled
[09:52:45][C][adf_media_player:024]: Number of ADFComponents: 3
[09:53:01][D][esp_adf_pipeline:070]: Called 'stop' while in RUNNING state.
[09:53:01][D][esp_adf_pipeline:445]: [ADFMicrophone] Pipeline changed from RUNNING to ABORTING. (REQ: 1)
[09:53:01][D][adf_audio_element:324]: [i2s_in] Checking State for stopping, got 3
[09:53:01][V][esp-idf:000][i2s_in]: W (35830) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[09:53:01][V][esp-idf:000][i2s_in]: W (35833) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[09:53:01][V][esp-idf:000][i2s_in]: W (35835) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[09:53:01][V][esp-idf:000][i2s_in]: W (35837) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[09:53:01][D][esp_adf_pipeline:445]: [ADFMicrophone] Pipeline changed from ABORTING to STOPPED. (REQ: 1)
[09:53:01][D][media_player:061]: 'Büro Media Assistant Media Player' - Setting
[09:53:01][D][media_player:065]: Command: STOP
[09:53:01][D][esp_adf_pipeline:070]: Called 'stop' while in UNINITIALIZED state.
[09:53:01][D][light:036]: 'led' Setting:
[09:53:01][D][light:059]: Red: 0%, Green: 100%, Blue: 0%
[09:53:01][D][light:109]: Effect: 'Slow Pulse'
[09:53:01][D][voice_assistant:502]: State changed from IDLE to START_MICROPHONE
[09:53:01][D][voice_assistant:508]: Desired state set to START_PIPELINE
[09:53:01][D][voice_assistant:220]: Starting Microphone
[09:53:01][D][ring_buffer:024]: Created ring buffer with size 16384
[09:53:01][D][esp_adf_pipeline:060]: Starting request, current state STOPPED
[09:53:01][D][voice_assistant:502]: State changed from START_MICROPHONE to STARTING_MICROPHONE
[09:53:01][D][esp_adf_pipeline:445]: [ADFMicrophone] Pipeline changed from STOPPED to PREPARING. (REQ: 0)
[09:53:01][D][adf_audio_element:108]: Preparing [i2s_in]...
[09:53:01][D][adf_audio_element:108]: Preparing [pcm_reader]...
[09:53:01][D][esp_adf_pipeline:342]: wait for preparation, done
[09:53:01][D][esp_adf_pipeline:445]: [ADFMicrophone] Pipeline changed from PREPARING to STARTING. (REQ: 0)
[09:53:01][D][adf_audio_element:165]: Resuming [i2s_in]...
[09:53:01][D][adf_audio_element:172]: [i2s_in] Sending resume command.
[09:53:01][V][adf_audio_element:035]: [i2s_in]evt internal cmd = 5
[09:53:01][V][esp-idf:000][i2s_in]: I (35987) AUDIO_ELEMENT: [i2s_in] AEL_MSG_CMD_RESUME,state:1
[09:53:01][D][adf_audio_element:191]: [i2s_in] Checking State, got 78
[09:53:01][I][esp_adf_pipeline:132]: [ i2s_in ] status: 12
[09:53:01][D][adf_audio_element:191]: [pcm_reader] Checking State, got 65
[09:53:01][D][esp_adf_pipeline:445]: [ADFMicrophone] Pipeline changed from STARTING to RUNNING. (REQ: 0)
[09:53:01][D][voice_assistant:502]: State changed from STARTING_MICROPHONE to START_PIPELINE
[09:53:01][D][voice_assistant:274]: Requesting start...
[09:53:01][D][voice_assistant:502]: State changed from START_PIPELINE to STARTING_PIPELINE
[09:53:01][D][voice_assistant:523]: Client started, streaming microphone
[09:53:01][D][voice_assistant:502]: State changed from STARTING_PIPELINE to STREAMING_MICROPHONE
[09:53:01][D][voice_assistant:508]: Desired state set to STREAMING_MICROPHONE
[09:53:01][D][voice_assistant:625]: Event Type: 1
[09:53:01][D][voice_assistant:628]: Assist Pipeline running
[09:53:01][D][voice_assistant:625]: Event Type: 3
[09:53:01][D][voice_assistant:639]: STT started
[09:53:01][D][main:690]: Listening for commands...
[09:53:01][D][light:036]: 'led' Setting:
[09:53:01][D][light:051]: Brightness: 25%
[09:53:01][D][light:059]: Red: 0%, Green: 0%, Blue: 100%
[09:53:01][D][light:109]: Effect: 'Fast Pulse'
[09:53:02][D][voice_assistant:625]: Event Type: 11
[09:53:02][D][voice_assistant:779]: Starting STT by VAD
[09:53:03][D][voice_assistant:625]: Event Type: 12
[09:53:03][D][voice_assistant:783]: STT by VAD end
[09:53:03][D][voice_assistant:502]: State changed from STREAMING_MICROPHONE to STOP_MICROPHONE
[09:53:03][D][voice_assistant:508]: Desired state set to AWAITING_RESPONSE
[09:53:03][D][esp_adf_pipeline:070]: Called 'stop' while in RUNNING state.
[09:53:03][D][voice_assistant:502]: State changed from STOP_MICROPHONE to STOPPING_MICROPHONE
[09:53:03][D][esp_adf_pipeline:445]: [ADFMicrophone] Pipeline changed from RUNNING to ABORTING. (REQ: 1)
[09:53:03][D][adf_audio_element:324]: [i2s_in] Checking State for stopping, got 3
[09:53:03][V][esp-idf:000][i2s_in]: W (37531) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[09:53:03][V][esp-idf:000][i2s_in]: W (37542) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[09:53:03][V][esp-idf:000][i2s_in]: W (37545) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[09:53:03][V][esp-idf:000][i2s_in]: W (37552) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[09:53:03][V][esp-idf:000][i2s_in]: W (37562) AUDIO_ELEMENT: OUT-[i2s_in] AEL_IO_ABORT
[09:53:03][D][esp_adf_pipeline:445]: [ADFMicrophone] Pipeline changed from ABORTING to STOPPED. (REQ: 1)
[09:53:03][D][voice_assistant:502]: State changed from STOPPING_MICROPHONE to AWAITING_RESPONSE
[09:53:05][D][voice_assistant:625]: Event Type: 4
[09:53:05][D][voice_assistant:653]: Speech recognised as: "Wie spät."
[09:53:05][D][voice_assistant:625]: Event Type: 5
[09:53:05][D][voice_assistant:658]: Intent started
[09:53:08][D][voice_assistant:625]: Event Type: 6
[09:53:08][D][voice_assistant:625]: Event Type: 7
[09:53:08][D][voice_assistant:681]: Response: "Es ist 11:53 Uhr."
[09:53:08][D][main:981]: Starting TTS...
[09:53:08][D][light:036]: 'led' Setting:
[09:53:08][D][light:051]: Brightness: 75%
[09:53:08][D][light:059]: Red: 0%, Green: 100%, Blue: 0%
[09:53:08][D][voice_assistant:625]: Event Type: 8
[09:53:08][D][voice_assistant:701]: Response URL: "http://homeassistant.local:8123/api/tts_proxy/94156db5c9b9e13974c65547acef8343e59e2956_de-de_896097e9b0_tts.microsoft.mp3"
[09:53:08][D][voice_assistant:502]: State changed from AWAITING_RESPONSE to STREAMING_RESPONSE
[09:53:08][D][voice_assistant:508]: Desired state set to STREAMING_RESPONSE
[09:53:08][D][media_player:061]: 'Büro Media Assistant Media Player' - Setting
[09:53:08][D][media_player:068]: Media URL: http://homeassistant.local:8123/api/tts_proxy/94156db5c9b9e13974c65547acef8343e59e2956_de-de_896097e9b0_tts.microsoft.mp3
[09:53:08][D][media_player:074]: Announcement: yes
[09:53:08][D][adf_media_player:057]: Got control call in state IDLE
[09:53:08][D][adf_media_player:058]: req_track stream uri: http://homeassistant.local:8123/api/tts_proxy/94156db5c9b9e13974c65547acef8343e59e2956_de-de_896097e9b0_tts.microsoft.mp3
[09:53:08][D][esp_adf_pipeline:060]: Starting request, current state UNINITIALIZED
[09:53:08][D][voice_assistant:625]: Event Type: 2
[09:53:08][D][voice_assistant:715]: Assist Pipeline ended
[09:53:08][D][esp_adf_pipeline:445]: [MediaPlayer] Pipeline changed from UNINITIALIZED to INITIALIZING. (REQ: 0)
[09:53:08][I][adf_media_player:192]: got new pipeline state: 1, while in MP state IDLE
[09:53:08][I][adf_media_player:255]: current mp state: IDLE
[09:53:09][I][adf_media_player:256]: anouncement: yes
[09:53:09][I][adf_media_player:257]: play_intent: false
[09:53:09][I][adf_media_player:258]: current_uri_: false
[09:53:09][D][main:993]: Voice assistant session ended.
[09:53:09][D][light:036]: 'led' Setting:
[09:53:09][D][light:047]: State: OFF
[09:53:09][D][light:109]: Effect: 'None'
[09:53:09][D][light:036]: 'led' Setting:
[09:53:09][D][light:047]: State: ON
[09:53:09][D][light:051]: Brightness: 25%
[09:53:09][D][light:059]: Red: 0%, Green: 0%, Blue: 100%
[09:53:09][D][main:1010]: Restarting wake word detection...
[09:53:09][D][light:036]: 'led' Setting:
[09:53:09][D][light:051]: Brightness: 25%
[09:53:09][D][light:059]: Red: 0%, Green: 0%, Blue: 100%
[09:53:09][D][esp_adf_pipeline:060]: Starting request, current state STOPPED
[09:53:09][D][esp_adf_pipeline:445]: [ADFMicrophone] Pipeline changed from STOPPED to PREPARING. (REQ: 0)
[09:53:09][V][esp-idf:000]: I (43587) MP3_DECODER: MP3 init
[09:53:09][D][i2s_audio:067]: Install driver requested by Writer
[09:53:09][D][esp_adf_pipeline:494]: pipeline tag 0, http
[09:53:09][D][esp_adf_pipeline:494]: pipeline tag 1, decoder
[09:53:09][D][esp_adf_pipeline:494]: pipeline tag 2, resampler
[09:53:09][D][esp_adf_pipeline:494]: pipeline tag 3, i2s_out
[09:53:09][V][esp-idf:000]: I (43627) AUDIO_PIPELINE: link el->rb, el:0x3d81d000, tag:http, rb:0x3d81d654
[09:53:09][V][esp-idf:000]: I (43629) AUDIO_PIPELINE: link el->rb, el:0x3d81d1b8, tag:decoder, rb:0x3d85d694
[09:53:09][V][esp-idf:000]: I (43637) AUDIO_PIPELINE: link el->rb, el:0x3d81d354, tag:resampler, rb:0x3d85e6d4
[09:53:09][D][esp_adf_pipeline:504]: Setting up event listener.
[09:53:09][D][esp_adf_pipeline:445]: [MediaPlayer] Pipeline changed from INITIALIZING to CREATED. (REQ: 0)
[09:53:09][I][adf_media_player:192]: got new pipeline state: 2, while in MP state IDLE
[09:53:09][I][adf_media_player:255]: current mp state: IDLE
[09:53:09][I][adf_media_player:256]: anouncement: yes
[09:53:09][I][adf_media_player:257]: play_intent: false
[09:53:09][I][adf_media_player:258]: current_uri_: false
[09:53:09][W][component:237]: Component adf_pipeline.media_player took a long time for an operation (113 ms).
[09:53:09][W][component:238]: Components should block for at most 30 ms.
[09:53:09][D][adf_audio_element:108]: Preparing [i2s_in]...
[09:53:09][D][esp_adf_pipeline:445]: [MediaPlayer] Pipeline changed from CREATED to PREPARING. (REQ: 0)
[09:53:09][I][adf_media_player:192]: got new pipeline state: 3, while in MP state IDLE
[09:53:09][D][adf_i2s_out:127]: Set final i2s settings: 16000
[09:53:09][I][adf_media_player:255]: current mp state: ANNOUNCING
[09:53:09][I][adf_media_player:256]: anouncement: yes
[09:53:09][I][adf_media_player:257]: play_intent: false
[09:53:09][I][adf_media_player:258]: current_uri_: false
[09:53:09][D][adf_audio_element:108]: Preparing [pcm_reader]...
[09:53:09][D][esp_audio_sources:103]: Prepare elements called (initial_call)!
[09:53:09][D][esp_audio_sources:137]: Use fixed settings: yes
[09:53:09][D][esp_audio_sources:138]: Streamer status: 1
[09:53:09][D][esp_audio_sources:139]: decoder status: 1
[09:53:09][D][esp_audio_sources:140]: stream uri: http://homeassistant.local:8123/api/tts_proxy/94156db5c9b9e13974c65547acef8343e59e2956_de-de_896097e9b0_tts.microsoft.mp3
[09:53:09][D][adf_i2s_out:127]: Set final i2s settings: 16000
[09:53:09][D][esp_audio_processors:098]: Received request from: HTTPStreamReader
[09:53:09][D][esp_audio_processors:103]: New settings: SRC: rate: 16000, ch: 1 bits: 32, DST: rate: 16000, ch: 2, bits 16
[09:53:09][D][adf_audio_element:108]: Preparing [http]...
[09:53:09][V][esp-idf:000]: I (43825) AUDIO_THREAD: The http task allocate stack on external memory
[09:53:09][V][esp-idf:000]: I (43842) AUDIO_ELEMENT: [http-0x3d81d000] Element task created
[09:53:09][D][adf_audio_element:108]: Preparing [decoder]...
[09:53:09][V][esp-idf:000]: I (43852) AUDIO_THREAD: The decoder task allocate stack on external memory
[09:53:09][V][esp-idf:000]: I (43862) AUDIO_ELEMENT: [decoder-0x3d81d1b8] Element task created
[09:53:09][W][component:237]: Component adf_pipeline.media_player took a long time for an operation (110 ms).
[09:53:09][W][component:238]: Components should block for at most 30 ms.
[09:53:09][D][adf_audio_element:108]: Preparing [resampler]...
[09:53:09][V][esp-idf:000]: I (43894) AUDIO_THREAD: The resampler task allocate stack on external memory
[09:53:09][V][esp-idf:000]: I (43903) AUDIO_ELEMENT: [resampler-0x3d81d354] Element task created
[09:53:09][D][esp_adf_pipeline:342]: wait for preparation, done
[09:53:09][D][esp_adf_pipeline:445]: [ADFMicrophone] Pipeline changed from PREPARING to STARTING. (REQ: 0)
[09:53:09][D][adf_audio_element:108]: Preparing [i2s_out]...
[09:53:09][V][esp-idf:000]: I (43934) AUDIO_ELEMENT: [i2s_out-0x3d81d50c] Element task created
[09:53:09][D][adf_audio_element:165]: Resuming [i2s_in]...
[09:53:09][D][adf_audio_element:172]: [i2s_in] Sending resume command.
[09:53:09][V][adf_audio_element:035]: [i2s_in]evt internal cmd = 5
[09:53:09][V][esp-idf:000][i2s_in]: I (43965) AUDIO_ELEMENT: [i2s_in] AEL_MSG_CMD_RESUME,state:1
[09:53:09][D][adf_audio_element:191]: [i2s_in] Checking State, got 78
[09:53:09][I][esp_adf_pipeline:132]: [ i2s_in ] status: 12
[09:53:09][D][adf_audio_element:191]: [pcm_reader] Checking State, got 65
[09:53:09][D][esp_adf_pipeline:445]: [ADFMicrophone] Pipeline changed from STARTING to RUNNING. (REQ: 0)
[09:53:09][D][esp_audio_sources:193]: Preparation done!
[09:53:09][D][esp_adf_pipeline:342]: wait for preparation, done
[09:53:09][D][esp_adf_pipeline:445]: [MediaPlayer] Pipeline changed from PREPARING to STARTING. (REQ: 0)
[09:53:09][I][adf_media_player:192]: got new pipeline state: 5, while in MP state ANNOUNCING
[09:53:09][I][adf_media_player:255]: current mp state: ANNOUNCING
[09:53:09][I][adf_media_player:256]: anouncement: yes
[09:53:09][I][adf_media_player:257]: play_intent: false
[09:53:09][I][adf_media_player:258]: current_uri_: false
[09:53:09][D][adf_audio_element:165]: Resuming [http]...
[09:53:09][D][adf_audio_element:172]: [http] Sending resume command.
[09:53:09][V][adf_audio_element:035]: [http]evt internal cmd = 5
[09:53:09][D][adf_audio_element:165]: Resuming [decoder]...
[09:53:09][D][adf_audio_element:172]: [decoder] Sending resume command.
[09:53:09][V][adf_audio_element:035]: [decoder]evt internal cmd = 5
[09:53:09][I][esp_audio_sources:033][http]: Receive http event: 2
[09:53:09][I][esp_audio_sources:033][http]: Receive http event: 4
[09:53:09][D][adf_audio_element:165]: Resuming [resampler]...
[09:53:09][D][adf_audio_element:172]: [resampler] Sending resume command.
[09:53:09][V][adf_audio_element:035]: [resampler]evt internal cmd = 5
[09:53:09][V][esp-idf:000][resampler]: I (44144) AUDIO_ELEMENT: [resampler] AEL_MSG_CMD_RESUME,state:1
[09:53:09][D][adf_audio_element:165]: Resuming [i2s_out]...
[09:53:09][D][adf_audio_element:172]: [i2s_out] Sending resume command.
[09:53:09][V][adf_audio_element:035]: [i2s_out]evt internal cmd = 5
[09:53:09][I][esp_adf_pipeline:132]: [ resampler ] status: 12
[09:53:09][D][adf_audio_element:191]: [http] Checking State, got 72
[09:53:09][D][adf_audio_element:191]: [decoder] Checking State, got 72
[09:53:09][D][adf_audio_element:191]: [resampler] Checking State, got 74
[09:53:09][I][esp_adf_pipeline:132]: [ i2s_out ] status: 12
[09:53:09][D][adf_audio_element:191]: [i2s_out] Checking State, got 74
[09:53:09][D][esp_adf_pipeline:445]: [MediaPlayer] Pipeline changed from STARTING to RUNNING. (REQ: 0)
[09:53:09][I][adf_media_player:192]: got new pipeline state: 6, while in MP state ANNOUNCING
[09:53:09][I][adf_media_player:255]: current mp state: ANNOUNCING
[09:53:09][I][adf_media_player:256]: anouncement: yes
[09:53:09][I][adf_media_player:257]: play_intent: false
[09:53:09][I][adf_media_player:258]: current_uri_: false
[09:53:11][V][esp-idf:000][http]: I (46450) HTTP_CLIENT: Body received in fetch header state, 0x3fcd183b, 1440
[09:53:11][V][esp-idf:000][http]: I (46455) HTTP_STREAM: total_bytes=35127
[09:53:11][I][HTTPStreamReader:230]: Codec Format reported: 3.
[09:53:12][I][esp_adf_pipeline:132]: [ http ] status: 12
[09:53:12][V][esp-idf:000][http]: W (46530) HTTP_STREAM: No more data,errno:0, total_bytes:35127, rlen = 0
[09:53:12][I][esp_audio_sources:033][http]: Receive http event: 7
[09:53:12][V][esp-idf:000][http]: I (46538) AUDIO_ELEMENT: IN-[http] AEL_IO_DONE,0
[09:53:12][I][esp_adf_pipeline:132]: [ decoder ] status: 12
[09:53:12][I][esp_adf_pipeline:123]: [ http ] byte_pos: 0, total: 35127
[09:53:12][I][esp_adf_pipeline:132]: [ http ] status: 15
[09:53:12][I][esp_adf_pipeline:135]: current state: RUNNING
[09:53:12][D][esp_adf_pipeline:445]: [MediaPlayer] Pipeline changed from RUNNING to FINISHING. (REQ: 0)
[09:53:12][I][adf_media_player:192]: got new pipeline state: 7, while in MP state ANNOUNCING
[09:53:12][I][adf_media_player:255]: current mp state: ANNOUNCING
[09:53:12][I][adf_media_player:256]: anouncement: yes
[09:53:12][I][adf_media_player:257]: play_intent: false
[09:53:12][I][adf_media_player:258]: current_uri_: false
[09:53:12][I][HTTPStreamReader:240]: [ * ] Receive music info from decoder, sample_rates=16000, bits=16, ch=1
[09:53:12][I][HTTPStreamReader:243]: [ * ] Receive music info from decoder, codec_fmt=3, bps=55000, duration=4860, bytes=-1170
[09:53:15][V][esp-idf:000][decoder]: I (50248) AUDIO_ELEMENT: IN-[decoder] AEL_IO_DONE,-2
[09:53:16][V][esp-idf:000][decoder]: I (51205) MP3_DECODER: Closed
[09:53:16][I][esp_adf_pipeline:123]: [ decoder ] byte_pos: 0, total: -1170
[09:53:16][I][esp_adf_pipeline:132]: [ decoder ] status: 15
[09:53:16][I][esp_adf_pipeline:135]: current state: FINISHING
[09:53:16][V][esp-idf:000][resampler]: I (51364) AUDIO_ELEMENT: IN-[resampler] AEL_IO_DONE,-2
[09:53:16][I][esp_adf_pipeline:132]: [ resampler ] status: 15
[09:53:16][I][esp_adf_pipeline:135]: current state: FINISHING
[09:53:16][V][esp-idf:000][i2s_out]: I (51460) AUDIO_ELEMENT: IN-[i2s_out] AEL_IO_DONE,-2
[09:53:17][I][esp_adf_pipeline:123]: [ i2s_out ] byte_pos: 0, total: 0
[09:53:17][I][esp_adf_pipeline:132]: [ i2s_out ] status: 15
[09:53:17][I][esp_adf_pipeline:135]: current state: FINISHING
[09:53:17][D][esp_adf_pipeline:445]: [MediaPlayer] Pipeline changed from FINISHING to STOPPED. (REQ: 1)
[09:53:17][I][adf_media_player:192]: got new pipeline state: 4, while in MP state ANNOUNCING
[09:53:17][I][adf_media_player:255]: current mp state: IDLE
[09:53:17][I][adf_media_player:256]: anouncement: false
[09:53:17][I][adf_media_player:257]: play_intent: false
[09:53:17][I][adf_media_player:258]: current_uri_: false
[09:53:17][D][esp32.preferences:114]: Saving 1 preferences to flash...
[09:53:17][V][esp32.preferences:163]: nvs_get_blob('1398651576'): ESP_ERR_NVS_NOT_FOUND - the key might not be set yet
[09:53:17][V][esp32.preferences:126]: sync: key: 1398651576, len: 7
[09:53:17][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[09:53:19][D][voice_assistant:502]: State changed from STREAMING_RESPONSE to IDLE
[09:53:19][D][voice_assistant:508]: Desired state set to IDLE
[09:57:26][I][ota:117]: Boot seems successful, resetting boot loop counter.
[09:57:26][D][esp32.preferences:114]: Saving 1 preferences to flash...
[09:57:26][V][esp32.preferences:126]: sync: key: 233825507, len: 4
[09:57:26][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
Playing a mp3 log:
[10:00:23][D][media_player:061]: 'Büro Media Assistant Media Player' - Setting
[10:00:23][D][media_player:068]: Media URL: http://homeassistant.local:8123/media/local/danger-143533.mp3?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiM2NkYWE4MWY5ZWM0NmVjYWVhZTljZWRlM2ZmMzljMiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvZGFuZ2VyLTE0MzUzMy5tcDMiLCJwYXJhbXMiOltdLCJpYXQiOjE3MTc5MjcyMjMsImV4cCI6MTcxODAxMzYyM30.lizy8f3yyZRhNe1bCdp4eN13H9ydtz0TaItuGN1pfZA
[10:00:23][D][esp_audio_sources:098]: Set new uri: http://homeassistant.local:8123/media/local/danger-143533.mp3?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiM2NkYWE4MWY5ZWM0NmVjYWVhZTljZWRlM2ZmMzljMiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvZGFuZ2VyLTE0MzUzMy5tcDMiLCJwYXJhbXMiOltdLCJpYXQiOjE3MTc5MjcyMjMsImV4cCI6MTcxODAxMzYyM30.lizy8f3yyZRhNe1bCdp4eN13H9ydtz0TaItuGN1pfZA
[10:00:23][D][adf_media_player:057]: Got control call in state IDLE
[10:00:23][D][adf_media_player:058]: req_track stream uri: http://homeassistant.local:8123/media/local/danger-143533.mp3?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiM2NkYWE4MWY5ZWM0NmVjYWVhZTljZWRlM2ZmMzljMiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvZGFuZ2VyLTE0MzUzMy5tcDMiLCJwYXJhbXMiOltdLCJpYXQiOjE3MTc5MjcyMjMsImV4cCI6MTcxODAxMzYyM30.lizy8f3yyZRhNe1bCdp4eN13H9ydtz0TaItuGN1pfZA
[10:00:23][D][esp_adf_pipeline:060]: Starting request, current state STOPPED
[10:00:23][W][component:237]: Component api took a long time for an operation (101 ms).
[10:00:23][W][component:238]: Components should block for at most 30 ms.
[10:00:23][D][esp_adf_pipeline:445]: [MediaPlayer] Pipeline changed from STOPPED to PREPARING. (REQ: 0)
[10:00:23][I][adf_media_player:192]: got new pipeline state: 3, while in MP state IDLE
[10:00:23][D][adf_i2s_out:127]: Set final i2s settings: 16000
[10:00:23][I][adf_media_player:255]: current mp state: PLAYING
[10:00:23][I][adf_media_player:256]: anouncement: false
[10:00:23][I][adf_media_player:257]: play_intent: false
[10:00:23][I][adf_media_player:258]: current_uri_: yes
[10:00:23][D][esp_audio_sources:103]: Prepare elements called (initial_call)!
[10:00:23][D][esp_audio_sources:137]: Use fixed settings: no
[10:00:23][D][esp_audio_sources:138]: Streamer status: 6
[10:00:23][D][esp_audio_sources:139]: decoder status: 6
[10:00:23][D][esp_audio_sources:140]: stream uri: http://homeassistant.local:8123/media/local/danger-143533.mp3?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiM2NkYWE4MWY5ZWM0NmVjYWVhZTljZWRlM2ZmMzljMiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvZGFuZ2VyLTE0MzUzMy5tcDMiLCJwYXJhbXMiOltdLCJpYXQiOjE3MTc5MjcyMjMsImV4cCI6MTcxODAxMzYyM30.lizy8f3yyZRhNe1bCdp4eN13H9ydtz0TaItuGN1pfZA
[10:00:23][D][adf_audio_element:108]: Preparing [http]...
[10:00:23][D][adf_audio_element:108]: Preparing [decoder]...
[10:00:23][D][adf_audio_element:108]: Preparing [resampler]...
[10:00:23][D][adf_audio_element:108]: Preparing [i2s_out]...
[10:00:23][D][adf_audio_element:165]: Resuming [http]...
[10:00:23][D][adf_audio_element:172]: [http] Sending resume command.
[10:00:23][V][adf_audio_element:035]: [http]evt internal cmd = 5
[10:00:23][D][adf_audio_element:165]: Resuming [decoder]...
ERROR Fatal error: protocol.data_received() call failed.
protocol: <aioesphomeapi._frame_helper.noise.APINoiseFrameHelper object at 0xffff976c3cc0>
transport: <_SelectorSocketTransport fd=6 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
File "/usr/lib/python3.11/asyncio/selector_events.py", line 1009, in _read_ready__data_received
self._protocol.data_received(data)
File "aioesphomeapi/_frame_helper/noise.py", line 136, in aioesphomeapi._frame_helper.noise.APINoiseFrameHelper.data_received
File "aioesphomeapi/_frame_helper/noise.py", line 163, in aioesphomeapi._frame_helper.noise.APINoiseFrameHelper.data_received
File "aioesphomeapi/_frame_helper/noise.py", line 319, in aioesphomeapi._frame_helper.noise.APINoiseFrameHelper._handle_frame
File "/usr/local/lib/python3.11/dist-packages/noise/state.py", line 74, in decrypt_with_ad
plaintext = self.cipher.decrypt(self.k, self.n, ad, ciphertext)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/noise/backends/default/ciphers.py", line 13, in decrypt
return self.cipher.decrypt(nonce=self.format_nonce(n), data=ciphertext, associated_data=ad)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "src/chacha20poly1305_reuseable/__init__.py", line 127, in chacha20poly1305_reuseable.ChaCha20Poly1305Reusable.decrypt
File "src/chacha20poly1305_reuseable/__init__.py", line 147, in chacha20poly1305_reuseable.ChaCha20Poly1305Reusable.decrypt
File "src/chacha20poly1305_reuseable/__init__.py", line 263, in chacha20poly1305_reuseable._decrypt_with_fixed_nonce_len
File "src/chacha20poly1305_reuseable/__init__.py", line 273, in chacha20poly1305_reuseable._decrypt_data
cryptography.exceptions.InvalidTag
WARNING media-assistant-buero @ 192.168.178.142: Connection error occurred: media-assistant-buero @ 192.168.178.142: Invalid encryption key: received_name=media-assistant-buero
INFO Processing unexpected disconnect from ESPHome API for media-assistant-buero @ 192.168.178.142
WARNING Disconnected from API
INFO Successfully connected to media-assistant-buero @ 192.168.178.142 in 8.041s
INFO Successful handshake with media-assistant-buero @ 192.168.178.142 in 0.077s
[10:00:34][D][media_player:061]: 'Büro Media Assistant Media Player' - Setting
[10:00:34][D][media_player:065]: Command: STOP
[10:00:34][D][esp_adf_pipeline:070]: Called 'stop' while in RUNNING state.
[10:00:34][D][esp_adf_pipeline:445]: [MediaPlayer] Pipeline changed from RUNNING to ABORTING. (REQ: 1)
[10:00:34][I][adf_media_player:192]: got new pipeline state: 10, while in MP state PLAYING
[10:00:34][I][adf_media_player:255]: current mp state: PLAYING
[10:00:34][I][adf_media_player:256]: anouncement: false
[10:00:34][I][adf_media_player:257]: play_intent: false
[10:00:34][I][adf_media_player:258]: current_uri_: false
[10:00:34][D][adf_audio_element:324]: [http] Checking State for stopping, got 3
[10:00:34][D][adf_audio_element:324]: [decoder] Checking State for stopping, got 3
[10:00:35][V][esp-idf:000][decoder]: W (489513) AUDIO_ELEMENT: OUT-[decoder] AEL_IO_ABORT
[10:00:35][V][esp-idf:000][decoder]: W (489518) MP3_DECODER: output aborted -3
[10:00:35][V][esp-idf:000][decoder]: I (489522) MP3_DECODER: Closed
[10:00:35][D][adf_audio_element:324]: [resampler] Checking State for stopping, got 3
[10:00:35][V][esp-idf:000][resampler]: W (489534) AUDIO_ELEMENT: OUT-[resampler] AEL_IO_ABORT
[10:00:35][D][adf_audio_element:324]: [i2s_out] Checking State for stopping, got 3
[10:00:35][D][esp_adf_pipeline:445]: [MediaPlayer] Pipeline changed from ABORTING to STOPPED. (REQ: 1)
[10:00:35][I][adf_media_player:192]: got new pipeline state: 4, while in MP state PLAYING
[10:00:35][I][adf_media_player:255]: current mp state: IDLE
[10:00:35][I][adf_media_player:256]: anouncement: false
[10:00:35][I][adf_media_player:257]: play_intent: false
[10:00:35][I][adf_media_player:258]: current_uri_: false
thank you very much!!!!
what kind of hardware are you using? Try my config, no problem with that. There are small problems with fast dictation of commands. The rest works fine
I am using as Hardware Max98357A + INMP441 + esp32s3 n16r8
In duplex mode the channel format for the input and output needs to be the same as well, unfortunately. Can't you use dedicated clock pins for both components, not running in duplex mode saves you from many troubles.
In duplex mode the channel format for the input and output needs to be the same as well, unfortunately. Can't you use dedicated clock pins for both components, not running in duplex mode saves you from many troubles.
if you had time to deal with this problem: sequential dictation of commands with a small pause causes the processing pipeline to freeze. What data can I provide?
In duplex mode the channel format for the input and output needs to be the same as well, unfortunately. Can't you use dedicated clock pins for both components, not running in duplex mode saves you from many troubles.
if you had time to deal with this problem: sequential dictation of commands with a small pause causes the processing pipeline to freeze. What data can I provide?
are you using the dev-next branch?
yes my code is below, I just upgraded to 24.5.5 when I saw the mention of ring buffer hoping it would solve something, but no.
substitutions:
device_name: "test-media-assistant-v2"
friendly_name: "Test Media Assistant V2"
device_description: "Media Assistant V2"
esp_board: "esp32-s3-devkitc-1"
framework_type: "esp-idf"
# Mic
i2s_lrclk_in_pin: GPIO3 # Mic WS
i2s_bclk_in_pin: GPIO2 # Mic CK
i2s_din_pin: GPIO1 # Mic SD/DA
# Speaker
i2s_lrclk_out_pin: GPIO21 # Spk LRC
i2s_bclk_out_pin: GPIO14 # Spk BCLK
i2s_dout_pin: GPIO45 # Spk DIN
# Phases of the Voice Assistant
# IDLE: The voice assistant is ready to be triggered by a wake-word
voice_assist_idle_phase_id: '1'
# LISTENING: The voice assistant is ready to listen to a voice command (after being triggered by the wake word)
voice_assist_listening_phase_id: '2'
# THINKING: The voice assistant is currently processing the command
voice_assist_thinking_phase_id: '3'
# REPLYING: The voice assistant is replying to the command
voice_assist_replying_phase_id: '4'
# NOT_READY: The voice assistant is not ready
voice_assist_not_ready_phase_id: '10'
# ERROR: The voice assistant encountered an error
voice_assist_error_phase_id: '11'
# MUTED: The voice assistant is muted and will not reply to a wake-word
voice_assist_muted_phase_id: '12'
external_components:
- source:
type: git
url: https://github.com/gnumpi/esphome_audio
ref: dev-next
components: [ adf_pipeline, i2s_audio ]
refresh: 0s
#- source:
#type: git
#url: https://github.com/gnumpi/esphome
#ref: adf-mods
#components: [ api, media_player, speaker, voice_assistant ]
esphome:
name: ${device_name}
comment: ${device_description}
friendly_name: ${friendly_name}
min_version: 2024.2.0
platformio_options:
build_flags: -DBOARD_HAS_PSRAM
board_build.flash_mode: dio
#board_upload.maximum_size: 16777216
on_boot:
priority: 600
then:
# Run the script to refresh the LED status
# If after 30 seconds, the device is still initializing (It did not yet connect to Home Assistant), turn off the init_in_progress variable and run the script to refresh the LED status
- delay: 30s
- if:
condition:
lambda: return id(init_in_progress);
then:
- lambda: id(init_in_progress) = false;
esp32:
board: ${esp_board}
variant: ESP32S3
flash_size: 8MB
framework:
type: ${framework_type}
version: recommended
sdkconfig_options:
# need to set a s3 compatible board for the adf-sdk to compile
# board specific code is not used though
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: "y"
CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
CONFIG_ESP32_S3_BOX_BOARD: "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"
logger:
globals:
# Global initialisation variable. Initialized to true and set to false once everything is connected. Only used to have a smooth "plugging" experience
- id: init_in_progress
type: bool
restore_value: no
initial_value: 'true'
# Global variable tracking the phase of the voice assistant (defined above). Initialized to not_ready
- id: voice_assistant_phase
type: int
restore_value: no
initial_value: ${voice_assist_not_ready_phase_id}
psram:
mode: octal
speed: 80MHz
# Enable Home Assistant API
api:
encryption:
key: "MitAC+hwLqT4vWNVudIUXyYcIS89yx/NAadUsGTiBXk="
ota:
password: "f48e29bb666abfe11cffe5904612ce9d"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Optional manual IP
manual_ip:
static_ip: 192.168.1.73
gateway: 192.168.1.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Freenove-Cam01 Fallback Hotspot"
password: "48zf4JyppQ8P"
i2s_audio: # I2s audio pins
- id: i2s_in
i2s_lrclk_pin: $i2s_lrclk_in_pin # Mic WS
i2s_bclk_pin: $i2s_bclk_in_pin # Mic CK
- id: i2s_out
i2s_lrclk_pin: $i2s_lrclk_out_pin # Spk LRC
i2s_bclk_pin: $i2s_bclk_out_pin # Spk BCLK
adf_pipeline: # ADF pieline pins
- platform: i2s_audio
type: audio_out
id: adf_i2s_out
i2s_audio_id: i2s_out
i2s_dout_pin: GPIO45
channel: right_left
sample_rate: 16000
bits_per_sample: 32bit # Spk DIN
- platform: i2s_audio
type: audio_in
id: adf_i2s_in
i2s_audio_id: i2s_in
i2s_din_pin: $i2s_din_pin # Mic SD/DA
channel: left
sample_rate: 16000
bits_per_sample: 32bit
pdm: false
microphone:
- platform: adf_pipeline
id: adf_microphone
gain_log2: 3
keep_pipeline_alive: false
pipeline:
- adf_i2s_in
- self
media_player:
- platform: adf_pipeline
id: adf_media_player
name: media_player
keep_pipeline_alive: false
internal: false
announcement_audio:
sample_rate: 24000
bits_per_sample: 16
num_channels: 1
pipeline:
- self
- resampler
- adf_i2s_out
micro_wake_word:
model: alexa
on_wake_word_detected:
- media_player.stop:
- light.turn_on:
id: led_ring
blue: 0%
red: 0%
green: 100%
brightness: 75%
effect: pulse
- voice_assistant.start:
voice_assistant:
microphone: adf_microphone
media_player: adf_media_player
use_wake_word: false
#vad_threshold: 3
noise_suppression_level: 1.0
#auto_gain: 31dBFS
volume_multiplier: 5.0
on_client_connected:
- lambda: id(init_in_progress) = false;
- if:
condition:
switch.is_on: use_wake_word
then:
- micro_wake_word.start:
- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
- script.execute: reset_led
else:
- lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
on_client_disconnected:
- lambda: id(voice_assistant_phase) = ${voice_assist_not_ready_phase_id};
- voice_assistant.stop
- micro_wake_word.stop
- light.turn_on:
id: led_ring
blue: 0%
red: 100%
green: 100%
brightness: 50%
effect: connecting
on_listening:
- light.turn_on:
id: led_ring
blue: 100%
red: 0%
green: 0%
brightness: 25%
effect: wakeword
on_tts_start:
- light.turn_on:
id: led_ring
blue: 0%
red: 100%
green: 0%
brightness: 100%
effect: pulse
on_end:
then:
- light.turn_off:
id: led_ring
- voice_assistant.stop
- wait_until:
not:
media_player.is_playing:
- script.execute: reset_led
- if:
condition:
switch.is_on: use_wake_word
then:
- micro_wake_word.start:
on_error:
- light.turn_on:
id: led_ring
blue: 0%
red: 100%
green: 0%
brightness: 100%
effect: none
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- lambda: |-
if (code == "wake-provider-missing" || code == "wake-engine-missing") {
id(use_wake_word).turn_off();
}
- if:
condition:
switch.is_on: use_wake_word
then:
- micro_wake_word.start:
- script.execute: reset_led
script:
- id: reset_led
then:
- if:
condition:
switch.is_on: use_wake_word
then:
- light.turn_on:
id: led_ring
blue: 100%
red: 0%
green: 0%
brightness: 25%
effect: none
else:
- light.turn_off: led_ring
button:
- platform: restart
id: restart_btn
name: "${friendly_name} REBOOT"
switch:
- platform: template
name: Enable Voice Assistant
id: use_wake_word
optimistic: true
restore_mode: RESTORE_DEFAULT_ON
icon: mdi:assistant
# When the switch is turned on (on Home Assistant):
# Start the voice assistant component
# Set the correct phase and run the script to refresh the LED status
on_turn_on:
- logger.log: "switch on"
- if:
condition:
lambda: return !id(init_in_progress);
then:
- logger.log: "condition 1"
- lambda: id(voice_assistant_phase) = ${voice_assist_idle_phase_id};
- voice_assistant.stop
- delay: 1s
- if:
condition:
not:
- voice_assistant.is_running
then:
- logger.log: "Starting MWW"
#- voice_assistant.start_continuous
- micro_wake_word.start:
- script.execute: reset_led
on_turn_off:
- if:
condition:
lambda: return !id(init_in_progress);
then:
- voice_assistant.stop
- micro_wake_word.stop
- lambda: id(voice_assistant_phase) = ${voice_assist_muted_phase_id};
- script.execute: reset_led
- platform: template
name: Pipeline
id: pipeline_switch
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
light:
- platform: esp32_rmt_led_strip
id: led_ring
name: "${friendly_name} Light"
pin: GPIO48
num_leds: 1
rmt_channel: 0
rgb_order: GRB
chipset: ws2812
default_transition_length: 0s
effects:
- pulse:
name: "Pulse"
transition_length: 0.5s
update_interval: 0.5s
- addressable_twinkle:
name: "Working"
twinkle_probability: 5%
progress_interval: 4ms
- addressable_color_wipe:
name: "Wakeword"
colors:
- red: 0%
green: 50%
blue: 0%
num_leds: 12
add_led_interval: 20ms
reverse: false
- addressable_color_wipe:
name: "Connecting"
colors:
- red: 60%
green: 60%
blue: 60%
num_leds: 12
- red: 60%
green: 60%
blue: 0%
num_leds: 12
add_led_interval: 100ms
reverse: true
the stopping point is here:
micro_wake_word:
model: alexa
on_wake_word_detected:
- media_player.stop:
- light.turn_on:
id: led_ring
blue: 0%
red: 0%
green: 100%
brightness: 75%
effect: pulse
- voice_assistant.start:
LED blinks green
I apologize, but this is a new error: 24.5.5 , I2S PCM5102A + INMP441 + esp32s3 Сonnect the HW for the first time - say the command - the response will be said in a slow voice, say the new command - the response will be said in a normal voice. The video shows how it happens and also shows how it hangs when the pause is too short
https://github.com/gnumpi/esphome_audio/assets/6624673/1105584a-e337-47cb-afcd-64944f2a5c96
In duplex mode the channel format for the input and output needs to be the same as well, unfortunately. Can't you use dedicated clock pins for both components, not running in duplex mode saves you from many troubles.
ah ok, I understand that i am testing the same code and pins which have indevor.
In duplex mode the channel format for the input and output needs to be the same as well, unfortunately. Can't you use dedicated clock pins for both components, not running in duplex mode saves you from many troubles.
ah ok, I understand that i am testing the same code and pins which have indevor.
So I am tested the another code, thats work better. Thanks.
(I think) after updating to the latest esphome version, I have this slow audio playback problem again.
Relevant config:
external_components:
- source:
type: git
url: https://github.com/gnumpi/esphome_audio
ref: dev-next
components: [ adf_pipeline, i2s_audio ]
refresh: 0s
i2s_audio:
- id: i2s_in
i2s_lrclk_pin: GPIO7
i2s_bclk_pin: GPIO16
- id: i2s_out
i2s_lrclk_pin: GPIO8
i2s_bclk_pin: GPIO18
adf_pipeline:
- platform: i2s_audio
type: audio_out
id: adf_i2s_out
i2s_audio_id: i2s_out
i2s_dout_pin: GPIO17
- platform: i2s_audio
type: audio_in
id: adf_i2s_in
i2s_audio_id: i2s_in
i2s_din_pin: GPIO15
pdm: false
channel: right
sample_rate: 16000
bits_per_sample: 32bit
microphone:
- platform: adf_pipeline
id: adf_microphone
keep_pipeline_alive: true
pipeline:
- adf_i2s_in
- self
media_player:
- platform: adf_pipeline
id: adf_media_player
name: "${friendly_name} Media Player"
keep_pipeline_alive: true
internal: false
pipeline:
- self
- resampler
- adf_i2s_out
I was having the same problem with the slow voice assistant audio. I made the sample rate change to 24000 and tested but was still getting the same result. Out of curiosity I doubled the bits per sample to 32 and the voice assistant is back to normal. I don't use mine to play music or anything so I can't comment on the affects of that.
media_player:
- platform: adf_pipeline
id: adf_media_player
name: s3-dev_media_player
keep_pipeline_alive: false
internal: false
announcement_audio:
sample_rate: 24000
bits_per_sample: 32
num_channels: 1
pipeline:
- self
- adf_i2s_out
- resampler
Hi, yesterday I did play around with those parameters and also tried your suggestion then. When using 24000/32 I get high pitched audio the first time, second time no audio at all.
When using:
announcement_audio:
sample_rate: 24000
bits_per_sample: 16
num_channels: 1
I get low pitched audio the first time, second time and after it is correct. So now it only sounds low-pitched the very fist time after booting.
if you remove the announcement_audio section completely from you media_player config, the right settings should get auto detected. It takes slightly longer though...
When using:
external_components:
- source:
type: git
url: https://github.com/gnumpi/esphome_audio
ref: annoucement_fixed_settings_config
components: [ adf_pipeline, i2s_audio ]
refresh: 0s
It works just fine, so it must be something in the latest dev-next changes.
Removing the:
announcement_audio:
sample_rate: 24000
bits_per_sample: 16
num_channels: 1
Does not help.
thx, thats really helpful information. I will check.
@HA-TB303, can you try setting your bits_per_sample explicitly in the pipeline settings:
adf_pipeline:
- platform: i2s_audio
type: audio_out
id: adf_i2s_out
i2s_audio_id: i2s_out
i2s_dout_pin: GPIO17
bits_per_sample: 16bit
- platform: i2s_audio
type: audio_in
id: adf_i2s_in
i2s_audio_id: i2s_in
i2s_din_pin: GPIO15
pdm: false
channel: right
sample_rate: 16000
bits_per_sample: 32bit
and please share some logs, if it doesn't help
@mstamp20, can you try changing the order of the resampler and i2s-output in your media player config: and set bits_per_sample to 16bit
media_player:
- platform: adf_pipeline
id: adf_media_player
name: s3-dev_media_player
keep_pipeline_alive: false
internal: false
announcement_audio:
sample_rate: 24000
bits_per_sample: 16
num_channels: 1
pipeline:
- self
- resampler
- adf_i2s_out
@HA-TB303, can you try setting your bits_per_sample explicitly in the pipeline settings:
and please share some logs, if it doesn't help
It now sounds fine from the first time.
Config:
i2s_audio:
- id: i2s_in
i2s_lrclk_pin: GPIO7
i2s_bclk_pin: GPIO16
- id: i2s_out
i2s_lrclk_pin: GPIO8
i2s_bclk_pin: GPIO18
adf_pipeline:
- platform: i2s_audio
type: audio_out
id: adf_i2s_out
i2s_audio_id: i2s_out
i2s_dout_pin: GPIO17
bits_per_sample: 16bit
- platform: i2s_audio
type: audio_in
id: adf_i2s_in
i2s_audio_id: i2s_in
i2s_din_pin: GPIO15
pdm: false
channel: right
sample_rate: 16000
bits_per_sample: 32bit
microphone:
- platform: adf_pipeline
id: adf_microphone
keep_pipeline_alive: true
pipeline:
- adf_i2s_in
- self
media_player:
- platform: adf_pipeline
id: adf_media_player
name: "${friendly_name} Media Player"
keep_pipeline_alive: true
internal: false
pipeline:
- self
- resampler
- adf_i2s_out
@mstamp20, can you try changing the order of the resampler and i2s-output in your media player config: and set bits_per_sample to 16bit
media_player: - platform: adf_pipeline id: adf_media_player name: s3-dev_media_player keep_pipeline_alive: false internal: false announcement_audio: sample_rate: 24000 bits_per_sample: 16 num_channels: 1 pipeline: - self - resampler - adf_i2s_out
I tried this and it went back to slow motion for the first response and then worked fine the rest of the time.
I did a few different tests as well. I went through all the variations without resampler and all with resampler. Here are the results I had:
announcement_audio:
sample_rate: 16000
bits_per_sample: 16
num_channels: 1
pipeline:
- self
- adf_i2s_out
The above audio came back slow motion.
announcement_audio:
sample_rate: 24000
bits_per_sample: 16
num_channels: 1
pipeline:
- self
- adf_i2s_out
The above was a little faster but still slow motion.
announcement_audio:
sample_rate: 16000
bits_per_sample: 32
num_channels: 1
pipeline:
- self
- adf_i2s_out
The above was slightly better than the previous, still low and slow.
announcement_audio:
sample_rate: 24000
bits_per_sample: 32
num_channels: 1
pipeline:
- self
- adf_i2s_out
The above played perfectly normal the entire time!
media_player:
- platform: adf_pipeline
id: adf_media_player
name: s3-dev_media_player
keep_pipeline_alive: false
internal: false
pipeline:
- self
- resampler
- adf_i2s_out
Removing announcement audio and adding resampler played slow on the first response and normal the rest of the time.
announcement_audio:
sample_rate: 16000
bits_per_sample: 16
num_channels: 1
pipeline:
- self
- resampler
- adf_i2s_out
This was extremely slow the first response and slow the rest of the time.
announcement_audio:
sample_rate: 24000
bits_per_sample: 16
num_channels: 1
pipeline:
- self
- resampler
- adf_i2s_out
This was slow on the first response and normal the rest of the time.
announcement_audio:
sample_rate: 16000
bits_per_sample: 32
num_channels: 1
pipeline:
- self
- resampler
- adf_i2s_out
This was fast the first response and then slow the rest of the time.
announcement_audio:
sample_rate: 24000
bits_per_sample: 32
num_channels: 1
pipeline:
- self
- resampler
- adf_i2s_out
This was extremely fast the first response and then normal the rest of the time.
I hope this helps!
thx, first of all I need to find out why it behaves differently the first time compared to the other times, this should definitely not be the case. thx for pointing at this.
Hi I'm using your latest code: HW: Max98357 + INMP441 + esp32s3 esphome: 24.5.0
my script, maybe I'm missing something:
1) The response from the voice assistant is spoken in a slow voice. There is also a wait after you say a voice command. I have noticed that the louder the command is spoken, the less the pause. On average there is a pause of 10-12 seconds after the command is said. Method of phrase ending: aggressive. 2) If you play this file WAV 44100, 706 kbps, 16bit, mono
log
3) Also RadioBrowser does not work.
log