From 294c94983d74ca0abb229efa9ada73957d6b409d Mon Sep 17 00:00:00 2001 From: Schevv Date: Wed, 31 Jul 2024 16:48:19 +0200 Subject: [PATCH] Fix for conversion of 8-bit audio --- wyoming/audio.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wyoming/audio.py b/wyoming/audio.py index 69c08a7..694fba8 100644 --- a/wyoming/audio.py +++ b/wyoming/audio.py @@ -163,7 +163,11 @@ def convert(self, chunk: AudioChunk) -> AudioChunk: if (self.width is not None) and (chunk.width != self.width): # Convert sample width + if chunk.width == 1: + audio_bytes = audioop.bias(audio_bytes, 1, -128) audio_bytes = audioop.lin2lin(audio_bytes, chunk.width, self.width) + if self.width == 1: + audio_bytes = audioop.bias(audio_bytes, 1, 128) width = self.width channels = chunk.channels