TTS icon indicating copy to clipboard operation
TTS copied to clipboard

[Bug] cannot import name 'LogitsWarper' from 'transformers', from transformers import LogitsWarper

Open devops724 opened this issue 1 year ago β€’ 9 comments

Describe the bug

Hi what i run finetune code for tts v2 i get this error from TTS.tts.layers.xtts.trainer.gpt_trainer import GPTArgs, GPTTrainer, GPTTrainerConfig, XttsAudioConfig File "/home/user/workspace/dataset/TTS/venv/lib/python3.11/site-packages/TTS/tts/layers/xtts/trainer/gpt_trainer.py", line 15, in from TTS.tts.layers.tortoise.arch_utils import TorchMelSpectrogram File "/home/user/workspace/dataset/TTS/venv/lib/python3.11/site-packages/TTS/tts/layers/tortoise/arch_utils.py", line 10, in from transformers import LogitsWarper ImportError: cannot import name 'LogitsWarper' from 'transformers' (/home/user/workspace/dataset/TTS/venv/lib/python3.11/site-packages/transformers/init.py) Traceback (most recent call last): File "/home/user/workspace/dataset/xtts-fa/train_xtts.py", line 11, in from TTS.tts.layers.xtts.trainer.gpt_trainer import GPTArgs, GPTTrainer, GPTTrainerConfig, XttsAudioConfig File "/home/user/workspace/dataset/TTS/venv/lib/python3.11/site-packages/TTS/tts/layers/xtts/trainer/gpt_trainer.py", line 15, in from TTS.tts.layers.tortoise.arch_utils import TorchMelSpectrogram File "/home/user/workspace/dataset/TTS/venv/lib/python3.11/site-packages/TTS/tts/layers/tortoise/arch_utils.py", line 10, in from transformers import LogitsWarper ImportError: cannot import name 'LogitsWarper' from 'transformers' (/home/user/workspace/dataset/TTS/venv/lib/python3.11/site-packages/transformers/init.py) Traceback (most recent call last): File "/home/user/workspace/dataset/xtts-fa/train_xtts.py", line 11, in from TTS.tts.layers.xtts.trainer.gpt_trainer import GPTArgs, GPTTrainer, GPTTrainerConfig, XttsAudioConfig File "/home/user/workspace/dataset/TTS/venv/lib/python3.11/site-packages/TTS/tts/layers/xtts/trainer/gpt_trainer.py", line 15, in from TTS.tts.layers.tortoise.arch_utils import TorchMelSpectrogram File "/home/user/workspace/dataset/TTS/venv/lib/python3.11/site-packages/TTS/tts/layers/tortoise/arch_utils.py", line 10, in from transformers import LogitsWarper ImportError: cannot import name 'LogitsWarper' from 'transformers' (/home/user/workspace/dataset/TTS/venv/lib/python3.11/site-packages/transformers/init.py)

To Reproduce

run https://github.com/coqui-ai/TTS/blob/dev/recipes/ljspeech/xtts_v2/train_gpt_xtts.py script

Expected behavior

No response

Logs


Environment

TTS==0.22.0
torch==2.6.0
torchaudio==2.6.0
transformers==4.49.0

Additional context

No response

devops724 avatar Mar 03 '25 07:03 devops724

This repo is not maintained anymore and doesn't work with latest versions of Pytorch and transformers. You can use our fork instead, available via pip install coqui-tts

eginhard avatar Mar 03 '25 09:03 eginhard

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You might also look our discussion channels.

stale[bot] avatar Apr 04 '25 03:04 stale[bot]

I found a solution. I replaced the "LogitsWarper" with "LogitsProcessor". The error ocurred for me when I was trying to use tortoise.

In my example the affected file was env/site-packages/TTS/tts/layers/tortoise/arch_utils.py

line 10: from transformers import LogitsWarper -> from transformers import LogitsProcessor line 401: class TypicalLogitsWarper(LogitsWarper): -> class TypicalLogitsWarper(LogitsProcessor):

fisand08 avatar Apr 09 '25 11:04 fisand08

hi, I got same error, I'll try your approach. Thanks

bmt621 avatar Apr 09 '25 18:04 bmt621

@fisand08 @bmt621 As mentioned above you can just use the fork with pip install coqui-tts where this and many other issues are fixed. This repo here is no longer updated.

eginhard avatar Apr 10 '25 04:04 eginhard

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You might also look our discussion channels.

stale[bot] avatar May 10 '25 09:05 stale[bot]

it seems to go back with v0.26.0 on MacOS Sonoma, here is the log.

logs.txt

ROBERT-MCDOWELL avatar May 16 '25 20:05 ROBERT-MCDOWELL

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You might also look our discussion channels.

stale[bot] avatar Jun 15 '25 21:06 stale[bot]

go to the eginhard fork, he solved a lot of issues.

ROBERT-MCDOWELL avatar Jun 15 '25 21:06 ROBERT-MCDOWELL

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You might also look our discussion channels.

stale[bot] avatar Jul 16 '25 01:07 stale[bot]

I found a solution. I replaced the "LogitsWarper" with "LogitsProcessor". The error ocurred for me when I was trying to use tortoise.

In my example the affected file was env/site-packages/TTS/tts/layers/tortoise/arch_utils.py

line 10: from transformers import LogitsWarper -> from transformers import LogitsProcessor line 401: class TypicalLogitsWarper(LogitsWarper): -> class TypicalLogitsWarper(LogitsProcessor):

It works, thank you @fisand08!

Hemilibeatriz avatar Sep 26 '25 12:09 Hemilibeatriz