Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read mp3 file from the SD card #7

Open
nbucic opened this issue Dec 27, 2024 · 4 comments
Open

Read mp3 file from the SD card #7

nbucic opened this issue Dec 27, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@nbucic
Copy link

nbucic commented Dec 27, 2024

Hi @n-serrette ,

Can I create esphome media_player that would pool files locally from the SD card, using your library for reading sd card files?

@n-serrette n-serrette added the enhancement New feature or request label Dec 27, 2024
@n-serrette
Copy link
Owner

Hi,

Thanks for your interest, at the moment it is not possible, the component does not support reading from the sd card yet.
I am working on the reading aspect, but progress is slow because I have limited time at the moment.

You have a great use case, I take it into account while developing the reading and try to implement it.

I have never use the audio aspect of esphome, could you tell me what hardware you plan to utilize?

@nbucic
Copy link
Author

nbucic commented Dec 28, 2024

Hi @n-serrette,

Thank you for showing the interest in my use-case.

I'm currently using ESP32 and ESP32-S3 (with PSRAM), together with MAX98357 DAC.
I have stored some mp3 files on my server and the stream from the internet is working without any issue.

In the long run, I would like to have stored these files on the SD card.

Before switching to the ESPHOME scripting, I wrote Arudino code that worked following this tutorial: https://dronebotworkshop.com/esp32-i2s/

I very unfamiliar with the C/C++ code (know to read and understand it, hard to write anything new), so I can't help you on your quest. But this is a very good and promising library.

@n-serrette
Copy link
Owner

Hi,

Thanks for the detail, I will try to procure some hardware to develop this but I cannot make promise en the timing.

In the mean time I have added a simple read_file function.

std::vector<uint8_t> read_file(char const *path);
std::vector<uint8_t> read_file(std::string const &path);

Return the whole file as a vector, trying to read large file will saturate the esp memory

  • path: file path

You can try playing a file with the Speaker Component

- speaker.play:
      id: my_speaker
      data: return id(esp_camera_sd_card)->read_file("/file");

@nbucic
Copy link
Author

nbucic commented Jan 2, 2025

Hey, thank you very much for the addition. Will try to find some time to setup sdcard together with esp32-s3 and will let you know the outcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants