2

I've recently had a hiking accident in which one eye got damaged. Hopefully I can fully recover, but until then reading longer texts is very exhausting to me. So I'm looking for a text-to-speech (TTS) solution which I can use for e-mails / some other texts.

I'm looking for a TTS software () that is executed locally (no web service, hence no Lyrebird / no gTTs) and sounds better than eSpeak. It should run on .

I'm looking for something like Tacotron 2, but ready-to-use (if possible without a GPU; it does NOT have to be real-time). I've also seen a lot more models in A Survey on Neural Speech Synthesis that might lead to similar good results.

What I tried

  • pyttsx3 with eSpeak (code) gives this mp3. Absolutely horrible.
  • gTTs (code) gives this mp3. A lot better, but not executed locally. The Google service might shut down at any time + not usable if privacy is a concern.
  • Lyrebird is amazing, but not

Example Text

I used The Awful German Language by Mark Twain as an example:

I went often to look at the collection of curiosities in Heidelberg Castle, and one day I surprised the keeper of it with my German. I spoke entirely in that language. He was greatly interested; and after I had talked a while he said my German was very rare, possibly a "unique"; and wanted to add it to his museum.

If he had known what it had cost me to acquire my art, he would also have known that it would break any collector to buy it. Harris and I had been hard at work on our German during several weeks at that time, and although we had made good progress, it had been accomplished under great difficulty and annoyance, for three of our teachers had died in the mean time.

1 Answer 1

1

I found something: CoquiTTS (web demo)

import sys


def gen(model_name: str, text: str, out_file: str) -> None:
    from TTS.api import TTS  # pip install TTS

    tts = TTS(model_name=model_name, progress_bar=False, gpu=False)
    # if you want to see which models are available: TTS.list_models()
    print("#" * 80)
    print(f"model={model_name}")
    print(f"speakers={tts.speakers}")
    print(f"languages={tts.languages}")
    speaker = tts.speakers[0] if tts.speakers else None
    language = "en" if tts.languages else None
    tts.tts_to_file(text=text, speaker=speaker, language=language, file_path=out_file)


def get_text(filepath: str) -> str:
    with open(filepath) as fp:
        text = fp.read()
    text = text.replace("”", '"').replace("“", '"')
    return text


if __name__ == "__main__":
    gen(
        model_name="tts_models/en/ljspeech/vits--neon",
        text=get_text(sys.argv[1]),
        out_file=sys.argv[2]
    )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.