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] TypeError: 'NoneType' object is not subscriptable #3019

Closed
bropines opened this issue Sep 30, 2023 · 6 comments
Closed

[Bug] TypeError: 'NoneType' object is not subscriptable #3019

bropines opened this issue Sep 30, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@bropines
Copy link

Describe the bug

Traceback (most recent call last):
File "G:\TTS\script.py", line 15, in
tts.tts_to_file(text="Hello world!", speaker=tts.speakers[0], language=tts.languages[0], file_path="output.wav")
TypeError: 'NoneType' object is not subscriptable

To Reproduce

I took an example from the readme

import torch
from TTS.api import TTS

# Get device
device = "cuda" if torch.cuda.is_available() else "cpu"

# List available 🐸TTS models and choose the first one
model_name = TTS().list_models()[0]
# Init TTS
tts = TTS(model_name).to(device)

# Run TTS
# ❗ Since this model is multi-speaker and multi-lingual, we must set the target speaker and the language
# Text to speech to a file
tts.tts_to_file(text="Hello world!", speaker=tts.speakers[0], language=tts.languages[0], file_path="output.wav")```

### Expected behavior

_No response_

### Logs

```shell
"Ya zapustil venv"
Python 3.10.6
Microsoft Windows [Version 10.0.22631.2338]
(c) Корпорация Майкрософт (Microsoft Corporation). Все права защищены.

(venv) G:\TTS>python script.py
G:\TTS\venv\lib\site-packages\torchaudio\compliance\kaldi.py:22: UserWarning: Failed to initialize NumPy: module compiled against API version 0x10 but this version of numpy is 0xf . Check the section C-API incompatibility at the Troubleshooting ImportError section at https://numpy.org/devdocs/user/troubleshooting-importerror.html#c-api-incompatibility for indications on how to solve this problem . (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:84.)
  EPSILON = torch.tensor(torch.finfo(torch.float).eps)
No API token found for 🐸Coqui Studio voices - https://coqui.ai
Visit 🔗https://app.coqui.ai/account to get one.
Set it as an environment variable `export COQUI_STUDIO_TOKEN=<token>`

 > tts_models/multilingual/multi-dataset/xtts_v1 is already downloaded.
 > Using model: xtts
Traceback (most recent call last):
  File "G:\TTS\script.py", line 15, in <module>
    tts.tts_to_file(text="Hello world!", speaker=tts.speakers[0], language=tts.languages[0], file_path="output.wav")
TypeError: 'NoneType' object is not subscriptable

(venv) G:\TTS>

Environment

{
    "CUDA": {
        "GPU": [
            "NVIDIA GeForce RTX 3060"
        ],
        "available": true,
        "version": "11.7"
    },
    "Packages": {
        "PyTorch_debug": false,
        "PyTorch_version": "2.0.1+cu117",
        "TTS": "0.17.6",
        "numpy": "1.22.0"
    },
    "System": {
        "OS": "Windows",
        "architecture": [
            "64bit",
            "WindowsPE"
        ],
        "processor": "Intel64 Family 6 Model 167 Stepping 1, GenuineIntel",
        "python": "3.10.6",
        "version": "10.0.22631"
    }
}

Additional context

No response

@bropines bropines added the bug Something isn't working label Sep 30, 2023
@bropines
Copy link
Author

Of course, I understand that I'm stupid and could mess up in the code, but I took the simplest and default example

@bropines bropines changed the title [Bug] TypeError: 'NoneType' object is not subscriptable [Bug] Sep 30, 2023
@bropines bropines changed the title TypeError: 'NoneType' object is not subscriptable [Bug] [Bug] TypeError: 'NoneType' object is not subscriptable Sep 30, 2023
@cabusar
Copy link

cabusar commented Sep 30, 2023

Hi,

I have the exact same problem, i'm on Windows too.

As i was looking for a solution i notice the problem seems to came from the list (tts.model, tts.speakers and tts.language) that are empty (none).

For instance i was able to make Coqui working with :

from TTS.api import TTS
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v1", gpu=True)

# generate speech by cloning a voice using default settings
tts.tts_to_file(text="This is a test",
                file_path="output.wav",
                speaker_wav="C:\\youruser\\yourfolder\\yourfile.wav",
                #speaker =""
                language="en")

@bropines : if you want to test xtts with this script you can download a youtube video as wav and with one person speaking, the results are clearely not amazing, but at least it validate that the model is working with your setup.

For now i'm trying to check if i can pass direct value instead, like in this script but i didn't find any list of speakers or languages at the moment.

Let me know if someone find a workaround or if there is something to do. :)

@David-bfg
Copy link
Contributor

The latest commit 4033db5 added a new voice model without updating the examples.

It appears that this change will skip the new model and point you to the old one that has those features implemented.
model_name = TTS().list_models()[1]

Ran into the same problem getting started and went diving into the code.

Looks like a lot of models are inconsistent in a couple ways. This new one and a few others seem to not have tts --model_name "tts_models/multilingual/multi-dataset/xtts_v1" --list_speaker_idxs working or implemented.

I assume the fix will be to implement it in the new model instead of just changing the documentation.

@bropines
Copy link
Author

bropines commented Oct 1, 2023

The latest commit 4033db5 added a new voice model without updating the examples.

It appears that this change will skip the new model and point you to the old one that has those features implemented. model_name = TTS().list_models()[1]

Ran into the same problem getting started and went diving into the code.

Looks like a lot of models are inconsistent in a couple ways. This new one and a few others seem to not have tts --model_name "tts_models/multilingual/multi-dataset/xtts_v1" --list_speaker_idxs working or implemented.

I assume the fix will be to implement it in the new model instead of just changing the documentation.

I just need to voice a conditional srt file and I just wanted to push in a model, but I don’t even understand which one would be suitable for this and how to use everything

@ahmedosman2001
Copy link

ahmedosman2001 commented Oct 10, 2023

Im getting the same error for this code

import torch
from TTS.api import TTS

# Get device
device = "cuda" if torch.cuda.is_available() else "cpu"

# List available 🐸TTS models and choose the first one
model_name = TTS().list_models()[0]
# Init TTS
tts = TTS(model_name).to(device)

# Run TTS
# ❗ Since this model is multi-speaker and multi-lingual, we must set the target speaker and the language
# Text to speech with a numpy output
wav = tts.tts("This is a test! This is also a test!!", speaker=tts.speakers[0], language=tts.languages[0])
# Text to speech to a file
tts.tts_to_file(text="Hello world!", speaker=tts.speakers[0], language=tts.languages[0], file_path="output.wav")

Error TypeError: 'NoneType' object is not subscriptable

I would like to use the XTTS model which i think located at TTS().list_models()[0]

@David-bfg
Copy link
Contributor

@ahmedosman2001

I would like to use the XTTS model which i think located at TTS().list_models()[0]

Then read the docs https://tts.readthedocs.io/en/dev/models/xtts.html

Also yes that should be the correct index.

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

No branches or pull requests

6 participants