Skip to content

Commit

Permalink
add json support to the TTS server api. This allows you to send a jso…
Browse files Browse the repository at this point in the history
…n request body with your text and will allow for longer texts that otherwise exceed the maximum http url length
  • Loading branch information
kikkia committed Jan 18, 2024
1 parent 5dcc16d commit 659629b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions TTS/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,19 @@ def details():
@app.route("/api/tts", methods=["GET", "POST"])
def tts():
with lock:
text = request.headers.get("text") or request.values.get("text", "")
speaker_idx = request.headers.get("speaker-id") or request.values.get("speaker_id", "")
language_idx = request.headers.get("language-id") or request.values.get("language_id", "")
style_wav = request.headers.get("style-wav") or request.values.get("style_wav", "")
try:
data = request.get_json()
text = data.get("text", "")
speaker_idx = data.get("speaker-id", "")
language_idx = data.get("language-id", "")
style_wav = data.get("style-wav", "")
except:
# Fallback to headers and form data if JSON data is not present
text = request.headers.get("text") or request.values.get("text", "")
speaker_idx = request.headers.get("speaker-id") or request.values.get("speaker_id", "")
language_idx = request.headers.get("language-id") or request.values.get("language_id", "")
style_wav = request.headers.get("style-wav") or request.values.get("style_wav", "")

style_wav = style_wav_uri_to_dict(style_wav)

print(f" > Model input: {text}")
Expand Down

0 comments on commit 659629b

Please sign in to comment.