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

[Bug] list_speaker_idx and throws error (CLI, v0.22.0) #3434

Closed
JRMeyer opened this issue Dec 15, 2023 · 5 comments
Closed

[Bug] list_speaker_idx and throws error (CLI, v0.22.0) #3434

JRMeyer opened this issue Dec 15, 2023 · 5 comments
Labels
bug Something isn't working wontfix This will not be worked on but feel free to help.

Comments

@JRMeyer
Copy link
Member

JRMeyer commented Dec 15, 2023

Describe the bug

trying to list studio speakers from the CLI, and getting errors (macOS, CPU)

To Reproduce

  1. pip install -U TTS
  2. tts --model_name tts_models/multilingual/multi-dataset/xtts_v2 --list_speaker_idx

Expected behavior

tts --model_name tts_models/multilingual/multi-dataset/xtts_v2 --list_speaker_idx
 > tts_models/multilingual/multi-dataset/xtts_v2 is already downloaded.
 > Using model: xtts
 > Available speaker ids: (Set --speaker_idx flag to one of these values to use the multi-speaker model.
dict_keys(['Claribel Dervla', 'Daisy Studious', 'Gracie Wise', 'Tammie Ema', 'Alison Dietlinde', 'Ana Florence', 'Annmarie Nele', 'Asya Anara', 'Brenda Stern', 'Gitta Nikolina', 'Henriette Usha', 'Sofia Hellen', 'Tammy Grit', 'Tanja Adelina', 'Vjollca Johnnie', 'Andrew Chipper', 'Badr Odhiambo', 'Dionisio Schuyler', 'Royston Min', 'Viktor Eka', 'Abrahan Mack', 'Adde Michal', 'Baldur Sanjin', 'Craig Gutsy', 'Damien Black', 'Gilberto Mathias', 'Ilkin Urbano', 'Kazuhiko Atallah', 'Ludvig Milivoj', 'Suad Qasim', 'Torcull Diarmuid', 'Viktor Menelaos', 'Zacharie Aimilios', 'Nova Hogarth', 'Maja Ruoho', 'Uta Obando', 'Lidiya Szekeres', 'Chandra MacFarland', 'Szofi Granger', 'Camilla Holmström', 'Lilya Stainthorpe', 'Zofija Kendrick', 'Narelle Moon', 'Barbora MacLean', 'Alexandra Hisakawa', 'Alma María', 'Rosemary Okafor', 'Ige Behringer', 'Filip Traverse', 'Damjan Chapman', 'Wulf Carlevaro', 'Aaron Dreschner', 'Kumar Dahl', 'Eugenio Mataracı', 'Ferran Simen', 'Xavier Hayasaka', 'Luis Moray', 'Marcos Rudaski'])

Logs

josh@joshuas-macbook-pro cv % tts --model_name tts_models/multilingual/multi-dataset/xtts_v2 --list_speaker_idx

 > tts_models/multilingual/multi-dataset/xtts_v2 is already downloaded.
 > Using model: xtts
 > Available speaker ids: (Set --speaker_idx flag to one of these values to use the multi-speaker model.
Traceback (most recent call last):
  File "/opt/homebrew/bin/tts", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/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'


### Environment

```shell
{
    "CUDA": {
        "GPU": [],
        "available": false,
        "version": null
    },
    "Packages": {
        "PyTorch_debug": false,
        "PyTorch_version": "2.1.0",
        "TTS": "0.22.0",
        "numpy": "1.24.3"
    },
    "System": {
        "OS": "Darwin",
        "architecture": [
            "64bit",
            ""
        ],
        "processor": "arm",
        "python": "3.11.6",
        "version": "Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000"
    }
}

Additional context

No response

@JRMeyer JRMeyer added the bug Something isn't working label Dec 15, 2023
@kovrom
Copy link

kovrom commented Dec 23, 2023

Do you have speakers_xtts.pth file? I would check that first.

@davidcheal
Copy link

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"
    }
}

@imkasen
Copy link

imkasen commented Dec 28, 2023

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. 😂

@djmaze
Copy link

djmaze commented Jan 14, 2024

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.

Copy link

stale bot commented Feb 14, 2024

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 stale bot added the wontfix This will not be worked on but feel free to help. label Feb 14, 2024
@stale stale bot closed this as completed Feb 23, 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 wontfix This will not be worked on but feel free to help.
Projects
None yet
Development

No branches or pull requests

5 participants