Closed JRMeyer closed 9 months ago
Do you have speakers_xtts.pth file? I would check that first.
Seeing similar/same issue using Docker container on Ubuntu
`tts --list_speaker_idxs
results in:
Traceback (most recent call last):
File "/usr/local/bin/tts", line 8, in <module>
sys.exit(main())
File "/root/TTS/bin/synthesize.py", line 443, in main
print(synthesizer.tts_model.speaker_manager.name_to_id)
AttributeError: 'NoneType' object has no attribute 'name_to_id'
{
"CUDA": {
"GPU": [],
"available": false,
"version": "11.8"
},
"Packages": {
"PyTorch_debug": false,
"PyTorch_version": "2.1.1+cu118",
"TTS": "0.22.0",
"numpy": "1.22.0"
},
"System": {
"OS": "Linux",
"architecture": [
"64bit",
""
],
"processor": "",
"python": "3.10.8",
"version": "#38~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 2 18:01:13 UTC 2"
}
}
I have a similar problem. My code is as follows:
import torch
from TTS.api import TTS
# Get device
DEVICE: str = "cuda" if torch.cuda.is_available() else "cpu"
# Init TTS
tts: TTS = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2").to(DEVICE)
if tts.is_multi_speaker:
print(tts.speakers)
Then, I got the error: AttributeError: 'TTS' object has no attribute 'speakers'
.
So I checked the source code of speakers()
method of the class TTS
in TTS/api.py
:
@property
def speakers(self):
if not self.is_multi_speaker:
return None
return self.synthesizer.tts_model.speaker_manager.speaker_names
I ran it again using the implementation in the source code:
print(tts.synthesizer.tts_model.speaker_manager.speaker_names)
And a new error was:
AttributeError: 'dict_keys' object has no attribute 'keys'
Then again I checked the source code of speaker_names()
method of the class SpeakerManager
in TTS/tts/utils/speakers.py
:
@property
def speaker_names(self):
return list(self.name_to_id.keys())
And I tried to know what name_to_id
is:
print(tts.synthesizer.tts_model.speaker_manager.name_to_id)
>>> dict_keys(['Claribel Dervla', 'Daisy Studious', ... , 'Marcos Rudaski'])
So, if I use print(list(tts.synthesizer.tts_model.speaker_manager.name_to_id))
instead of print(tts.speakers)
, I can get the expected answer:
print(list(tts.synthesizer.tts_model.speaker_manager.name_to_id))
>>> ['Claribel Dervla', 'Daisy Studious', ...'Marcos Rudaski']
It's certain that there's a problem in the code, but I'm not sure where it's caused by. Obviously, name_to_id
is supposed to be a type like dict[str, int]
, but that's clearly not what's happening now. :joy:
Had the same problem. You probably have an outdated version of the model checkpoint. The speaker data has been updated only 1 month ago.
Quick solution: rm ~/.local/share/tts/tts_models--multilingual--multi-dataset--xtts_v2 -fR
The new model will automatically be downloaded the next time you try to use it.
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.
Describe the bug
trying to list studio speakers from the CLI, and getting errors (macOS, CPU)
To Reproduce
Expected behavior
Logs
Additional context
No response