DashScope Realtime
🚀 Async Python SDK for DashScope Realtime ASR (Speech Recognition) & TTS (Speech Synthesis)
简介
DashScope Realtime 是一个支持异步 WebSocket 的 Python SDK,适配阿里 DashScope 的实时流式语音识别(ASR)和流式语音合成(TTS)能力。
为什么开发这个项目?
阿里云官方提供的DashScope Python SDK 是同步 WebSocket 实现,存在以下问题:
-
不支持 async / await
-
回调不在同一事件循环,无法直接使用 async 上下文
-
与 OpenAI API 生态的开源项目(如 FastAPI、Chainlit)不兼容
为了解决这些问题,本项目基于 DashScope WebSocket API,重新实现了异步版本的 ASR(语音识别)与 TTS(语音合成)SDK,具备:
-
纯异步 API 设计
-
支持流式音频输入输出
-
支持上下文无感知切换
-
更易接入 OpenAI API 风格的开源项目
安装
pip install dashscope-realtime
快速上手
实时语音识别(ASR)
from dashscope_realtime import DashScopeRealtimeASR
async with DashScopeRealtimeASR(api_key="your-api-key") as asr:
await asr.send_audio(b"...") # 发送音频片段
实时语音合成(TTS)
from dashscope_realtime import DashScopeRealtimeTTS
async with DashScopeRealtimeTTS(api_key="your-api-key") as tts:
await tts.say("Hello, DashScope!") # 发送文本
await tts.finish() # 完成任务
特性
- ✅ 全异步设计(async / await)
- ✅ ASR 支持流式音频输入
- ✅ TTS 支持流式音频输出
- ✅ 自动重连 & 错误处理
- ✅ 接口风格对齐 OpenAI Realtime
- ✅ 方便集成任意异步 Python 项目
License
MIT License — see LICENSE for details.
Made with ❤️ by mikuh
Metadata
Release files for dashscope-realtime 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dashscope_realtime-0.1.8.tar.gz | 22.6 kB | Without provenance | Details for dashscope_realtime-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dashscope_realtime-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for dashscope_realtime-0.1.8-py3-none-any.whl |
Total release size: 49.2 kB
Release files / dashscope_realtime-0.1.8.tar.gz
| Download URL | dashscope_realtime-0.1.8.tar.gz |
|---|---|
| Size | 22.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2943a27cdf8c12b25f105f9d5f125cd1e43308092132109baf41b1852dc4d8d
|
|
BLAKE2b-256 checksum How to use checksums |
d1b712eaa3d6174d834b6c30d74557a45d4717ad1307c40093f3b5dbcee5bad2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Release files / dashscope_realtime-0.1.8-py3-none-any.whl
| Download URL | dashscope_realtime-0.1.8-py3-none-any.whl |
|---|---|
| Size | 26.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1eccc60c3820b244f6de06bc9081d985614f651191e007d755378447cf714f3
|
|
BLAKE2b-256 checksum How to use checksums |
68f86fee89885782e7130b032a4b406d1eb0e80778626308b807c7b64b1e4464
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Security for dashscope-realtime 0.1.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.