Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named 'audioop' in Python 3.13 (Fedora 41) [SOLVED, PATCH] #61

Open
themanyone opened this issue Nov 26, 2024 · 0 comments · May be fixed by #62
Open

No module named 'audioop' in Python 3.13 (Fedora 41) [SOLVED, PATCH] #61

themanyone opened this issue Nov 26, 2024 · 0 comments · May be fixed by #62
Labels
bug Something isn't working

Comments

@themanyone
Copy link

themanyone commented Nov 26, 2024

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,
@themanyone themanyone added the bug Something isn't working label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant