From 560857c90e46489a8162b7516e15e73e56a36fb3 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Wed, 29 Jun 2022 15:56:00 -0400 Subject: [PATCH] Add MaryTTS-compatible /voices endpoint --- mimic3_http/app.py | 25 ++++++++++++++++++++++++- mimic3_tts/VERSION | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/mimic3_http/app.py b/mimic3_http/app.py index 83d7ecd..0f82bdc 100644 --- a/mimic3_http/app.py +++ b/mimic3_http/app.py @@ -269,7 +269,7 @@ async def api_voices(): return jsonify(voice_dicts) @app.route("/process", methods=["GET", "POST"]) - async def api_process(): + async def api_marytts_process(): """MaryTTS-compatible /process endpoint""" voice = args.voice @@ -305,6 +305,29 @@ async def api_process(): return Response(wav_bytes, mimetype="audio/wav") + @app.route("/voices", methods=["GET"]) + async def api_marytts_voices(): + """MaryTTS-compatible /voices endpoint""" + voices_by_key = {v.key: v for v in _MIMIC3.get_voices()} + sorted_voices = sorted(voices_by_key.values(), key=lambda v: v.key) + + # [voice] [language] [gender] [tech=hmm] + lines = [] + gender = "NA" # don't have this information for every speaker yet + tech = "vits" + + for voice in sorted_voices: + if voice.is_multispeaker: + # List each speaker separately + for speaker in voice.speakers: + lines.append( + f"{voice.key}#{speaker} {voice.language} {gender} {tech}" + ) + else: + lines.append(f"{voice.key} {voice.language} {gender} {tech}") + + return "\n".join(lines) + @app.route("/api/healthcheck", methods=["GET"]) async def api_healthcheck(): """Endpoint to check health status""" diff --git a/mimic3_tts/VERSION b/mimic3_tts/VERSION index ee1372d..7179039 100644 --- a/mimic3_tts/VERSION +++ b/mimic3_tts/VERSION @@ -1 +1 @@ -0.2.2 +0.2.3