When I use mutagen I get the following error:
Traceback (most recent call last):
File "C:UserswiznePycharmProjects3.9RedditCoquiTest.py", line 16, in <module>
audio = MP3(filename)
File "C:UserswiznePycharmProjects3.9Reddit.venvlibsite-packagesmutagen_file.py", line 48, in __init__
self.load(*args, **kwargs)
File "C:UserswiznePycharmProjects3.9Reddit.venvlibsite-packagesmutagen_util.py", line 123, in wrapper
return func(self, h, *args, **kwargs)
File "C:UserswiznePycharmProjects3.9Reddit.venvlibsite-packagesmutagenid3_file.py", line 406, in load
self.info = self._Info(fileobj, offset)
File "C:UserswiznePycharmProjects3.9Reddit.venvlibsite-packagesmutagen_util.py", line 152, in wrapper
return func(*args, **kwargs)
File "C:UserswiznePycharmProjects3.9Reddit.venvlibsite-packagesmutagenmp3__init__.py", line 387, in __init__
raise HeaderNotFoundError("can't sync to MPEG frame")
mutagen.mp3.HeaderNotFoundError: can't sync to MPEG frame
This is what my code looks like:
import os
from mutagen.mp3 import MP3
from TTS.api import TTS
sentences = ["Nurgle","Khorne","Slaanesh","Tzeetch"]
for i, sentence in enumerate(sentences):
model_name = "tts_models/en/ljspeech/tacotron2-DDC_ph"
print(f"Using model: {model_name}")
filename = os.path.join("output", f'sentence_{i + 1:03d}.mp3')
tts = TTS(model_name=model_name, progress_bar=False).to("cpu")
tts.tts_to_file(text=sentence, file_path=filename)
audio = MP3(filename)
print(audio.info.length)
For troubleshooting I tried having Mutagen read the file outside of my venv, which it reads just fine?? In the venv I am using python 3.9 and on my command line its python 3.12, I can’t determine any other difference between those tests. Any help would be greatly appreciated!!