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
35.27k stars 4.3k forks source link

[Bug] typo in \TTS\tts\utils\text\punctuation.py, lines 140 and 151 reference attribute "punc" incorrectly as "mark" #1720

Closed ShmingMaster closed 2 years ago

ShmingMaster commented 2 years ago

Describe the bug

\TTS\tts\utils\text\punctuation.py, line 140, this only gets called when the synthesizer is told to speak a string that only consists of punctuation marks, you get the error
File "F:\TTS Adventures\coqui\coqui39\lib\site-packages\TTS\tts\utils\text\punctuation.py", line 140, in return ["".join(m.mark for m in puncs)] AttributeError: '_punc_index' object has no attribute 'mark'

I also notice the same typo is in line 150. Poked around, looks like line 9 says _PUNC_IDX = collections.namedtuple("_punc_index", ["punc", "position"]) and neither of those words are "mark".

I'd do the fix myself but I've literally never requested to change a respository on github before in my life and it's 1am local as I type this. Well, I mean, I did the fix myself on my machine, and it worked.

To Reproduce

image I ran specifically the following model, where "words" was the string "!?!?!?!?!?!" or something like that to reproduce the error just now for the screenshot.

model_path, config_path, model_item = manager.download_model("tts_models/en/vctk/vits") synthesizer = Synthesizer( tts_checkpoint=model_path, tts_config_path=config_path,

tts_speakers_file=speakers_file_path,

tts_languages_file=None,
#vocoder_checkpoint=vocoder_path,
#vocoder_config=vocoder_config_path,
encoder_checkpoint="",
encoder_config="",
use_cuda=True,

) wavs = synthesizer.tts(words, speaker_name="p311", style_wav=None) out = Path(file).parent/out_path synthesizer.save_wav(wavs, out)

Expected behavior

No response

Logs

No response

Environment

{
    "CUDA": {
        "GPU": [
            "NVIDIA GeForce RTX 3090"
        ],
        "available": true,
        "version": "11.6"
    },
    "Packages": {
        "PyTorch_debug": false,
        "PyTorch_version": "1.12.0+cu116",
        "TTS": "0.6.2",
        "numpy": "1.19.5"
    },
    "System": {
        "OS": "Windows",
        "architecture": [
            "64bit",
            "WindowsPE"
        ],
        "processor": "Intel64 Family 6 Model 158 Stepping 9, GenuineIntel",
        "python": "3.9.13",
        "version": "10.0.19044"
    }
}

Additional context

No response

erogol commented 2 years ago

Can you pls format your post correctly?

https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks

stale[bot] commented 2 years ago

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.

erogol commented 2 years ago

This needs to be fixed by now.

ShayBox commented 2 years ago

Yeah same problem, punctuation code is :b:roke

  File "/home/shaybox/.cache/pypoetry/virtualenvs/daily-reddit-recap-dIQ3ccPv-py3.10/lib/python3.10/site-packages/TTS/utils/synthesizer.py", line 270, in tts
    outputs = synthesis(
  File "/home/shaybox/.cache/pypoetry/virtualenvs/daily-reddit-recap-dIQ3ccPv-py3.10/lib/python3.10/site-packages/TTS/tts/utils/synthesis.py", line 180, in synthesis
    model.tokenizer.text_to_ids(text, language=language_id),
  File "/home/shaybox/.cache/pypoetry/virtualenvs/daily-reddit-recap-dIQ3ccPv-py3.10/lib/python3.10/site-packages/TTS/tts/utils/text/tokenizer.py", line 109, in text_to_ids
    text = self.phonemizer.phonemize(text, separator="")
  File "/home/shaybox/.cache/pypoetry/virtualenvs/daily-reddit-recap-dIQ3ccPv-py3.10/lib/python3.10/site-packages/TTS/tts/utils/text/phonemizers/base.py", line 135, in phonemize
    phonemized = self._phonemize_postprocess(phonemized, punctuations)
  File "/home/shaybox/.cache/pypoetry/virtualenvs/daily-reddit-recap-dIQ3ccPv-py3.10/lib/python3.10/site-packages/TTS/tts/utils/text/phonemizers/base.py", line 114, in _phonemize_postprocess
    return self._punctuator.restore(phonemized, punctuations)[0]
  File "/home/shaybox/.cache/pypoetry/virtualenvs/daily-reddit-recap-dIQ3ccPv-py3.10/lib/python3.10/site-packages/TTS/tts/utils/text/punctuation.py", line 130, in restore
    return cls._restore(text, puncs, 0)
  File "/home/shaybox/.cache/pypoetry/virtualenvs/daily-reddit-recap-dIQ3ccPv-py3.10/lib/python3.10/site-packages/TTS/tts/utils/text/punctuation.py", line 140, in _restore
    return ["".join(m.mark for m in puncs)]
  File "/home/shaybox/.cache/pypoetry/virtualenvs/daily-reddit-recap-dIQ3ccPv-py3.10/lib/python3.10/site-packages/TTS/tts/utils/text/punctuation.py", line 140, in <genexpr>
    return ["".join(m.mark for m in puncs)]
AttributeError: '_punc_index' object has no attribute 'mark'

Text that caused this:

For having lunch with my grandma on my lunch break at work. Not joking. I serve a wide area of my state and when I’m in her part of the state, which was historically underserved by the person in my position before I was, I eat lunch with her during my lunch break. The other administrators I work with in parts of the state that I serve are now complaining that the only reason that part of the state is getting more attention (ie. Equal treatment to them rather than being neglected) is because I like to have lunch with my grandmother.

Models:

"tts_models/en/ljspeech/fast_pitch"
"vocoder_models/en/ljspeech/hifigan_v2"
erogol commented 2 years ago

@WeberJulian Can you check this?

WeberJulian commented 2 years ago

I'm on it

WeberJulian commented 2 years ago

Hey this looks like a bug I fixed in this PR https://github.com/coqui-ai/TTS/pull/1717

Could you please try v0.8.0 of TTS?

ShayBox commented 2 years ago

Yep that fixed it 👍