[Python] Coqui TTS: No espeak backend found. Install espeak-ng or espeak to your system

Discussão em 'Python' iniciado por Stack, Abril 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have a test script for Coqui TTS under Windows. I moved the installation folder to the project directory and set the PATH variables.

    [​IMG]

    import os
    import torch
    from TTS.api import TTS
    from TTS.utils.manage import ModelManager

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

    espeak_path = r"eSpeakNG"

    # Add eSpeak to PATH
    os.environ["PATH"] = espeak_path + os.pathsep + os.environ.get("PATH", "")
    os.environ["ESPEAK_DATA_PATH"] = os.path.join(espeak_path, "espeak-ng-data")

    # Show models
    manager = ModelManager()
    models = manager.list_models()
    print(models)

    # Initialize TTS-Model
    tts = TTS(model_name="tts_models/de/thorsten/tacotron2-DDC")
    # Save tts
    tts.tts_to_file(text="Das ist ein Test.", file_path="output.wav")


    I always get the error message

    File "C:\Python311\Lib\site-packages\TTS\tts\utils\text\phonemizers\espeak_wrapper.py", line 114, in __init__
    raise Exception(" [!] No espeak backend found. Install espeak-ng or espeak to your system.")


    Exception: [!] No espeak backend found. Install espeak-ng or espeak to your system.

    I tried this code

    import subprocess

    espeak_path = r"eSpeakNG"
    os.environ["PATH"] = espeak_path + os.pathsep + os.environ.get("PATH", "")
    os.environ["ESPEAK_DATA_PATH"] = os.path.join(espeak_path, "espeak-ng-data")

    try:
    result = subprocess.run(
    ["espeak-ng.exe", "--version"],
    capture_output=True,
    text=True,
    )
    print("eSpeak NG output:", result.stdout)
    except FileNotFoundError:
    print("espeak-ng.exe not found.")


    and the output is eSpeak NG output: eSpeak NG text-to-speech: 1.52-dev Data at: eSpeakNG\espeak-ng-data, so it is set correct, right? I also tried this code to ensure the Dll can be loaded:

    import ctypes

    try:
    ctypes.CDLL(r"eSpeakNG\libespeak-ng.dll")
    print("libespeak-ng.dll successfully loaded.")
    except OSError as e:
    print("Error loading libespeak-ng.dll:", e)


    Is there anything Coqui uses I forgot to add to the PATH? Thank you.

    Continue reading...

Compartilhe esta Página