You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: components/media_player/speaker.rst
+32-14Lines changed: 32 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Speaker Audio Media Player
7
7
8
8
The ``speaker`` media player platform allows you to play on-device and online audio media via :doc:`speaker components </components/speaker/index>`.
9
9
10
-
This platform greatly benefits from having external PSRAM. See the :ref:`performance section <speaker_media_player-performance>` for details.
10
+
This platform greatly benefits from having external PSRAM. See the :ref:`performance section <media_player-speaker-performance>` for details.
11
11
12
12
It natively supports decoding ``FLAC``, ``MP3``, and ``WAV`` audio files. Home Assistant (since version 2024.10) can proxy any media it sends and transcode it to a specified format and sample rate to minimize the device's computational load.
13
13
@@ -58,23 +58,12 @@ Configuration variables:
58
58
- **on_volume** (*Optional*, :ref:`Automation <automation>`): An automation to perform when the volume is changed.
59
59
- All other options from :ref:`Media Player <config-media_player>`
60
60
61
-
.. _speaker_media_player-performance:
62
-
63
-
Performance
64
-
-----------
65
-
66
-
Decoding audio files is CPU and memory intensive. PSRAM external memory is strongly recommended. To use the component on a memory constrained device, define only the announcement pipeline, decrease the buffer size, set ``codec_support_enabled`` to false, and set the pipeline transcode setting format to ``WAV`` with a low sample rate and only 1 channel.
67
-
68
-
In general, decoding FLAC has the lowest CPU usage, but requires a strong WiFi connection. Decoding MP3 requires less data to be sent over WiFi but is more CPU intensive to decode. Decoding WAV is only recommended at low sample rates if streamed over a network connection.
69
-
70
-
Increasing the buffer size may reduce stuttering, but do not set it to the entire size of the external memory. Each pipeline allocates the configured amount, and this setting also does not take into account other smaller buffers allocated throughout the audio stack.
71
-
72
-
.. _speaker_media_player-examples:
61
+
.. _media_player-speaker-examples:
73
62
74
63
Example Configuration
75
64
---------------------
76
65
77
-
This example outputs audio to an :doc:`I²S Audio Speaker </components/speaker/i2s_audio>` configured with a 48000 Hz sample rate. It uses a ``mixer`` speaker component to handle combining the two differnet pipelines, and it uses ``resampler`` speaker components to ensure the source speakers uses the same sample rate.
66
+
This example outputs audio to an :doc:`I²S Audio Speaker </components/speaker/i2s_audio>` configured with a 48000 Hz sample rate. It uses a ``mixer`` speaker component to handle combining the two different pipelines, and it uses ``resampler`` speaker components to ensure the source speakers uses the same sample rate.
78
67
79
68
It adds a switch for playing an on-device file for an alarm notification. Any playing media is ducked while the alarm is activated. After the alarm is turned off, the media ducking will gradually stop.
80
69
@@ -83,6 +72,7 @@ It adds a switch for playing an on-device file for an alarm notification. Any pl
83
72
i2s_audio:
84
73
i2s_lrclk_pin: GPIOXX
85
74
i2s_bclk_pin: GPIOXX
75
+
sample_rate: 48000
86
76
speaker:
87
77
- platform: i2s_audio
88
78
id: speaker_id
@@ -176,11 +166,39 @@ Configuration variables:
176
166
177
167
- **media_file** (**Required**, :ref:`config-id`): The ID of the media file.
178
168
- **announcement** (*Optional*, boolean): Whether to play back the file as an announcement or media stream. Defaults to ``false``.
169
+
- **enqueue** (*Optional*, boolean): Whether to add the media file to the end of the pipeline's internal playlist. Defaults to ``false``.
170
+
171
+
.. _media_player-speaker-performance:
172
+
173
+
Performance
174
+
-----------
175
+
176
+
Decoding audio files is CPU and memory intensive. PSRAM external memory is strongly recommended. To use the component on a memory constrained device, define only the announcement pipeline, decrease the buffer size, set ``codec_support_enabled`` to false, and set the pipeline transcode setting format to ``WAV`` with a low sample rate and only 1 channel.
177
+
178
+
In general, decoding FLAC has the lowest CPU usage, but requires a strong WiFi connection. Decoding MP3 requires less data to be sent over WiFi but is more CPU intensive to decode. Decoding WAV is only recommended at low sample rates if streamed over a network connection.
179
+
180
+
Increasing the buffer size may reduce stuttering, but do not set it to the entire size of the external memory. Each pipeline allocates the configured amount, and this setting also does not take into account other smaller buffers allocated throughout the audio stack.
181
+
182
+
Only set ``task_stack_in_psram`` to true if you have many components configured and your logs show that memory allocation failed. It is slower, especially if your PSRAM doesn't support ``octal`` mode.
183
+
184
+
.. _media_player-speaker-troubleshooting:
185
+
186
+
Troubleshooting
187
+
---------------
188
+
189
+
While you are troubleshooting, simplify your setup as much as possible . Only configure the ``announcement_pipeline`` and do not use ``resampler`` or ``mixer`` speakers.
190
+
191
+
If you can't hear anything, check whether your hardware requires a GPIO pin to be high or low to enable the speaker. Verify you have the correct speaker channel configured: try setting your speaker configuration to stereo if you are unsure which channels are available.
192
+
193
+
If the audio quality is poor, check your output speaker configuration. Experiment with the bits per sample, channels, and sample rate settings. In general, higher sample rates improve audio quality: try using ``44100`` Hz or ``48000`` Hz instead of ``16000`` Hz.
179
194
195
+
If there is a noticeable delay before a pause command takes effect, reduce the buffer duration in the output speaker. Be sure to adjust both the hardware speaker component settings and the ``mixer`` speaker component settings, if used.
0 commit comments