Update EspeakWrapper for espeak-ng

This commit is contained in:
Eren Gölge 2021-11-25 17:28:17 +01:00
parent 8c8093ce23
commit c39aaafbfc
1 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,5 @@
import logging import logging
import subprocess import subprocess
import tempfile
from typing import Dict, List from typing import Dict, List
from TTS.tts.utils.text.phonemizers.base import BasePhonemizer from TTS.tts.utils.text.phonemizers.base import BasePhonemizer
@ -24,6 +23,7 @@ else:
def _espeak_exe(espeak_lib: str, args: List, sync=False) -> List[str]: def _espeak_exe(espeak_lib: str, args: List, sync=False) -> List[str]:
cmd = [ cmd = [
espeak_lib, espeak_lib,
"-q",
"-b", "-b",
"1", # UTF8 text encoding "1", # UTF8 text encoding
] ]
@ -107,11 +107,20 @@ class ESpeak(BasePhonemizer):
with '_'. This option requires espeak>=1.49. Default to False. with '_'. This option requires espeak>=1.49. Default to False.
""" """
# set arguments # set arguments
args = ["-q", "-v", f"{self._language}"] args = ["-v", f"{self._language}"]
# espeak and espeak-ng parses `ipa` differently
if tie: if tie:
args.append("--ipa=1") # use '͡' between phonemes # use '͡' between phonemes
if _DEF_ESPEAK_LIB == "espeak":
args.append("--ipa=1")
else: else:
args.append("--ipa=3") # split with '_' args.append("--ipa=3")
else:
# split with '_'
if _DEF_ESPEAK_LIB == "espeak":
args.append("--ipa=3")
else:
args.append("--ipa=1")
if tie: if tie:
args.append("--tie=%s" % tie) args.append("--tie=%s" % tie)
args.append(text) args.append(text)