Repository navigation
Fix voice list fetching JSONDecodeError on HuggingFace redirect - #74
Open
AdamMagued wants to merge 1 commit into
Open
AdamMagued wants to merge 1 commit into
AdamMagued wants to merge 1 commit into
Conversation
…nd redirect handling (mush42#68)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Users attempting to open the Voice Manager encounter a failure dialog ("Could not retrieve voice list. Please check your connection and try again.") due to an unhandled exception:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)invoice_download.pywhen attemptingstd_resp.json().Root Cause
HuggingFace changed the
/resolve/URLs (https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/voices.jsonandhttps://huggingface.co/datasets/mush42/piper-rt/resolve/main/voices.json) to issue HTTP 307 redirects to cache endpoints. The bundledmureqHTTP client defaults tomax_redirects=None(no redirects followed), returning the 307 redirect message body instead of following the redirect to the target JSON content. Additionally,mureq'sraise_for_status()treats 3xx codes as successful, causing.json()to be invoked on empty or non-JSON redirect response bodies.Fix
PIPER_VOICE_LIST_URLandRT_VOICE_LIST_URLto use/raw/endpoints instead of/resolve/, which return JSON payloads directly without redirects.max_redirects=5torequest.get(...)calls inget_available_voices()and torequest.yield_response(...)in_do_download_fileand_do_download_archiveto ensure any CDN or server redirects are automatically followed..json()calls inget_available_voices()to catchJSONDecodeErrorandValueErrorgracefully, logging the failure and raising an informativeRuntimeError.tests/test_voice_download.pycovering raw URLs, redirect parameter forwarding, and JSON decode error handling.Fixes #68