[Frontend] Add configurable output sample rate to Speech API (#6553)

Signed-off-by: 郑倩倩 <2458983186@qq.com>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
AuFlowandHongsheng Liu authored and GitHub committed 2026-09-01 17:25:09 +08:00
1 parent a65e89cbd4
commit 49c6fc1540
12 files changed
+453 -14

No files matched your search

+7
View File
@@ -873,6 +873,13 @@ def assert_audio_speech_response(response: Any, request_config: dict[str, Any],
elif req_fmt == "wav" and response.audio_format:
assert req_fmt in response.audio_format
expected_sample_rate = request_config.get("sample_rate")
if expected_sample_rate is not None and req_fmt == "wav" and response.audio_bytes:
info = sf.info(io.BytesIO(response.audio_bytes))
assert info.samplerate == int(expected_sample_rate), (
f"Expected sample_rate={expected_sample_rate}, got {info.samplerate}"
)
if run_level in {"advanced_model", "full_model"}:
if req_fmt == "pcm" and response.audio_bytes:
min_hnr_db = float(request_config.get("min_hnr_db", _MIN_PCM_SPEECH_HNR_DB))