Skip to content

Commit cbed9ae

Browse files
author
zhansheng.lzs
committed
feat(v2): mark the 2.0 audio API as preview
client.audio now mounts lazily and emits a one-time FutureWarning on first access; Audio/AsyncAudio docstrings and the examples READMEs carry the same preview note.
1 parent 771993e commit cbed9ae

4 files changed

Lines changed: 54 additions & 6 deletions

File tree

‎dashscope/v2/client.py‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from pathlib import Path
1212
from typing import Any, Dict, Mapping, Optional, Union
13+
import warnings
1314

1415
import httpx
1516

@@ -116,14 +117,33 @@ def __init__(
116117
self.models = Models(self)
117118
self.images = Images(self)
118119
self.videos = Videos(self)
119-
self.audio = Audio(self)
120+
self._audio = None
120121
self.fine_tunes = FineTunes(self)
121122
self.deployments = Deployments(self)
122123
self.rl = Rl(self)
123124
self.apps = Apps(self)
124125
self.tingwu = TingWu(self)
125126
self._agentstudio = None
126127

128+
@property
129+
def audio(self) -> "Audio":
130+
"""Audio capabilities (lazily mounted).
131+
132+
Preview: the 2.0 audio API surface is not final and may change
133+
in a future release.
134+
"""
135+
if self._audio is None:
136+
warnings.warn(
137+
"dashscope 2.0 audio API is a preview and may change "
138+
"in a future release.",
139+
FutureWarning,
140+
stacklevel=2,
141+
)
142+
self._audio = Audio(self)
143+
audio = self._audio
144+
assert audio is not None
145+
return audio
146+
127147
@property
128148
def reinforcement_learning(self) -> "Rl":
129149
"""Long-form alias for ``client.rl``."""
@@ -338,14 +358,33 @@ def __init__(
338358
self.models = AsyncModels(self)
339359
self.images = AsyncImages(self)
340360
self.videos = AsyncVideos(self)
341-
self.audio = AsyncAudio(self)
361+
self._audio = None
342362
self.fine_tunes = AsyncFineTunes(self)
343363
self.deployments = AsyncDeployments(self)
344364
self.rl = AsyncRl(self)
345365
self.apps = AsyncApps(self)
346366
self.tingwu = AsyncTingWu(self)
347367
self._agentstudio = None
348368

369+
@property
370+
def audio(self) -> "AsyncAudio":
371+
"""Audio capabilities (lazily mounted).
372+
373+
Preview: the 2.0 audio API surface is not final and may change
374+
in a future release.
375+
"""
376+
if self._audio is None:
377+
warnings.warn(
378+
"dashscope 2.0 audio API is a preview and may change "
379+
"in a future release.",
380+
FutureWarning,
381+
stacklevel=2,
382+
)
383+
self._audio = AsyncAudio(self)
384+
audio = self._audio
385+
assert audio is not None
386+
return audio
387+
349388
@property
350389
def reinforcement_learning(self) -> "AsyncRl":
351390
"""Long-form alias for ``client.rl``."""

‎dashscope/v2/resources/audio/__init__.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@
7878

7979

8080
class Audio:
81+
"""Sync audio surface.
82+
83+
Preview: the 2.0 audio API surface is not final and may change in
84+
a future release.
85+
"""
86+
8187
def __init__(self, client) -> None:
8288
self.asr = Asr(client)
8389
self.tts = Tts(client)
@@ -95,6 +101,9 @@ class AsyncAudio:
95101
Only batch transcription is exposed here; the ws realtime resources
96102
(``asr.recognize``, ``tts``, ``realtime``) are sync-only by design
97103
(design doc M3 3.5).
104+
105+
Preview: the 2.0 audio API surface is not final and may change in
106+
a future release.
98107
"""
99108

100109
def __init__(self, client) -> None:

‎examples/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ Uniform style: `client = dashscope.Client()` (reads the key from the `DASHSCOPE_
9393
| `text_generation/chat.py` | Text generation: one-line `dashscope.chat()`, non-streaming, streaming (text_stream) |
9494
| `text_generation/tokenization.py` | Token counting |
9595
| `multimodal_vision/multimodal_chat.py` | Multimodal chat (qwen-vl image understanding) |
96-
| `audio_speech/audio_tts.py` | Speech synthesis (one-shot + streaming) |
97-
| `audio_speech/audio_asr.py` | Batch speech recognition |
96+
| `audio_speech/audio_tts.py` | Speech synthesis (one-shot + streaming); 2.0 audio API is a preview and may change |
97+
| `audio_speech/audio_asr.py` | Batch speech recognition; 2.0 audio API is a preview and may change |
9898
| `audio_speech/tingwu.py` | TingWu offline tasks and realtime sessions |
9999
| `image_video_synthesis/images.py` | Image generation: one-call generate-and-wait + the manual jobs flow |
100100
| `image_video_synthesis/videos.py` | Video generation: one-call generate-and-wait + the manual jobs flow |

‎examples/README_zh.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ examples/
9393
| `text_generation/chat.py` | 文本生成:一行 `dashscope.chat()`、非流式、流式(text_stream) |
9494
| `text_generation/tokenization.py` | token 计数 |
9595
| `multimodal_vision/multimodal_chat.py` | 多模态对话(qwen-vl 图像理解) |
96-
| `audio_speech/audio_tts.py` | 语音合成(一次性 + 流式) |
97-
| `audio_speech/audio_asr.py` | 批量语音识别 |
96+
| `audio_speech/audio_tts.py` | 语音合成(一次性 + 流式);2.0 audio API 为预览,后续可能变更 |
97+
| `audio_speech/audio_asr.py` | 批量语音识别;2.0 audio API 为预览,后续可能变更 |
9898
| `audio_speech/tingwu.py` | 听悟离线任务与实时会话 |
9999
| `image_video_synthesis/images.py` | 图像生成:一键生成并等待 + 手动 jobs 流程 |
100100
| `image_video_synthesis/videos.py` | 视频生成:一键生成并等待 + 手动 jobs 流程 |

0 commit comments

Comments
 (0)