Skip to content

Commit

Permalink
Add MaryTTS-compatible /voices endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
synesthesiam committed Jun 29, 2022
1 parent 61c2aa5 commit 560857c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 24 additions & 1 deletion mimic3_http/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion mimic3_tts/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.2
0.2.3

0 comments on commit 560857c

Please sign in to comment.