refac/fix: azure audio escape

This commit is contained in:
Timothy Jaeryang Baek 2025-10-01 23:01:08 -05:00
parent c0d3e70296
commit 2e75c6dbdf

View file

@ -3,6 +3,7 @@ import json
import logging import logging
import os import os
import uuid import uuid
import html
from functools import lru_cache from functools import lru_cache
from pydub import AudioSegment from pydub import AudioSegment
from pydub.silence import split_on_silence from pydub.silence import split_on_silence
@ -458,7 +459,7 @@ async def speech(request: Request, user=Depends(get_verified_user)):
try: try:
data = f"""<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="{locale}"> data = f"""<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="{locale}">
<voice name="{language}">{payload["input"]}</voice> <voice name="{language}">{html.escape(payload["input"])}</voice>
</speak>""" </speak>"""
timeout = aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT) timeout = aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT)
async with aiohttp.ClientSession( async with aiohttp.ClientSession(