fix: Sprachausgabe ohne Stimme und Studio-Fehler sauber melden (#1146)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GmHhg6k5Hxh8GpVW7od4Di
This commit is contained in:
@ -265,6 +265,17 @@ async fn forward_to(
|
||||
// Grundlage steht immer vor Persona und vor Nachrichten des Clients; API-Personas gibt es nicht.
|
||||
prepend_basis(&mut request, &basis)?;
|
||||
}
|
||||
// Base-Modelle klonen eine gespeicherte Stimme: ohne `voice` gleich ablehnen, bevor das Modell lädt.
|
||||
if path == "/v1/audio/speech"
|
||||
&& plan.engine_name == "tts"
|
||||
&& crate::ui::chat::voice_art(&plan.model_path.to_string_lossy()) == "gespeichert"
|
||||
&& !request
|
||||
.get("voice")
|
||||
.and_then(Value::as_str)
|
||||
.is_some_and(|v| !v.trim().is_empty())
|
||||
{
|
||||
return Err(ApiError::speech_voice_required());
|
||||
}
|
||||
slot.lock().unwrap_or_else(|e| e.into_inner()).metric_model = Some(plan.model.clone());
|
||||
|
||||
let waited = std::time::Instant::now();
|
||||
@ -351,6 +362,16 @@ async fn forward_to(
|
||||
// Sprachausgabe: Das Studio schickt die Kopfzeilen (200), bevor es Ton erzeugt hat, und bricht danach
|
||||
// bei einem Fehler ab. Ohne diese Prüfung sieht das Protokoll „200“ und der Browser bleibt stumm
|
||||
// (→ #1109). Auf das erste Stück wird deshalb gewartet, bevor die Antwort beginnt.
|
||||
if path == "/v1/audio/speech" && !status.is_success() {
|
||||
// Der Fehlertext des Studios enthält Pfade und Programmtext: nur Status ins Log, nichts davon zum Client.
|
||||
tracing::warn!(
|
||||
modell = %clip(&model),
|
||||
ziel = %endpoint.base_url,
|
||||
status = status.as_u16(),
|
||||
"Das Studio hat die Sprachanfrage abgelehnt"
|
||||
);
|
||||
return Err(ApiError::speech_rejected(status.is_client_error()));
|
||||
}
|
||||
if path == "/v1/audio/speech" && status.is_success() {
|
||||
response_stream = match first_chunk(response_stream).await {
|
||||
Ok(restored) => restored,
|
||||
|
||||
Reference in New Issue
Block a user