From 7292e821e93596f793dc4644fb355663be996488 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Fri, 4 Nov 2022 14:04:08 -0500 Subject: [PATCH] Ensure aliases is not a set for JSON serialization --- mimic3_http/app.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/mimic3_http/app.py b/mimic3_http/app.py index 12f844b..ea118d0 100644 --- a/mimic3_http/app.py +++ b/mimic3_http/app.py @@ -132,17 +132,6 @@ async def text_to_wav(params: TextToWavParams, no_cache: bool = False) -> bytes: def _to_bool(s: str) -> bool: return s.strip().lower() in {"true", "1", "yes", "on"} - class VoiceEncoder(json.JSONEncoder): - """Encode a voice to JSON""" - - def default(self, o): - if isinstance(o, set): - return list(o) - - return json.JSONEncoder.default(self, o) - - app.json_encoder = VoiceEncoder # type: ignore - @app.route("/img/", methods=["GET"]) async def img(filename) -> Response: """Image static endpoint.""" @@ -267,6 +256,11 @@ async def api_voices(): sample_text = re.sub(r"\s+", " ", sample_text) voice_dict["sample_text"] = sample_text + # Ensure aliases is not a set for JSON serialization + aliases = voice_dict.get("aliases") + if aliases is not None: + voice_dict["aliases"] = list(aliases) + return jsonify(voice_dicts) @app.route("/process", methods=["GET", "POST"])