Skip to content

Fix voice list fetching JSONDecodeError on HuggingFace redirect - #74

Open
AdamMagued wants to merge 1 commit into
mush42:mainfrom
AdamMagued:fix/voice-list-fetch-redirect
Open

AdamMagued wants to merge 1 commit into
mush42:mainfrom
AdamMagued:fix/voice-list-fetch-redirect

Conversation

@AdamMagued

Copy link
Copy Markdown

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) in voice_download.py when attempting std_resp.json().

Root Cause

HuggingFace changed the /resolve/ URLs (https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/voices.json and https://huggingface.co/datasets/mush42/piper-rt/resolve/main/voices.json) to issue HTTP 307 redirects to cache endpoints. The bundled mureq HTTP client defaults to max_redirects=None (no redirects followed), returning the 307 redirect message body instead of following the redirect to the target JSON content. Additionally, mureq's raise_for_status() treats 3xx codes as successful, causing .json() to be invoked on empty or non-JSON redirect response bodies.

Fix

  1. Updated PIPER_VOICE_LIST_URL and RT_VOICE_LIST_URL to use /raw/ endpoints instead of /resolve/, which return JSON payloads directly without redirects.
  2. Added max_redirects=5 to request.get(...) calls in get_available_voices() and to request.yield_response(...) in _do_download_file and _do_download_archive to ensure any CDN or server redirects are automatically followed.
  3. Added error handling around .json() calls in get_available_voices() to catch JSONDecodeError and ValueError gracefully, logging the failure and raising an informative RuntimeError.
  4. Added unit tests in tests/test_voice_download.py covering raw URLs, redirect parameter forwarding, and JSON decode error handling.

Fixes #68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] JSONDecodeError on empty response when fetching voice list

1 participant