Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Add voice genders, fix MaryTTS /voices API
Browse files Browse the repository at this point in the history
  • Loading branch information
synesthesiam committed Oct 22, 2021
1 parent fbcd8a0 commit e03cf6c
Show file tree
Hide file tree
Showing 57 changed files with 190 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL := bash

.PHONY: check clean reformat dist docker amd64 index test
.PHONY: check clean reformat dist docker index test genders

all: dist

Expand All @@ -24,3 +24,6 @@ docker:

index:
bin/make_sample_html.py local/ > index.html

genders:
scripts/get-genders.sh > larynx/VOICE_GENDERS
2 changes: 1 addition & 1 deletion larynx/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.2
1.0.3
51 changes: 51 additions & 0 deletions larynx/VOICE_GENDERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ru-ru_nikolaev-glow_tts M
ru-ru_hajdurova-glow_tts F
ru-ru_minaev-glow_tts M
en-us_scottish_english_male-glow_tts M
en-us_northern_english_male-glow_tts M
en-us_cmu_ljm-glow_tts F
en-us_cmu_slp-glow_tts F
en-us_cmu_bdl-glow_tts M
en-us_cmu_aew-glow_tts M
en-us_cmu_clb-glow_tts F
en-us_cmu_jmk-glow_tts M
en-us_cmu_aup-glow_tts M
en-us_cmu_lnh-glow_tts F
en-us_southern_english_male-glow_tts M
en-us_cmu_rxr-glow_tts M
en-us_blizzard_fls-glow_tts F
en-us_blizzard_lessac-glow_tts F
en-us_glados-glow_tts F
en-us_cmu_fem-glow_tts M
en-us_harvard-glow_tts F
en-us_judy_bieber-glow_tts F
en-us_cmu_rms-glow_tts M
en-us_cmu_slt-glow_tts F
en-us_mary_ann-glow_tts F
en-us_ljspeech-glow_tts F
en-us_cmu_ksp-glow_tts M
en-us_cmu_ahw-glow_tts M
en-us_kathleen-glow_tts F
en-us_cmu_eey-glow_tts F
en-us_southern_english_female-glow_tts F
en-us_ek-glow_tts F
de-de_hokuspokus-glow_tts F
de-de_karlsson-glow_tts M
de-de_eva_k-glow_tts F
de-de_rebecca_braunert_plunkett-glow_tts F
de-de_thorsten-glow_tts M
de-de_pavoque-glow_tts M
de-de_kerstin-glow_tts F
nl_nathalie-glow_tts F
nl_rdh-glow_tts M
nl_flemishguy-glow_tts M
nl_bart_de_leeuw-glow_tts M
sw_biblia_takatifu-glow_tts M
it-it_riccardo_fasol-glow_tts M
it-it_lisa-glow_tts F
fr-fr_siwis-glow_tts F
fr-fr_gilles_le_blanc-glow_tts M
fr-fr_tom-glow_tts M
es-es_carlfm-glow_tts M
es-es_karen_savage-glow_tts F
sv-se_talesyntese-glow_tts M
46 changes: 43 additions & 3 deletions larynx/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@
VOCODER_DIR_NAMES,
VOCODER_QUALITY,
VOICE_DOWNLOAD_NAMES,
VOICE_GENDERS,
download_voice,
get_voices_dirs,
load_voices_aliases,
load_voices_genders,
valid_voice_dir,
)
from larynx.wavfile import write as wav_write
Expand Down Expand Up @@ -504,11 +506,49 @@ async def api_process():
@app.route("/voices", methods=["GET"])
async def api_voices():
"""MaryTTS-compatible /voices endpoint"""

load_voices_genders()

# [voice] [language] [gender] [tech=hmm]
lines = []
for voice_id in get_voices():
lines.append(voice_id)

return "\n".join(lines)
# Search for downloaded voices/vocoders
for voices_dir in voices_dirs:
if not voices_dir.is_dir():
continue

# <LANGUAGE>/<VOICE>-<TTS_SYSTEM>
for lang_dir in voices_dir.iterdir():
if (not lang_dir.is_dir()) or (lang_dir.name in VOCODER_DIR_NAMES):
continue

# Voice
voice_lang = lang_dir.name
for voice_model_dir in lang_dir.iterdir():
if not valid_voice_dir(voice_model_dir):
continue

voice_name_tts = voice_model_dir.name
full_voice_name = f"{voice_lang}_{voice_name_tts}"
voice_name, tts_system = voice_name_tts.split("-", maxsplit=1)

voice_gender = "NA" # not available
gender_path = voice_model_dir / "GENDER"

if gender_path.is_file():
# Use GENDER file in voice directory
voice_gender = gender_path.read_text().strip()
else:
# Use value from VOICE_GENDERS file
voice_gender = VOICE_GENDERS.get(full_voice_name, voice_gender)

# Repeat voice for each quality level
for quality in VOCODER_QUALITY:
lines.append(
f"{voice_name};{quality} {voice_lang} {voice_gender} {tts_system}"
)

return "\n".join(sorted(lines))


@app.route("/version", methods=["GET"])
Expand Down
17 changes: 17 additions & 0 deletions larynx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
# voice -> <name>.tar.gz
VOICE_DOWNLOAD_NAMES: typing.Dict[str, str] = {}

# voice -> gender
VOICE_GENDERS: typing.Dict[str, str] = {}


def load_voices_aliases():
"""Load voice aliases from VOICES file"""
Expand All @@ -56,6 +59,20 @@ def load_voices_aliases():
VOICE_DOWNLOAD_NAMES[full_voice_name] = download_name


def load_voices_genders():
"""Load genders from VOICE_GENDERS file"""
if not VOICE_GENDERS:
# Load voice genders
with open(_DIR / "VOICE_GENDERS", "r", encoding="utf-8") as voices_file:
for line in voices_file:
line = line.strip()
if not line:
continue

full_voice_name, gender = line.split(" ", maxsplit=1)
VOICE_GENDERS[full_voice_name] = gender


def resolve_voice_name(voice_name: str) -> str:
"""Resolve voice name using aliases"""
load_voices_aliases()
Expand Down
1 change: 1 addition & 0 deletions local/de-de/eva_k-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/de-de/hokuspokus-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/de-de/karlsson-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/de-de/kerstin-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/de-de/pavoque-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/de-de/rebecca_braunert_plunkett-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/de-de/thorsten-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/blizzard_fls-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/blizzard_lessac-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/cmu_aew-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/cmu_ahw-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/cmu_aup-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/cmu_bdl-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/cmu_clb-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/cmu_eey-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/cmu_fem-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/cmu_jmk-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/cmu_ksp-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/cmu_ljm-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/cmu_lnh-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/cmu_rms-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/cmu_rxr-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/cmu_slp-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/cmu_slt-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/ek-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/glados-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/harvard-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/judy_bieber-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/kathleen-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/ljspeech-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/mary_ann-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/northern_english_male-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/scottish_english_male-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/en-us/southern_english_female-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/en-us/southern_english_male-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/es-es/carlfm-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/es-es/karen_savage-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/fr-fr/gilles_le_blanc-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/fr-fr/siwis-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/fr-fr/tom-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/it-it/lisa-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/it-it/riccardo_fasol-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/nl/bart_de_leeuw-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/nl/flemishguy-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/nl/nathalie-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/nl/rdh-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/ru-ru/hajdurova-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
F
1 change: 1 addition & 0 deletions local/ru-ru/minaev-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/ru-ru/nikolaev-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/sv-se/talesyntese-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
1 change: 1 addition & 0 deletions local/sw/biblia_takatifu-glow_tts/GENDER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
23 changes: 23 additions & 0 deletions scripts/get-genders.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail

# Directory of *this* script
this_dir="$( cd "$( dirname "$0" )" && pwd )"
src_dir="$(realpath "${this_dir}/..")"

local_dir="${src_dir}/local"

find "${local_dir}" -mindepth 2 -maxdepth 2 -type d | \
while read -r voice_dir;
do
voice_lang="$(dirname "${voice_dir}" | xargs basename)"
if [ "${voice_lang}" = 'hifi_gan' ] || [ "${voice_lang}" = 'waveglow' ]; then
continue;
fi

voice_name="$(basename "${voice_dir}")"
voice_gender="$(cat "${voice_dir}/GENDER")"

full_voice_name="${voice_lang}_${voice_name}"
echo "${full_voice_name}" "${voice_gender}"
done

0 comments on commit e03cf6c

Please sign in to comment.