fix(espeak_wrapper): capture stderr separately

Fixes https://github.com/coqui-ai/TTS/issues/2728

Previously, error messages from espeak were treated as normal output and also
converted to phonemes. This captures and logs them separately.
This commit is contained in:
Enno Hermann 2024-05-01 12:31:49 +02:00
parent 06304504d2
commit 7b2289a454
1 changed files with 4 additions and 1 deletions

View File

@ -60,9 +60,12 @@ def _espeak_exe(espeak_lib: str, args: List, sync=False) -> List[str]:
with subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stderr=subprocess.PIPE,
) as p:
res = iter(p.stdout.readline, b"")
err = iter(p.stderr.readline, b"")
for line in err:
logger.warning("espeakng: %s", line.decode("utf-8").strip())
if not sync:
p.stdout.close()
if p.stderr: