
Aliyun Qwen Tts
- 63 installs
- 396 repo stars
- Updated July 18, 2026
- cinience/alicloud-skills
Generate human-like speech from text with Alibaba Cloud Model Studio Qwen TTS models via the DashScope SDK.
About
Uses the DashScope SDK with Qwen TTS models to convert text to speech, including voice lines for short videos and news. A developer uses it to add text-to-speech to a media pipeline.
- qwen3-tts-flash and instruct-flash model variants
- Saves generated audio links and request payloads as evidence
Aliyun Qwen Tts by the numbers
- 63 all-time installs (skills.sh)
- Ranked #858 of 1,335 Generative Media skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/cinience/alicloud-skills --skill aliyun-qwen-ttsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 63 |
|---|---|
| repo stars | ★ 396 |
| Last updated | July 18, 2026 |
| Repository | cinience/alicloud-skills ↗ |
What it does
Generate human-like speech from text with Alibaba Cloud Model Studio Qwen TTS models via the DashScope SDK.
Files
Category: provider
Model Studio Qwen TTS
Validation
mkdir -p output/aliyun-qwen-tts
python -m py_compile skills/ai/audio/aliyun-qwen-tts/scripts/generate_tts.py && echo "py_compile_ok" > output/aliyun-qwen-tts/validate.txtPass criteria: command exits 0 and output/aliyun-qwen-tts/validate.txt is generated.
Output And Evidence
- Save generated audio links, sample audio files, and request payloads to
output/aliyun-qwen-tts/. - Keep one validation log per execution.
Critical model names
Use one of the recommended models:
qwen3-tts-flashqwen3-tts-instruct-flashqwen3-tts-instruct-flash-2026-01-26
Prerequisites
- Install SDK (recommended in a venv to avoid PEP 668 limits):
python3 -m venv .venv
. .venv/bin/activate
python -m pip install dashscope- Set
DASHSCOPE_API_KEYin your environment, or adddashscope_api_keyto~/.alibabacloud/credentials(env takes precedence).
Normalized interface (tts.generate)
Request
text(string, required)voice(string, required)language_type(string, optional; defaultAuto)instruction(string, optional; recommended for instruct models)stream(bool, optional; default false)
Response
audio_url(string, when stream=false)audio_base64_pcm(string, when stream=true)sample_rate(int, 24000)format(string, wav or pcm depending on mode)
Quick start (Python + DashScope SDK)
import os
import dashscope
# Prefer env var for auth: export DASHSCOPE_API_KEY=...
# Or use ~/.alibabacloud/credentials with dashscope_api_key under [default].
# Beijing region; for Singapore use: https://dashscope-intl.aliyuncs.com/api/v1
dashscope.base_http_api_url = "https://dashscope.aliyuncs.com/api/v1"
text = "Hello, this is a short voice line."
response = dashscope.MultiModalConversation.call(
model="qwen3-tts-instruct-flash",
api_key=os.getenv("DASHSCOPE_API_KEY"),
text=text,
voice="Cherry",
language_type="English",
instruction="Warm and calm tone, slightly slower pace.",
stream=False,
)
audio_url = response.output.audio.url
print(audio_url)Streaming notes
stream=Truereturns Base64-encoded PCM chunks at 24kHz.- Decode chunks and play or concatenate to a pcm buffer.
- The response contains
finish_reason == "stop"when the stream ends.
Operational guidance
- Keep requests concise; split long text into multiple calls if you hit size or timeout errors.
- Use
language_typeconsistent with the text to improve pronunciation. - Use
instructiononly when you need explicit style/tone control. - Cache by
(text, voice, language_type)to avoid repeat costs.
Output location
- Default output:
output/aliyun-qwen-tts/audio/ - Override base dir with
OUTPUT_DIR.
Workflow
1) Confirm user intent, region, identifiers, and whether the operation is read-only or mutating. 2) Run one minimal read-only query first to verify connectivity and permissions. 3) Execute the target operation with explicit parameters and bounded scope. 4) Verify results and save output/evidence files.
References
references/api_reference.mdfor parameter mapping and streaming example.- Realtime mode is provided by
skills/ai/audio/aliyun-qwen-tts-realtime/. - Voice cloning/design are provided by
skills/ai/audio/aliyun-qwen-tts-voice-clone/andskills/ai/audio/aliyun-qwen-tts-voice-design/.
- Source list:
references/sources.md
interface:
display_name: "Alibaba Cloud AI Audio TTS"
short_description: "Alibaba Cloud TTS and speech workflows"
default_prompt: "Use $aliyun-qwen-tts to complete this ai/audio task on Alibaba Cloud."
DashScope SDK Reference (Qwen TTS)
Install
python3 -m venv .venv
. .venv/bin/activate
python -m pip install dashscopeEnvironment
export DASHSCOPE_API_KEY=your_keyIf env vars are not set, you can also place dashscope_api_key under [default] in ~/.alibabacloud/credentials.
Suggested mapping
import os
import dashscope
# Beijing region; for Singapore use: https://dashscope-intl.aliyuncs.com/api/v1
dashscope.base_http_api_url = "https://dashscope.aliyuncs.com/api/v1"
response = dashscope.MultiModalConversation.call(
model="qwen3-tts-flash",
api_key=os.getenv("DASHSCOPE_API_KEY"),
text=text,
voice=voice,
language_type=language_type,
stream=False,
)
audio_url = response.output.audio.urlStreaming example (PCM)
import os
import base64
import dashscope
# Beijing region; for Singapore use: https://dashscope-intl.aliyuncs.com/api/v1
dashscope.base_http_api_url = "https://dashscope.aliyuncs.com/api/v1"
response = dashscope.MultiModalConversation.call(
model="qwen3-tts-flash",
api_key=os.getenv("DASHSCOPE_API_KEY"),
text=text,
voice=voice,
language_type=language_type,
stream=True,
)
pcm_chunks = []
for chunk in response:
audio = chunk.output.audio
if audio.data:
pcm_chunks.append(base64.b64decode(audio.data))
if chunk.output.finish_reason == "stop":
break
pcm_bytes = b"".join(pcm_chunks)Notes
- SDK versions: Python >= 1.24.6 (per doc); Java >= 2.21.9.
stream=Falsereturns a temporaryaudio_urlvalid for 24 hours.- Streaming output is Base64 PCM at 24kHz.
官方文档来源(用于后续更新) ============================
- https://dashscope-intl.aliyuncs.com/api/v1
- https://dashscope.aliyuncs.com/api/v1
#!/usr/bin/env python3
"""Generate speech audio using DashScope (qwen3-tts-flash) from a normalized request.
Usage:
python scripts/generate_tts.py --request '{"text":"Hello","voice":"Cherry"}'
python scripts/generate_tts.py --file request.json --output output/ai-audio-tts/audio/voice.wav
"""
from __future__ import annotations
import argparse
import configparser
import json
import os
import sys
import urllib.request
from pathlib import Path
from typing import Any
try:
import dashscope
except ImportError:
print("Error: dashscope is not installed. Run: pip install dashscope", file=sys.stderr)
sys.exit(1)
MODEL_NAME = "qwen3-tts-flash"
DEFAULT_VOICE = "Cherry"
DEFAULT_LANGUAGE = "Auto"
def _find_repo_root(start: Path) -> Path | None:
for parent in [start] + list(start.parents):
if (parent / ".git").exists():
return parent
return None
def _load_dotenv(path: Path) -> None:
if not path.exists():
return
for line in path.read_text().splitlines():
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
key, value = line.split("=", 1)
key = key.strip()
value = value.strip().strip('"').strip("'")
if key and key not in os.environ:
os.environ[key] = value
def _load_env() -> None:
_load_dotenv(Path.cwd() / ".env")
repo_root = _find_repo_root(Path(__file__).resolve())
if repo_root:
_load_dotenv(repo_root / ".env")
def _load_dashscope_api_key_from_credentials() -> None:
if os.environ.get("DASHSCOPE_API_KEY"):
return
credentials_path = Path(os.path.expanduser("~/.alibabacloud/credentials"))
if not credentials_path.exists():
return
config = configparser.ConfigParser()
try:
config.read(credentials_path)
except configparser.Error:
return
profile = os.getenv("ALIBABA_CLOUD_PROFILE") or os.getenv("ALICLOUD_PROFILE") or "default"
if not config.has_section(profile):
return
key = config.get(profile, "dashscope_api_key", fallback="").strip()
if not key:
key = config.get(profile, "DASHSCOPE_API_KEY", fallback="").strip()
if key:
os.environ["DASHSCOPE_API_KEY"] = key
def load_request(args: argparse.Namespace) -> dict[str, Any]:
if args.request:
return json.loads(args.request)
if args.file:
with open(args.file, "r", encoding="utf-8") as f:
return json.load(f)
raise ValueError("Either --request or --file must be provided")
def call_generate(req: dict[str, Any]) -> dict[str, Any]:
text = req.get("text")
if not text:
raise ValueError("text is required")
dashscope.base_http_api_url = req.get(
"base_url", "https://dashscope.aliyuncs.com/api/v1"
)
response = dashscope.MultiModalConversation.call(
model=MODEL_NAME,
api_key=os.getenv("DASHSCOPE_API_KEY"),
text=text,
voice=req.get("voice", DEFAULT_VOICE),
language_type=req.get("language_type", DEFAULT_LANGUAGE),
stream=False,
)
audio = response.output.audio
audio_url = audio.url
return {
"audio_url": audio_url,
"sample_rate": audio.get("sample_rate"),
"format": audio.get("format"),
}
def download_audio(audio_url: str, output_path: Path) -> None:
output_path.parent.mkdir(parents=True, exist_ok=True)
with urllib.request.urlopen(audio_url) as response:
output_path.write_bytes(response.read())
def main() -> None:
parser = argparse.ArgumentParser(description="Generate audio with qwen3-tts-flash")
parser.add_argument("--request", help="Inline JSON request string")
parser.add_argument("--file", help="Path to JSON request file")
default_output_dir = Path(os.getenv("OUTPUT_DIR", "output")) / "ai-audio-tts" / "audio"
parser.add_argument(
"--output",
default=str(default_output_dir / "output.wav"),
help="Output audio path",
)
parser.add_argument("--print-response", action="store_true", help="Print normalized response JSON")
args = parser.parse_args()
_load_env()
_load_dashscope_api_key_from_credentials()
if not os.environ.get("DASHSCOPE_API_KEY"):
print(
"Error: DASHSCOPE_API_KEY is not set. Configure it via env/.env or ~/.alibabacloud/credentials.",
file=sys.stderr,
)
print("Example .env:\n DASHSCOPE_API_KEY=your_key_here", file=sys.stderr)
print(
"Example credentials:\n [default]\n dashscope_api_key=your_key_here",
file=sys.stderr,
)
sys.exit(1)
req = load_request(args)
result = call_generate(req)
download_audio(result["audio_url"], Path(args.output))
if args.print_response:
print(json.dumps(result, ensure_ascii=True))
if __name__ == "__main__":
main()