coqui-ai / TTS

🐸💬 - a deep learning toolkit for Text-to-Speech, battle-tested in research and production
http://coqui.ai
Mozilla Public License 2.0
33.25k stars 4.02k forks source link

[Bug] json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #3074

Closed darkzbaron closed 10 months ago

darkzbaron commented 10 months ago

Describe the bug

Can't generate with Coqui Studio voices

To Reproduce

When running

tts = TTS(model_name="coqui_studio/en/Torcull Diarmuid/coqui_studio", progress_bar=False) tts.tts_to_file(text="This is a test.", file_path="out.wav")

I get that error json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Expected behavior

Voice generated

Logs

No response

Environment

{
    "CUDA": {
        "GPU": [
            "NVIDIA GeForce GTX 1650"
        ],
        "available": true,
        "version": "12.1"
    },
    "Packages": {
        "PyTorch_debug": false,
        "PyTorch_version": "2.1.0+cu121",
        "TTS": "0.17.8",
        "numpy": "1.22.0"
    },
    "System": {
        "OS": "Windows",
        "architecture": [
            "64bit",
            "WindowsPE"
        ],
        "processor": "Intel64 Family 6 Model 165 Stepping 5, GenuineIntel",
        "python": "3.9.16",
        "version": "10.0.19045"
    }
}

Additional context

Also I find that voices generated with xTTS local are far from what is generated in Coqui Studio, any explanation to that?

Zeiny96 commented 10 months ago

Getting similar error whenever I try to use the library.

zhangwenniu commented 10 months ago

Description

/home/wenniu/anaconda3/envs/tts/lib/python3.9/site-packages/TTS/.models.json This json file format has an extra comma, cause ttf --list_models to be wrong:

tts --list_models                                                                                                                                                                          ─╯
Traceback (most recent call last):
  File "/home/wenniu/anaconda3/envs/tts/bin/tts", line 8, in <module>
    sys.exit(main())
  File "/home/wenniu/anaconda3/envs/tts/lib/python3.9/site-packages/TTS/bin/synthesize.py", line 375, in main
    manager = ModelManager(path, progress_bar=args.progress_bar)
  File "/home/wenniu/anaconda3/envs/tts/lib/python3.9/site-packages/TTS/utils/manage.py", line 55, in __init__
    self.read_models_file(models_file)
  File "/home/wenniu/anaconda3/envs/tts/lib/python3.9/site-packages/TTS/utils/manage.py", line 68, in read_models_file
    self.models_dict = json.load(json_file)
  File "/home/wenniu/anaconda3/envs/tts/lib/python3.9/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/home/wenniu/anaconda3/envs/tts/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/home/wenniu/anaconda3/envs/tts/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/wenniu/anaconda3/envs/tts/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 11 column 21 (char 549)

Solution:

    "tts_models": {
        "multilingual": {
            "multi-dataset": {
                "xtts_v1": {
                    "description": "XTTS-v1 by Coqui with 13 languages and cross-language voice cloning.",
                    "hf_url": [
                        "https://coqui.gateway.scarf.sh/hf-coqui/XTTS-v1/hifigan/model.pth",
                        "https://coqui.gateway.scarf.sh/hf-coqui/XTTS-v1/hifigan/config.json",
                        "https://coqui.gateway.scarf.sh/hf-coqui/XTTS-v1/hifigan/vocab.json", <==========there is an extra comma, should delete it. (line 10)
                    ],
                    "default_vocoder": null,
                    "commit": "e5140314",
                    "license": "CPML",
                    "contact": "info@coqui.ai",
                    "tos_required": true
                },

delete comma at the end of line 11.

WeberJulian commented 10 months ago

The fix took some time to be deployed on Pypi , can you please try now with pip install -U TTS?

fallinbryan commented 10 months ago

@erogol ,

Looks like the fix didn't deploy to Pypi... I just installed TTS with pip install TTS and after reading the bug also ran pip install -U TTS

I am getting this same error when following the instructions on the README TTS(cs_api_model="XTTS").list_models()

also if coqui_studio model is loaded, the tts_to_file won't work at all and I get the JSONDecodeError tts = TTS(model_name="coqui_studio/en/Torcull Diarmuid/coqui_studio", progress_bar=False)

darkzbaron commented 10 months ago

Thanks for the push @erogol ! print(TTS().list_models())

was not working in any case, now it just does not work when trying to list models from Coqui studio. Essentially this does not work: models = TTS(cs_api_model="XTTS").list_models()

it returns Expecting value: line 1 column 1 (char 0)

When I am trying to generate audio with

tts.tts_to_file(text="This is a test.", file_path=OUTPUT_PATH)

I get

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Thanks so much!

ColemanDunn commented 10 months ago

Same here. Can't follow the guide in the readme because of this error.

ColemanDunn commented 10 months ago

data = res.read() in

def list_voices(self):
        """List custom voices created by the user."""
        conn = http.client.HTTPSConnection("app.coqui.ai")
        url = self.MODEL_ENDPOINTS[self.model]["list_voices"]
        conn.request("GET", f"{url}", headers=self.headers)
        res = conn.getresponse()
        data = res.read()
        return [Speaker(s, True) for s in json.loads(data)["result"]]

results in HTML encoded as btyes, NOT json.

nirbhaysinghnarang commented 10 months ago

Running into the same error, any workarounds?

Aliasmk commented 10 months ago

Also having this problem with the sample code from the readme. I can list the models but tts.tts_to_file(text="This is a test.", file_path="./test.wav") gives me the error json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0).

ColemanDunn commented 10 months ago

@erogol any idea why this got closed?

cocktailpeanut commented 10 months ago

I think I've fixed this, please check out the PR for details on what's happening and how I fixed it https://github.com/coqui-ai/TTS/pull/3138