-
Notifications
You must be signed in to change notification settings - Fork 128
Description
Describe the bug
The audioop module is not compatible with Python 3.13. The audioop module was built-in module in earlier versions of Python.
To Reproduce
mimic3 "hello"
Expected behavior
"Hello"
Log files
$ mimic3
Traceback (most recent call last):
File "/home/k/.local/bin/mimic3", line 5, in
from mimic3_tts.main import main
File "/home/k/.local/lib/python3.13/site-packages/mimic3_tts/init.py", line 17, in
from .tts import Mimic3Settings, Mimic3TextToSpeechSystem
File "/home/k/.local/lib/python3.13/site-packages/mimic3_tts/tts.py", line 17, in
import audioop
ModuleNotFoundError: No module named 'audioop'
Environment (please complete the following information):
CPU: quad core Intel Core i7-2860QM (-MT MCP-) speed/min/max: 798/800/3600 MHz
Kernel: 6.11.8-300.fc41.x86_64 x86_64 Up: 1d 21h 9m
Mem: 8.81/31.28 GiB (28.2%) Storage: 1.92 TiB (27.1% used) Procs: 387
Shell: Bash inxi: 3.3.36
Additional context
The audioop module is being used to multiply the audio bytes by a volume factor. This is a simple operation that can be done using the numpy library, which is a more common and widely-used library for numerical computations.
We can make it work using the following patch.
--- mimic3_tts/tts.py.orig 2024-11-26 01:50:44.850440516 -0900
+++ mimic3_tts/tts.py 2024-11-26 01:52:21.522285877 -0900
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""Implementation of OpenTTS for Mimic 3"""
-import audioop
+import numpy
import itertools
import logging
import re
@@ -540,7 +540,9 @@
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,