diff --git a/homeassistant/components/tts/__init__.py b/homeassistant/components/tts/__init__.py index 1262e8132131..fc5fe4ffe23c 100644 --- a/homeassistant/components/tts/__init__.py +++ b/homeassistant/components/tts/__init__.py @@ -355,6 +355,9 @@ async def _async_convert_audio( if to_sample_bytes == 2: # 16-bit samples. command.extend(["-sample_fmt", "s16"]) + # Do not write the muxer's own encoder metadata; metadata from the input + # is still copied. + command.extend(["-fflags", "+bitexact"]) command.append("pipe:1") # Send output to stdout. process = await asyncio.create_subprocess_exec( diff --git a/tests/components/tts/test_init.py b/tests/components/tts/test_init.py index c03cc2b380ab..3382c63f69b0 100644 --- a/tests/components/tts/test_init.py +++ b/tests/components/tts/test_init.py @@ -1920,6 +1920,8 @@ async def test_async_convert_audio_probe_size( "1", "-sample_fmt", "s16", + "-fflags", + "+bitexact", "pipe:1", ] @@ -1968,6 +1970,8 @@ async def test_async_convert_audio_mp3_bitrate( "-ac", "1", *expected_encoder_args, + "-fflags", + "+bitexact", "pipe:1", ]