From 340ee617ede6c836b8e797d53c4b09cd0c17dc04 Mon Sep 17 00:00:00 2001 From: themanyone Date: Tue, 26 Nov 2024 02:18:12 -0900 Subject: [PATCH] Replace audioop with numpy for Python 3.13 --- mimic3_tts/tts.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mimic3_tts/tts.py b/mimic3_tts/tts.py index 49d77ee..07750f6 100644 --- a/mimic3_tts/tts.py +++ b/mimic3_tts/tts.py @@ -14,7 +14,7 @@ # along with this program. If not, see . # """Implementation of OpenTTS for Mimic 3""" -import audioop +import numpy import itertools import logging import re @@ -540,7 +540,9 @@ def _speak_sentence_phonemes( audio_bytes = audio.tobytes() if settings.volume != DEFAULT_VOLUME: - audio_bytes = audioop.mul(audio_bytes, 2, settings.volume / 100.0) + audio_bytes = np.frombuffer(audio_bytes, dtype=np.int16) + audio_bytes = audio_bytes * (settings.volume / 100.0) + audio_bytes = audio_bytes.clip(-32768, 32767).astype(np.int16).tobytes() return AudioResult( sample_rate_hz=voice.config.audio.sample_rate,