Add voice aliases
This commit is contained in:
parent
668a46f16d
commit
bac647841f
3 changed files with 21 additions and 1 deletions
|
|
@ -101,8 +101,10 @@ def main():
|
||||||
|
|
||||||
if args.debug:
|
if args.debug:
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
logging.getLogger().setLevel(logging.DEBUG)
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
logging.getLogger().setLevel(logging.INFO)
|
||||||
|
|
||||||
if args.version:
|
if args.version:
|
||||||
# Print version and exit
|
# Print version and exit
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,18 @@ class Mimic3TextToSpeechSystem(TextToSpeechSystem):
|
||||||
if line:
|
if line:
|
||||||
speakers.append(line)
|
speakers.append(line)
|
||||||
|
|
||||||
|
# Load aliases
|
||||||
|
aliases: typing.Optional[typing.Set[str]] = None
|
||||||
|
aliases_path = voice_dir / "ALIASES"
|
||||||
|
if aliases_path.is_file():
|
||||||
|
aliases = set()
|
||||||
|
|
||||||
|
with open(aliases_path, "r", encoding="utf-8") as aliases_file:
|
||||||
|
for line in aliases_file:
|
||||||
|
line = line.strip()
|
||||||
|
if line:
|
||||||
|
aliases.add(line)
|
||||||
|
|
||||||
voice_key = f"{voice_lang}/{voice_name}"
|
voice_key = f"{voice_lang}/{voice_name}"
|
||||||
|
|
||||||
yield Voice(
|
yield Voice(
|
||||||
|
|
@ -231,6 +243,7 @@ class Mimic3TextToSpeechSystem(TextToSpeechSystem):
|
||||||
speakers=speakers,
|
speakers=speakers,
|
||||||
location=str(voice_dir.absolute()),
|
location=str(voice_dir.absolute()),
|
||||||
properties=properties,
|
properties=properties,
|
||||||
|
aliases=aliases,
|
||||||
)
|
)
|
||||||
|
|
||||||
known_voices.discard(voice_key)
|
known_voices.discard(voice_key)
|
||||||
|
|
@ -467,7 +480,9 @@ class Mimic3TextToSpeechSystem(TextToSpeechSystem):
|
||||||
# Look up as substring of known voice
|
# Look up as substring of known voice
|
||||||
model_dir: typing.Optional[Path] = None
|
model_dir: typing.Optional[Path] = None
|
||||||
for maybe_voice in self.get_voices():
|
for maybe_voice in self.get_voices():
|
||||||
if maybe_voice.key.endswith(voice_key):
|
if (voice_key == maybe_voice.key) or (
|
||||||
|
maybe_voice.aliases and (voice_key in maybe_voice.aliases)
|
||||||
|
):
|
||||||
maybe_model_dir = Path(maybe_voice.location)
|
maybe_model_dir = Path(maybe_voice.location)
|
||||||
|
|
||||||
if (not maybe_model_dir.is_dir()) and (not self.settings.no_download):
|
if (not maybe_model_dir.is_dir()) and (not self.settings.no_download):
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,9 @@ class Voice:
|
||||||
properties: typing.Optional[typing.Mapping[str, typing.Any]] = None
|
properties: typing.Optional[typing.Mapping[str, typing.Any]] = None
|
||||||
"""Additional properties associated with the voice"""
|
"""Additional properties associated with the voice"""
|
||||||
|
|
||||||
|
aliases: typing.Optional[typing.Set[str]] = None
|
||||||
|
"""Alternative keys for this voice"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_multispeaker(self) -> bool:
|
def is_multispeaker(self) -> bool:
|
||||||
"""True if voice has multiple speakers"""
|
"""True if voice has multiple speakers"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue