From d6e3f4cd101d63c62f4cb74849bef93ac0aec3e6 Mon Sep 17 00:00:00 2001 From: retoor Date: Sun, 19 Jan 2025 01:19:13 +0000 Subject: [PATCH] fix: add explicit None check for audio_content before decoding in tts function --- src/rspeech/gcloud.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rspeech/gcloud.py b/src/rspeech/gcloud.py index 38def7a..8d72ba0 100644 --- a/src/rspeech/gcloud.py +++ b/src/rspeech/gcloud.py @@ -104,6 +104,8 @@ async def tts(text:str ,google_project:str="lisa-448004", language_code:str="nl- response = await session.post(url, headers=headers, json=data) response_json = await response.json() audio_content = response_json.get("audioContent") + if not audio_content: + return file = pathlib.Path(str(uuid.uuid4()) + ".mp3") with file.open("wb") as audio_file: audio_file.write(base64.b64decode(audio_content.encode('latin1')))