Skip to content

Commit

Permalink
Ensure aliases is not a set for JSON serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
synesthesiam committed Nov 4, 2022
1 parent 15b83ea commit 7292e82
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions mimic3_http/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<path:filename>", methods=["GET"])
async def img(filename) -> Response:
"""Image static endpoint."""
Expand Down Expand Up @@ -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"])
Expand Down

0 comments on commit 7292e82

Please sign in to comment.