mofa-fm: pre-validate voice against ominix-api /v1/voices#48
Open
ymote wants to merge 1 commit into
Open
Conversation
fm_tts and fm_voice_list now cross-check mofa-fm's local catalog against what ominix-api will actually synthesise. fm_tts: before POSTing to /v1/audio/tts/qwen3, fetch /v1/voices. If the requested voice isn't registered (and isn't the empty server-default), return an error up-front listing the available voices. This plugs the mini2 yangmi symptom: fm-fm had yangmi locally, ominix-api had no voices.json entries, and /v1/audio/tts/qwen3 silently substituted a different preset so the user heard the wrong voice. When /v1/voices is unreachable, fall through to the TTS call (better to try than block on a transient outage). fm_voice_list: intersect catalog with /v1/voices and annotate each entry as registered, orphaned_in_catalog, or ominix_only. Append a summary like "N registered, M orphaned (not synth-capable on this ominix-api)". If /v1/voices is unreachable, emit a warning banner but still render the catalog. Pure helpers (parse_registered_voices, validate_requested_voice, classify_voice_entries, voice_in_registry) are unit tested; the unreachable path uses a closed TCP port to exercise graceful degradation without standing up an HTTP server.
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.
Summary
fm_ttsnow callsGET /v1/voicesbefore hitting/v1/audio/tts/qwen3and rejects unknown voices up-front (with the list of available voices and a hint to usefm_voice_save).fm_voice_listintersects the local catalog with/v1/voices, annotates each entry asregistered/orphaned_in_catalog/ominix_only, and appends a summary like"N registered, M orphaned"./v1/voicesis unreachable —fm_ttsfalls through to the TTS call,fm_voice_listemits a warning banner but still returns the catalog.Symptom this fixes
On octos mini2 a user ran
fm_voice_listand sawyangmi+douwentao(saved in mofa-fm's local voices.json).fm_tts({voice: "yangmi"})succeeded, but the audio was clearly notyangmi. Root cause: ominix-api's~/.OminiX/models/voices.jsonon mini2 was empty (/v1/voicesreturned{"voices": []})./v1/audio/tts/qwen3silently substituted a default preset, so the tool reported success but delivered the wrong voice. After this change, the mismatch is surfaced before any synthesis happens, andfm_voice_listflags the offending entry asorphaned_in_catalog.Test plan
cargo test -p mofa-fm— 21 tests pass (7 pre-existing + 14 new).cargo build --release -p mofa-fm— clean.cargo fmt --all -- --check— clean.should_pre_validate_voice_and_reject_unknownshould_pass_through_when_voice_registeredshould_pass_through_when_voice_registered_case_insensitiveshould_allow_empty_voice_as_server_defaultshould_list_available_when_registry_is_emptyshould_fall_through_when_voices_endpoint_unreachable(uses a closed TCP port so no HTTP server is needed in CI)should_intersect_catalog_with_registered_in_fm_voice_listshould_classify_empty_registered_as_all_orphanedshould_match_voices_case_insensitively_in_classifiershould_parse_voices_response_and_include_aliasesshould_handle_empty_voices_responseshould_error_on_missing_voices_keyshould_error_on_invalid_jsonvoice_in_registry_is_case_insensitivefm_voice_listshould now annotateyangmiasorphaned_in_catalog, andfm_tts({voice: "yangmi"})should return the "not registered" error instead of silently producing the wrong voice.Constraints respected
./skill_binary <tool_name>with JSON stdin/stdout).fm_voice_list; warnings surface but the call still succeeds.