Skip to main content

DashScope Realtime ASR & TTS SDK

Project description

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_chunk(b"...")  # 发送音频片段

实时语音合成(TTS)

from dashscope_realtime import DashScopeRealtimeTTS

async with DashScopeRealtimeTTS(api_key="your-api-key") as tts:
    await tts.send_text("Hello, DashScope!")  # 发送文本
    await tts.finish()  # 完成任务

特性

  • ✅ 全异步设计(async / await)
  • ✅ ASR 支持流式音频输入
  • ✅ TTS 支持流式音频输出
  • ✅ 自动重连 & 错误处理
  • ✅ 接口风格对齐 OpenAI Realtime
  • ✅ 方便集成任意异步 Python 项目

License

MIT License — see LICENSE for details.


Made with ❤️ by mikuh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dashscope_realtime-0.1.1.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dashscope_realtime-0.1.1-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file dashscope_realtime-0.1.1.tar.gz.

File metadata

  • Download URL: dashscope_realtime-0.1.1.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for dashscope_realtime-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e788dfa6bbbf801b509758f25c071edc3855d9890ba9e34979dfff86453dd7bc
MD5 bb3ad1228c22f37cca2d1bc8200a5a4c
BLAKE2b-256 b7c62905e0fa32da6edfb15db095780cbc28cbf84765c312bd4725bf5bae0f71

See more details on using hashes here.

File details

Details for the file dashscope_realtime-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dashscope_realtime-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d42c4661b7be9152d4de8dbc08c11dbe69f3c898bd431533dea9c74028f02ac5
MD5 90d8a5fe45e473862349bd5f48a8972a
BLAKE2b-256 3cd63fd5be55a5951e70da6a7efd377e4813df4d014d600c395d3e38b16bfbe5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page