feat(qwen-audio): add Alibaba Cloud Qwen-Audio Realtime service integration

- Introduced Qwen-Audio Realtime service for speech-to-speech processing in Pipecat.
- Updated interface catalog to include Qwen-Audio Realtime capabilities.
- Enhanced model resource testing to support new service.
- Added configuration options for audio sample rates and turn detection modes.
- Updated documentation to reflect integration details and usage instructions.
This commit is contained in:
Xin Wang
2026-07-21 15:57:43 +08:00
parent f027ed99b7
commit 774825593d
10 changed files with 866 additions and 19 deletions

View File

@@ -62,7 +62,18 @@ async def test_model_resource(
detail="鉴权字段和连接参数完整,请在语音测试页验证签名及音频链路",
)
if interface_type == "stepfun-realtime":
return await _test_stepfun_realtime(values, secrets)
return await _test_realtime_websocket(
values,
secrets,
provider="StepFun",
)
if interface_type == "qwen-audio-realtime":
return await _test_realtime_websocket(
values,
secrets,
provider="Qwen-Audio",
extra_headers={"x-dashscope-dataInspection": "disable"},
)
if capability == "Realtime":
return ModelResourceTestResult(
ok=False,
@@ -158,8 +169,12 @@ async def test_model_resource(
)
async def _test_stepfun_realtime(
values: dict, secrets: dict
async def _test_realtime_websocket(
values: dict,
secrets: dict,
*,
provider: str,
extra_headers: dict[str, str] | None = None,
) -> ModelResourceTestResult:
api_url = str(values.get("apiUrl") or "")
model_id = str(values.get("modelId") or "")
@@ -171,11 +186,13 @@ async def _test_stepfun_realtime(
(parts.scheme, parts.netloc, parts.path, urlencode(query), parts.fragment)
)
started = time.perf_counter()
headers = {"Authorization": f"Bearer {api_key}"}
headers.update(extra_headers or {})
try:
async with websocket_connect(
url,
additional_headers={"Authorization": f"Bearer {api_key}"},
additional_headers=headers,
open_timeout=TEST_TIMEOUT_SECONDS,
close_timeout=2,
) as websocket:
@@ -194,7 +211,7 @@ async def _test_stepfun_realtime(
ok=True,
latency_ms=round((time.perf_counter() - started) * 1000),
message="Realtime 连接成功",
detail="StepFun 返回 session.created",
detail=f"{provider} 返回 session.created",
)
except TimeoutError:
return ModelResourceTestResult(
@@ -211,6 +228,6 @@ async def _test_stepfun_realtime(
return ModelResourceTestResult(
ok=False,
latency_ms=round((time.perf_counter() - started) * 1000),
message="无法连接到 StepFun Realtime",
message=f"无法连接到 {provider} Realtime",
detail=detail[:300],
)