You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit eb2c60e
Browse filesBrowse the repository at this point in the historyBrowse files
@@ -578,6 +602,24 @@ if rsp.status_code == HTTPStatus.OK:
578
602
print(result.url)
579
603
```
580
604
605
+
`call` already blocks until the task completes; submit without blocking and poll separately with `async_call` + `wait`:
606
+
607
+
```python
608
+
from dashscope import ImageSynthesis
609
+
610
+
task = ImageSynthesis.async_call(
611
+
model="wanx2.1-t2i-turbo",
612
+
prompt="a flower shop with delicate windows and a wooden door",
613
+
n=1,
614
+
size="1024*1024",
615
+
)
616
+
print(task.output.task_id)
617
+
618
+
rsp = ImageSynthesis.wait(task)
619
+
for result in rsp.output.results:
620
+
print(result.url)
621
+
```
622
+
581
623
`sync_call` (currently only for `wan2.2-t2i-flash`/`wan2.2-t2i-plus`) returns the result directly instead of polling an async task:
582
624
583
625
```python
@@ -696,6 +738,31 @@ with open("output.wav", "wb") as f:
696
738
f.write(result.get_audio_data())
697
739
```
698
740
741
+
`SpeechSynthesisResult` also exposes sentence-level timestamps and the raw task response, useful for e.g. subtitle sync:
742
+
743
+
```python
744
+
print(result.get_timestamps()) # per-sentence begin/end times
745
+
print(result.get_response()) # the underlying SpeechSynthesisResponse (status, request_id, ...)
746
+
```
747
+
748
+
For streaming instead of a single blocking call, subclass `ResultCallback` and pass it as `callback=`; `on_event` receives each `SpeechSynthesisResult` chunk as audio is generated:
749
+
750
+
```python
751
+
from dashscope.audio.tts import SpeechSynthesizer, ResultCallback
752
+
753
+
classCallback(ResultCallback):
754
+
defon_event(self, result) -> None:
755
+
withopen("output.wav", "ab") as f:
756
+
f.write(result.get_audio_frame())
757
+
758
+
SpeechSynthesizer.call(
759
+
model="cosyvoice-v1",
760
+
text="Hello, Bailian.",
761
+
format=SpeechSynthesizer.AudioFormat.format_wav,
762
+
callback=Callback(),
763
+
)
764
+
```
765
+
699
766
`HttpSpeechSynthesizer` calls TTS over plain HTTP (no WebSocket), useful in environments that can't hold a persistent connection:
700
767
701
768
```python
@@ -785,6 +852,8 @@ with open("audio.pcm", "rb") as f:
785
852
recognition.stop()
786
853
```
787
854
855
+
For voice cloning, pronunciation fixes, real-time speech translation, and custom ASR hot words, see the [Advanced Audio guide](docs/guides/realtime-audio.md).
856
+
788
857
### Bailian Application (Agent App)
789
858
790
859
Call an app you built in [Bailian's Application Center](https://bailian.console.aliyun.com/):
Upload a training file, launch a fine-tune job, and poll it to completion (requires `pip install "dashscope[rl]"` for agentic RL fine-tuning; classic supervised fine-tuning needs no extra):
@@ -898,8 +989,27 @@ dashscope generation create -m qwen-plus -p "Write a haiku about the sea" --stre
# Deploy a fine-tuned model, then manage the deployment
1002
+
dashscope deployments create -m <finetuned-model-id> --plan mu -c 1
1003
+
dashscope deployments list
1004
+
dashscope deployments get <deployed_model>
1005
+
dashscope deployments scale <deployed_model> -c 2
1006
+
dashscope deployments delete <deployed_model>
1007
+
1008
+
# Agentic RL job management (see the reinforcement guide for `dashscope rl run`)
1009
+
dashscope rl list
1010
+
dashscope rl get <job_id>
1011
+
dashscope rl logs <job_id>
1012
+
dashscope rl cancel <job_id>
903
1013
```
904
1014
905
1015
Run `dashscope --help` or `dashscope <command> --help` (e.g. `dashscope generation --help`) to see every command group (`generation`, `ft`, `files`, `deployments`, `models`, `embeddings`, `rerank`, `tokenization`, `application`, `image-synthesis`, `video-synthesis`, `multimodal-conversation`, `transcription`, `speech-synthesis`, `rl`, ...) and their options. Running `dashscope` with no arguments instead launches the interactive [AI Assistant](#ai-assistant-dashscope-sdk-expert).
0 commit comments