Skip to content

Fix/jigsawstack-python-audio-tts #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ venv/
.pytest_cache/
jigsawstack.egg-info/

__pycache__/
/.pytest_cache/
/.vscode/
/.idea/


*.ipynb_checkpoints/
*.ipynb

.env
build/
dist/
Expand Down
5 changes: 4 additions & 1 deletion jigsawstack/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def perform(self) -> Union[T, None]:

# this is a safety net, if we get here it means the JigsawStack API is having issues
# and most likely the gateway is returning htmls
if "application/json" not in resp.headers["content-type"]:
if "application/json" not in resp.headers["content-type"] and "audio/wav" not in resp.headers["content-type"]:
raise_for_code_and_type(
code=500,
message="Failed to parse JigsawStack API response. Please try again.",
Expand All @@ -72,6 +72,9 @@ def perform(self) -> Union[T, None]:
err=error.get("error"),
)

if "audio/wav" in resp.headers["content-type"]:
return cast(T, resp) # we return the response object, instead of the json

return cast(T, resp.json())

def perform_file(self) -> Union[T, None]:
Expand Down