From 9d581bbe8cb8233dcd94680e53e34d55ddba706e Mon Sep 17 00:00:00 2001 From: Linghong Date: Fri, 7 Aug 2026 03:35:08 +0000 Subject: [PATCH] =?UTF-8?q?=E9=94=81=E5=AE=9A=20ElevenLabs=20=E5=8D=95?= =?UTF-8?q?=E6=AC=A1=E8=AF=B7=E6=B1=82=E4=B8=8E=E9=9F=B3=E9=A2=91=E6=97=B6?= =?UTF-8?q?=E9=95=BF=E8=BE=B9=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 显式禁用 ElevenLabs 专用 HTTP 客户端重试。 增加真实 MP3 帧的 600 秒上下边界回归测试。 --- .../crates/platform-audio/src/elevenlabs.rs | 1 + server-rs/crates/platform-audio/src/mp3.rs | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/server-rs/crates/platform-audio/src/elevenlabs.rs b/server-rs/crates/platform-audio/src/elevenlabs.rs index 4ef1ea57f..1a69a3916 100644 --- a/server-rs/crates/platform-audio/src/elevenlabs.rs +++ b/server-rs/crates/platform-audio/src/elevenlabs.rs @@ -50,6 +50,7 @@ pub fn build_elevenlabs_audio_http_client( settings: &ElevenLabsAudioSettings, ) -> Result { reqwest::Client::builder() + .retry(reqwest::retry::never()) .timeout(std::time::Duration::from_millis( settings.request_timeout_ms.max(1), )) diff --git a/server-rs/crates/platform-audio/src/mp3.rs b/server-rs/crates/platform-audio/src/mp3.rs index 7e0fc736f..fc7931903 100644 --- a/server-rs/crates/platform-audio/src/mp3.rs +++ b/server-rs/crates/platform-audio/src/mp3.rs @@ -92,6 +92,19 @@ mod tests { use super::*; + const REAL_MP3_FRAME_OFFSET: usize = 1_374; + const REAL_MP3_FRAME_LENGTH: usize = 156; + + fn repeated_real_mp3_frame(frame_count: usize) -> Bytes { + let fixture = base64::engine::general_purpose::STANDARD + .decode(include_str!("../tests/fixtures/vbr-id3.mp3.base64").trim()) + .expect("VBR MP3 fixture should decode"); + let frame = &fixture[REAL_MP3_FRAME_OFFSET..REAL_MP3_FRAME_OFFSET + REAL_MP3_FRAME_LENGTH]; + assert_eq!(&frame[..4], &[0xff, 0xfb, 0x30, 0xc4]); + + Bytes::from(frame.repeat(frame_count)) + } + #[test] fn duration_guard_uses_only_the_independent_six_hundred_second_limit() { for duration in [0.001, 30.5, 60.0, 600.0] { @@ -128,6 +141,20 @@ mod tests { assert!((0.39..=0.46).contains(&duration), "duration={duration}"); } + #[test] + fn probe_enforces_the_six_hundred_second_boundary_on_real_mp3_frames() { + let accepted_duration = probe_mp3_duration_seconds(repeated_real_mp3_frame(22_968)) + .expect("real MP3 just below 600 seconds should pass"); + assert!( + (599.9..=600.0).contains(&accepted_duration), + "duration={accepted_duration}" + ); + + let error = probe_mp3_duration_seconds(repeated_real_mp3_frame(22_969)) + .expect_err("real MP3 just above 600 seconds should fail"); + assert!(error.contains("不超过 600 秒"), "error={error}"); + } + #[test] fn probe_rejects_non_mp3_and_empty_payloads() { for payload in [Bytes::new(), Bytes::from_static(b"error")] {