Skip to content

Commit

Permalink
Websocket support for word_timestamps that don't have the 'data' field (
Browse files Browse the repository at this point in the history
#19)

This is a fix for this issue #18 

It provides a simple safety check for the presence of the "data" field
in a response before trying to access it.
  • Loading branch information
robbie-anam authored Feb 3, 2025
1 parent e3fbd4a commit 82b7061
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cartesia/_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def send(
raise RuntimeError(f"Error generating audio:\n{response['error']}")
if response["done"]:
break
if response["data"]:
if "data" in response and response["data"]:
yield self._websocket._convert_response(
response=response, include_context_id=True
)
Expand All @@ -138,7 +138,7 @@ def send(
raise RuntimeError(f"Error generating audio:\n{response['error']}")
if response["done"]:
break
if response["data"]:
if "data" in response and response["data"]:
yield self._websocket._convert_response(
response=response, include_context_id=True
)
Expand Down

0 comments on commit 82b7061

Please sign in to comment.