Skip to content

AttributeError: module 'torch.serialization' has no attribute 'FILE_LIKE' #933

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

Open
rhyshanan opened this issue May 2, 2025 · 4 comments · Fixed by #932
Open

AttributeError: module 'torch.serialization' has no attribute 'FILE_LIKE' #933

rhyshanan opened this issue May 2, 2025 · 4 comments · Fixed by #932
Labels
bug Something isn't working

Comments

@rhyshanan
Copy link

Hi,

I'm on python 3.13 and installed ChatTTS and its requirments.txt ... via the Pycharm packages repository (PIP)

Everything installed with no errors.

But when I run the main webpages basic example code ... in python.


import ChatTTS
import torch
import torchaudio

chat = ChatTTS.Chat()
chat.load(compile=False) # Set to True for better performance

texts = ["PUT YOUR 1st TEXT HERE", "PUT YOUR 2nd TEXT HERE"]

wavs = chat.infer(texts)

for i in range(len(wavs)):
    """
    In some versions of torchaudio, the first line works but in other versions, so does the second line.
    """
    try:
        torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]).unsqueeze(0), 24000)
    except:
        torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]), 24000)

It returns the following error,

Traceback (most recent call last):
  File "D:\GOOD\Coding\.Coding_Projects\Composite_media\Text to Speech\Audiobook_Maker\test3.py", line 8, in <module>
    import ChatTTS
  File "C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-packages\ChatTTS\__init__.py", line 1, in <module>
    from .core import Chat
  File "C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-packages\ChatTTS\core.py", line 17, in <module>
    from .model import DVAE, Embed, GPT, gen_logits, Tokenizer, Speaker
  File "C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-packages\ChatTTS\model\__init__.py", line 6, in <module>
    from .tokenizer import Tokenizer
  File "C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-packages\ChatTTS\model\tokenizer.py", line 16, in <module>
    class Tokenizer:
    ...<121 lines>...
            )
  File "C:\Users\User\AppData\Local\Programs\Python\Python313\Lib\site-packages\ChatTTS\model\tokenizer.py", line 19, in Tokenizer
    tokenizer_path: torch.serialization.FILE_LIKE,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'torch.serialization' has no attribute 'FILE_LIKE'
@AluGoooo
Copy link

AluGoooo commented May 3, 2025

the same problem and my way is change torch>=2.1.0 to torch==2.5.0,its solved, but i dont know what happed.

@fumiama fumiama linked a pull request May 6, 2025 that will close this issue
@Kommisaar
Copy link

Kommisaar commented May 6, 2025

In newer versions of PyTorch, FILE_LIKE has been changed to FileLike. Consider downgrading to an earlier version.

@fumiama fumiama added the bug Something isn't working label May 6, 2025
@rhyshanan
Copy link
Author

Ok thank you! We will wait for the update

@osbertngok
Copy link

torch>=2.1.0,<2.7.0 should work. In pytorch 2.7.1 there is a breaking change:
pytorch/pytorch@835e770

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.

5 participants