ESP32-audioI2S icon indicating copy to clipboard operation
ESP32-audioI2S copied to clipboard

add audio_webfile_start/audio_webfile_data_received/audio_stopped callbacks

Open freddy36 opened this issue 1 year ago • 10 comments

Adds the following callbacks:

void audio_stopped(const uint32_t pos) // called after audio has stopped
void audio_webfile_data_received(const uint8_t *writePtr, const int16_t bytesWritten) // called after data has been received from a web file stream
void audio_webfile_start(const bool isTTS, const char *lastHost) // the webfile stream starts

And adds the existing audio_eof_stream callback to the readme

freddy36 avatar Jan 29 '24 15:01 freddy36

What can you use it for?

schreibfaul1 avatar Jan 29 '24 20:01 schreibfaul1

I'm using it to stream webfiles and save them to SD while playing.

freddy36 avatar Jan 30 '24 03:01 freddy36

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Mar 16 '24 01:03 github-actions[bot]

I've rebased the PR. Do you have any alternative suggestion for the use case?

freddy36 avatar Mar 25 '24 16:03 freddy36

Might be useful to cache TTS. For example I use TTS to get notified about Home Assistant TTS events.

Imagine you have TTS notifications like "Hey, a movement has been detected in basement". Instead of asking for TTS sentence, it can be cached using md5 of the sentence adding the language as salt.

Seems like a good feature candidate anyway.

cziter15 avatar Apr 11 '24 10:04 cziter15

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar May 27 '24 02:05 github-actions[bot]

@schreibfaul1 any comment on this? If you plan to merge it, I'll rebase it on master again.

freddy36 avatar Jun 02 '24 12:06 freddy36

you can query isRunning()

schreibfaul1 avatar Jun 04 '24 20:06 schreibfaul1

you can query isRunning()

That doesn't give me access to the input buffer and we would have to use busy waiting (inefficient) to get something similar to the webfile_start/stopped callback.

Are your concerns only with the webfile_start and stopped callback?

freddy36 avatar Jun 05 '24 02:06 freddy36

It would be really useful to have events when audio connection has been started or stopped so that one could enable/disable leds based on these events for example.

lamikr avatar Jun 14 '24 07:06 lamikr