gnumpi / esphome_audio

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

Grabbing audio source via HTTPS request #54

Open VivantSenior opened 4 months ago

VivantSenior commented 4 months ago

Hello,

I'm using @tetele's MicroWakeWord.yaml but encountered an error (I think) related to https requests (#45). My HA instance is behind CloudFlare therefor I'm connecting to my HA via public domain (TLS) even locally. My issue is with playing response / media via the speaker.

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

I noticed that you already set CONFIG_ESP_TLS_INSECURE and CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY to true so this is probably not the answer.

This is a log then trying to play media from HA:

[12:22:40][VV][api.service:893]: on_media_player_command_request: MediaPlayerCommandRequest {
  key: 1703473339
  has_command: NO
  command: MEDIA_PLAYER_COMMAND_PLAY
  has_volume: NO
  volume: 0
  has_media_url: YES
  media_url: 'https://example.com/media/local/File.mp3?authSig=xxx
[12:22:40][D][media_player:061]: 'Office Voice Assistant' - Setting
[12:22:40][D][media_player:068]:   Media URL: https://example.com/media/local/File.mp3?authSig=xxx
[12:22:40][D][esp_audio_sources:098]: Set new uri: https://example.com/media/local/File.mp3?authSig=xxx
[12:22:40][D][adf_media_player:057]: Got control call in state IDLE
[12:22:40][D][adf_media_player:058]: req_track stream uri: https://example.com/media/local/File.mp3?authSig=xxx
[12:22:40][D][esp_adf_pipeline:060]: Starting request, current state UNINITIALIZED
[12:22:40][D][esp_adf_pipeline:448]: [MediaPlayer] Pipeline changed from UNINITIALIZED to INITIALIZING. (REQ: 0)
[12:22:40][I][adf_media_player:192]: got new pipeline state: 1, while in MP state IDLE
[12:22:40][I][adf_media_player:256]: current mp state: IDLE
[12:22:40][I][adf_media_player:257]: anouncement: false
[12:22:40][I][adf_media_player:258]: play_intent: false
[12:22:40][I][adf_media_player:259]: current_uri_: yes
[12:22:40][VV][esp-idf:000]: I (156407) MP3_DECODER: MP3 init

[12:22:40][D][i2s_audio:067]: Install driver requested by Writer
[12:22:40][VV][esp-idf:000]: I (156414) I2S: DMA Malloc info, datalen=blocksize=1024, dma_buf_count=4

[12:22:40][VV][esp-idf:000]: I (156417) I2S: DMA Malloc info, datalen=blocksize=1024, dma_buf_count=4

[12:22:40][D][i2s_audio:073]: Installing driver : yes
[12:22:40][D][esp_adf_pipeline:497]: pipeline tag 0, http
[12:22:40][D][esp_adf_pipeline:497]: pipeline tag 1, decoder
[12:22:40][D][esp_adf_pipeline:497]: pipeline tag 2, resampler
[12:22:40][D][esp_adf_pipeline:497]: pipeline tag 3, i2s_out
[12:22:40][VV][esp-idf:000]: I (156442) AUDIO_PIPELINE: link el->rb, el:0x3d817a5c, tag:http, rb:0x3d818270

[12:22:40][VV][esp-idf:000]: I (156445) AUDIO_PIPELINE: link el->rb, el:0x3d817d50, tag:decoder, rb:0x3d8582b0

[12:22:40][VV][esp-idf:000]: I (156448) AUDIO_PIPELINE: link el->rb, el:0x3d817eec, tag:resampler, rb:0x3d8592f0

[12:22:40][D][esp_adf_pipeline:507]: Setting up event listener.
[12:22:40][D][esp_adf_pipeline:448]: [MediaPlayer] Pipeline changed from INITIALIZING to CREATED. (REQ: 0)
[12:22:40][I][adf_media_player:192]: got new pipeline state: 2, while in MP state IDLE
[12:22:40][I][adf_media_player:256]: current mp state: IDLE
[12:22:40][I][adf_media_player:257]: anouncement: false
[12:22:40][I][adf_media_player:258]: play_intent: false
[12:22:40][I][adf_media_player:259]: current_uri_: yes
[12:22:40][W][component:237]: Component adf_pipeline.media_player took a long time for an operation (64 ms).
[12:22:40][W][component:238]: Components should block for at most 30 ms.
[12:22:40][D][esp_adf_pipeline:448]: [MediaPlayer] Pipeline changed from CREATED to PREPARING. (REQ: 0)
[12:22:40][I][adf_media_player:192]: got new pipeline state: 3, while in MP state IDLE
[12:22:40][D][adf_i2s_out:141]: Set final i2s settings: 16000
[12:22:40][D][esp_audio_processors:124]: Current settings: SRC: rate: 16000, ch: 2 bits: 16, DST: rate: 16000, ch: 2, bits 16
[12:22:40][VV][api.service:324]: send_media_player_state_response: MediaPlayerStateResponse {
  key: 1703473339
  state: MEDIA_PLAYER_STATE_PLAYING
  volume: 1
  muted: NO
}
[12:22:40][I][adf_media_player:256]: current mp state: PLAYING
[12:22:40][I][adf_media_player:257]: anouncement: false
[12:22:40][I][adf_media_player:258]: play_intent: false
[12:22:40][I][adf_media_player:259]: current_uri_: yes
[12:22:40][D][esp_audio_sources:103]: Prepare elements called (initial_call)!
[12:22:40][D][esp_audio_sources:137]: Use fixed settings: no
[12:22:40][D][esp_audio_sources:138]: Streamer status: 1
[12:22:40][D][esp_audio_sources:139]: decoder status: 1
[12:22:40][D][esp_audio_sources:140]: stream uri: https://example.com/media/local/File.mp3?authSig=xxx
[12:22:40][D][adf_audio_element:108]: Preparing [http]...
[12:22:40][VV][esp-idf:000]: I (156522) AUDIO_THREAD: The http task allocate stack on external memory

[12:22:40][VV][esp-idf:000]: I (156525) AUDIO_ELEMENT: [http-0x3d817a5c] Element task created

[12:22:40][D][adf_audio_element:108]: Preparing [decoder]...
[12:22:40][VV][esp-idf:000]: I (156531) AUDIO_THREAD: The decoder task allocate stack on external memory

[12:22:40][VV][esp-idf:000]: I (156534) AUDIO_ELEMENT: [decoder-0x3d817d50] Element task created

[12:22:40][D][adf_audio_element:108]: Preparing [resampler]...
[12:22:40][VV][esp-idf:000]: I (156541) AUDIO_THREAD: The resampler task allocate stack on external memory

[12:22:40][VV][esp-idf:000]: I (156544) AUDIO_ELEMENT: [resampler-0x3d817eec] Element task created

[12:22:40][D][adf_audio_element:108]: Preparing [i2s_out]...
[12:22:40][VV][esp-idf:000]: I (156556) AUDIO_ELEMENT: [i2s_out-0x3d8180a8] Element task created

[12:22:40][D][adf_audio_element:165]: Resuming [http]...
[12:22:40][D][adf_audio_element:172]: [http] Sending resume command.
[12:22:40][V][adf_audio_element:035]: [http]evt internal cmd = 5
[12:22:40][D][adf_audio_element:165]: Resuming [decoder]...
[12:22:40][D][adf_audio_element:172]: [decoder] Sending resume command.
[12:22:40][V][adf_audio_element:035]: [decoder]evt internal cmd = 5
[12:22:40][VV][esp-idf:000][decoder]: I (156607) AUDIO_ELEMENT: [decoder] AEL_MSG_CMD_RESUME,state:1

[12:22:40][VV][esp-idf:000][decoder]: I (156611) MP3_DECODER: MP3 opened

[12:22:40][VV][esp-idf:000][decoder]: W (156615) AUDIO_ELEMENT: IN-[decoder] AEL_IO_ABORT

[12:22:40][VV][esp-idf:000][decoder]: E (156618) MP3_DECODER: failed to read audio data (line 117)

[12:22:40][VV][esp-idf:000][decoder]: W (156621) AUDIO_ELEMENT: [decoder] AEL_IO_ABORT, -3

[12:22:40][VV][esp-idf:000][decoder]: I (156625) MP3_DECODER: Closed

[12:22:40][D][adf_audio_element:324]: [http] Checking State for stopping, got 7
[12:22:40][VV][esp-idf:000]: E (156644) AUDIO_ELEMENT: [http] Element already stopped

[12:22:40][E][esp_adf_pipeline:223]: HTTPStreamReader got in error state while STOPPING. Stopping pipeline!
[12:22:40][D][esp_adf_pipeline:448]: [MediaPlayer] Pipeline changed from ABORTING to DESTROYING. (REQ: 4)
[12:22:40][I][adf_media_player:192]: got new pipeline state: 11, while in MP state PLAYING
[12:22:40][I][adf_media_player:256]: current mp state: PLAYING
[12:22:40][I][adf_media_player:257]: anouncement: false
[12:22:40][I][adf_media_player:258]: play_intent: false
[12:22:40][I][adf_media_player:259]: current_uri_: yes
[12:22:40][E][esp_adf_pipeline:246]: Timeout while STOPPING. Stopping pipeline!
[12:22:40][D][esp_adf_pipeline:448]: [MediaPlayer] Pipeline changed from DESTROYING to DESTROYING. (REQ: 4)
[12:22:40][I][adf_media_player:192]: got new pipeline state: 11, while in MP state PLAYING
[12:22:40][I][adf_media_player:256]: current mp state: PLAYING
[12:22:40][I][adf_media_player:257]: anouncement: false
[12:22:40][I][adf_media_player:258]: play_intent: false
[12:22:40][I][adf_media_player:259]: current_uri_: yes
[12:22:40][D][esp_adf_pipeline:518]: Called deinit_all
[12:22:40][VV][esp-idf:000]: I (156687) AUDIO_PIPELINE: audio_pipeline_unlinked

[12:22:40][VV][esp-idf:000]: W (156689) AUDIO_ELEMENT: [http] Element has not create when AUDIO_ELEMENT_TERMINATE

[12:22:40][VV][esp-idf:000]: W (156692) AUDIO_ELEMENT: [decoder] Element has not create when AUDIO_ELEMENT_TERMINATE

[12:22:40][VV][esp-idf:000]: W (156695) AUDIO_ELEMENT: [resampler] Element has not create when AUDIO_ELEMENT_TERMINATE

[12:22:40][VV][esp-idf:000]: W (156698) AUDIO_ELEMENT: [i2s_out] Element has not create when AUDIO_ELEMENT_TERMINATE

[12:22:40][VV][esp-idf:000]: I (156702) I2S: DMA queue destroyed

[12:22:40][VV][esp-idf:000]: I (156705) I2S: DMA queue destroyed

[12:22:40][D][esp_adf_pipeline:448]: [MediaPlayer] Pipeline changed from DESTROYING to UNINITIALIZED. (REQ: 4)
[12:22:40][I][adf_media_player:192]: got new pipeline state: 0, while in MP state PLAYING
[12:22:40][VV][api.service:324]: send_media_player_state_response: MediaPlayerStateResponse {
  key: 1703473339
  state: MEDIA_PLAYER_STATE_IDLE
  volume: 1
  muted: NO
}
[12:22:40][I][adf_media_player:256]: current mp state: IDLE
[12:22:40][I][adf_media_player:257]: anouncement: false
[12:22:40][I][adf_media_player:258]: play_intent: false
[12:22:40][I][adf_media_player:259]: current_uri_: yes

Could you please help me with this issue?