feat: Add API endpoint for model load status (infer_loaded_voice) #2720
+28
−0
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.
Pull request checklist
The PR has a proper title. Use Semantic Commit Messages.
Make sure this is ready to be merged into the relevant branch.
Ensure you can run the codes you submitted succesfully. These submissions will be prioritized for review:
Introduce more convenient user operations.
PR type
Description
This PR introduces a new API endpoint to check the current status of the model loading
process (
infer_loaded_voice).Rationale and Value (Operational Improvements)
This new API provides a quick, non-intrusive way for external tools to confirm the model's status,
leading to significant operational improvements:
attempt conversion and immediately hit a critical pipeline error. This API allows checking
first, completely preventing these hard errors.
infer_change_voicebefore everyconversion to guarantee the model is loaded, even if it's already active. This generates excessive
console logs which obscure critical error messages. The
infer_loaded_voicecheck is much faster and doesn't generate logs, preserving console clarity.than unconditionally reloading the model via
infer_change_voice.changed (e.g., by the WebUI), eliminating the need to unnecessarily reload the model every time.
Detailed Changes
1. State Tracking (modules.py)
self.loaded_model_id = sidinside the model loading logic to persistently track the currently loaded model ID. This minimal change is necessary to enable status reporting.2. API Endpoint Addition (infer-web.py)
infer_loaded_voiceAPI endpoint using a hidden Gradio button click event.loaded_model_idand returns the status as a JSON object to the client.i18n()for proper internationalization compatibility.What will it affect
infer-web.py,modules.py). No changes to core algorithms or existing APIs.Screenshot