-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guide on creating and including sound clips to be played by the i2s S…
…peaker component. (#3718) * Add files via upload * Add files via upload * Update audio_clips_for_i2s.rst * Update audio_clips_for_i2s.rst * Update audio_clips_for_i2s.rst * Update index.rst missing link to the speaker component (this page is well hidden!) and added the link to the guide. * Update audio_clips_for_i2s.rst Dots on i * Update audio_clips_for_i2s.rst updated links * Update audio_clips_for_i2s.rst xxd link for anything else but Linux... * Update index.rst links in this format are strange. * Update audio_clips_for_i2s.rst And again... links are weird. * Update audio_clips_for_i2s.rst --------- Co-authored-by: H. Árkosi Róbert <robreg@zsurob.hu>
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
.. audio_clips_for_i2s: | ||
Create audio clip files for use with I²S Speakers | ||
================================================= | ||
|
||
It is possible to create sound clips to include in your build to use with I²S speakers. No need for a media player component! | ||
|
||
- Using `Audacity <https://github.com/audacity/audacity>`__, convert audio to WAV, mono, 16kHz, Unsigned 8bit PCM | ||
|
||
.. figure:: /guides/images/save_as_wav.png | ||
:alt: Audacity export dialog | ||
:height: 200 | ||
:align: center | ||
|
||
- Convert again, this time with `SOX <https://github.com/chirlu/sox>`__. | ||
|
||
.. code-block:: console | ||
sox startup.wav --bits 8 --encoding signed-integer --endian little startup_again.raw | ||
- Now convert it into a hexadecimal string using `xxd <https://github.com/ckormanyos/xxd>`__ into a C++ file. | ||
|
||
.. code-block:: console | ||
xxd -i startup_again.raw startup.c | ||
- The resulting file needs a modification in the start line: | ||
Open in an editor and change | ||
``unsigned char startup_again_raw[] = {…[SNIP]…}`` | ||
to | ||
``std::vector<unsigned char> startup_raw = {…[SNIP]…}``. | ||
|
||
Now you can rename the file to startup.h, put it inside the esphome configuration directory and put it in a include in your device config like this: | ||
|
||
.. code-block:: yaml | ||
esphome: | ||
includes: | ||
- startup.h | ||
Now you can define using the audio clip using the following: | ||
|
||
.. code-block:: yaml | ||
- speaker.play: | ||
id: speaker | ||
data: !lambda return startup_raw; | ||
Enjoy! | ||
|
||
HowTo by [NUT]. | ||
|
||
See also | ||
-------- | ||
|
||
- :doc:`/components/speaker/index` | ||
- :doc:`/components/speaker/i2s_audio` | ||
- :ghedit:`Edit` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.