fix(tts): leerer Audio-Strom des Studios wird zu 502 (#1109), nicht installierte Studio-Modelle werden ausgeblendet und abgelehnt (#1110), Version 0.1.10-rc5
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GmHhg5YdSXUmKzjHCaEWQp
This commit is contained in:
@ -35,6 +35,11 @@ pub struct StudioConfig {
|
||||
pub base_url: String,
|
||||
/// Wie lange die Erreichbarkeitsprüfung beim Start höchstens dauert.
|
||||
pub ready_timeout_secs: u64,
|
||||
/// Ordner mit den Modellen des Studios (auf srv04 `/srv/models/audio/qwen-tts`, im Container
|
||||
/// `/app/local-models`). Ist er gesetzt, kennt das Gateway nur Modelle, deren Ordner dort liegt:
|
||||
/// `discover` blendet nicht installierte Modelle aus (das Studio nennt sie trotzdem, → #1110),
|
||||
/// und `start` lehnt sie ab, statt Anfragen ins Leere laufen zu lassen. Ungesetzt: keine Prüfung.
|
||||
pub local_models_dir: Option<std::path::PathBuf>,
|
||||
}
|
||||
|
||||
impl Default for StudioConfig {
|
||||
@ -42,6 +47,7 @@ impl Default for StudioConfig {
|
||||
Self {
|
||||
base_url: "http://127.0.0.1:8862".to_string(),
|
||||
ready_timeout_secs: 15,
|
||||
local_models_dir: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,6 +73,15 @@ impl StudioEngine {
|
||||
}
|
||||
}
|
||||
|
||||
/// Ist das Modell (zum Beispiel `Qwen/Qwen3-TTS-12Hz-1.7B-Base`) im Modellordner vorhanden?
|
||||
/// Ohne gesetzten Ordner ist es unbekannt, dann gilt es als vorhanden.
|
||||
fn installed(&self, id: &str) -> bool {
|
||||
match &self.config.local_models_dir {
|
||||
None => true,
|
||||
Some(dir) => dir.join(id.rsplit('/').next().unwrap_or(id)).is_dir(),
|
||||
}
|
||||
}
|
||||
|
||||
fn base(&self) -> &str {
|
||||
self.config.base_url.trim_end_matches('/')
|
||||
}
|
||||
@ -202,7 +217,9 @@ impl Engine for StudioEngine {
|
||||
.map_err(|e| AdapterError::Spawn(format!("Studio-Antwort nicht lesbar: {e}")))?;
|
||||
let json: Value = serde_json::from_slice(&bytes)
|
||||
.map_err(|e| AdapterError::Spawn(format!("Studio-Antwort kein JSON: {e}")))?;
|
||||
Ok(models_from(&json))
|
||||
let mut models = models_from(&json);
|
||||
models.retain(|m| self.installed(&m.path.to_string_lossy()));
|
||||
Ok(models)
|
||||
}
|
||||
|
||||
async fn start(&self, profile: &ProfileSpec) -> Result<InstanceHandle> {
|
||||
@ -212,6 +229,16 @@ impl Engine for StudioEngine {
|
||||
"kein Modellname des Studios angegeben".to_string(),
|
||||
));
|
||||
}
|
||||
if !self.installed(&model) {
|
||||
return Err(AdapterError::InvalidProfile(format!(
|
||||
"Das Modell {model} ist im Studio nicht installiert (Ordner fehlt in {})",
|
||||
self.config
|
||||
.local_models_dir
|
||||
.as_deref()
|
||||
.map(|d| d.display().to_string())
|
||||
.unwrap_or_default()
|
||||
)));
|
||||
}
|
||||
let timeout = Duration::from_secs(self.config.ready_timeout_secs);
|
||||
if !self.reachable(timeout).await {
|
||||
return Err(AdapterError::NotReady {
|
||||
@ -310,6 +337,7 @@ mod tests {
|
||||
StudioEngine::new(StudioConfig {
|
||||
base_url: format!("http://127.0.0.1:{port}/"),
|
||||
ready_timeout_secs: 3,
|
||||
local_models_dir: None,
|
||||
})
|
||||
}
|
||||
|
||||
@ -385,4 +413,33 @@ mod tests {
|
||||
Err(AdapterError::InvalidProfile(_))
|
||||
));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn nicht_installierte_modelle_werden_ausgeblendet_und_abgelehnt() {
|
||||
// Nur der Ordner der Base-Variante liegt im Modellordner (→ #1110).
|
||||
let dir = std::env::temp_dir().join(format!("nexus-studio-test-{}", std::process::id()));
|
||||
std::fs::create_dir_all(dir.join("Qwen3-TTS-12Hz-1.7B-Base")).unwrap();
|
||||
let port = fake_studio().await;
|
||||
let e = StudioEngine::new(StudioConfig {
|
||||
base_url: format!("http://127.0.0.1:{port}/"),
|
||||
ready_timeout_secs: 3,
|
||||
local_models_dir: Some(dir.clone()),
|
||||
});
|
||||
let found = e.discover().await.unwrap();
|
||||
assert_eq!(found.len(), 1, "nur das installierte Modell bleibt");
|
||||
assert_eq!(found[0].name, "Qwen3-TTS-12Hz-1.7B-Base");
|
||||
assert!(
|
||||
e.start(&profile("Qwen/Qwen3-TTS-12Hz-1.7B-Base"))
|
||||
.await
|
||||
.is_ok()
|
||||
);
|
||||
match e
|
||||
.start(&profile("Qwen/Qwen3-TTS-12Hz-0.6B-CustomVoice"))
|
||||
.await
|
||||
{
|
||||
Err(AdapterError::InvalidProfile(m)) => assert!(m.contains("nicht installiert")),
|
||||
other => panic!("erwartet InvalidProfile, bekommen {other:?}"),
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user