
Alicloud Ai Audio Tts Realtime
- 272 installs
- 396 repo stars
- Updated July 18, 2026
- cinience/alicloud-skills
alicloud-ai-audio-tts-realtime is a version 1.0.0 agent skill that wires Alibaba Cloud Model Studio Qwen realtime TTS models into voice agents for developers who need low-latency streaming speech synthesis with instructi
About
alicloud-ai-audio-tts-realtime is a version 1.0.0 Cinience agent skill for Alibaba Cloud Model Studio Qwen realtime text-to-speech. It supports five exact model strings—including qwen3-tts-flash-realtime and instruction-controlled variants—via the dashscope SDK in a Python virtual environment with DASHSCOPE_API_KEY authentication. The normalized tts.realtime interface accepts text, voice, optional instruction and sample_rate, returning audio_base64_pcm_chunks over websocket streaming. Developers reach for this skill when building voice agents, live assistants, or interactive apps needing immediate spoken responses rather than batch TTS. A bundled realtime_tts_demo.py script probes SDK compatibility, supports --strict CI gating, and can fallback to non-realtime models. Output lands in output/ai-audio-tts-realtime/audio/ with py_compile validation scripts. Operational guidance keeps utterances short for lower latency and instructions concise on instruct models.
- Streaming TTS session management
- Low-latency audio chunk delivery
- Live voice agent integration
- WebSocket or stream API wiring
- Interactive assistant speech output
Alicloud Ai Audio Tts Realtime by the numbers
- 272 all-time installs (skills.sh)
- Ranked #534 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 alicloud-ai-audio-tts-realtimeAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 272 |
|---|---|
| repo stars | ★ 396 |
| Last updated | July 18, 2026 |
| Repository | cinience/alicloud-skills ↗ |
How do you add realtime TTS to a voice agent?
Wire low-latency streaming TTS into voice agents, live assistants, or interactive apps requiring immediate spoken responses from Alibaba Cloud.
Who is it for?
Developers building voice agents or live assistants on Alibaba Cloud who need streaming Qwen TTS with dashscope SDK integration.
Skip if: Batch offline TTS or non-Alibaba speech providers should use aliyun-qwen-tts or other cloud audio skills instead.
When should I use this skill?
User needs low-latency streaming speech synthesis with Alibaba Cloud Qwen realtime TTS models.
What you get
Streaming PCM audio chunks, sample_rate metadata, probe-script WAV output, and validation artifacts under output/aliyun-qwen-tts-realtime/.
- Streaming PCM audio output
- realtime_tts_demo.py probe results
- Validation artifacts in output/aliyun-qwen-tts-realtime/
By the numbers
- Version 1.0.0 skill with 5 exact Qwen realtime TTS model strings
- Includes realtime_tts_demo.py probe script with --strict CI mode
Files
Category: provider
Model Studio Qwen TTS Realtime
Use realtime TTS models for low-latency streaming speech output.
Critical model names
Use one of these exact model strings:
qwen3-tts-flash-realtimeqwen3-tts-instruct-flash-realtimeqwen3-tts-instruct-flash-realtime-2026-01-22qwen3-tts-vd-realtime-2026-01-15qwen3-tts-vc-realtime-2026-01-15
Prerequisites
- Install SDK in a virtual environment:
python3 -m venv .venv
. .venv/bin/activate
python -m pip install dashscope- Set
DASHSCOPE_API_KEYin your environment, or adddashscope_api_keyto~/.alibabacloud/credentials.
Normalized interface (tts.realtime)
Request
text(string, required)voice(string, required)instruction(string, optional)sample_rate(int, optional)
Response
audio_base64_pcm_chunks(array<string>)sample_rate(int)finish_reason(string)
Operational guidance
- Use websocket or streaming endpoint for realtime mode.
- Keep each utterance short for lower latency.
- For instruction models, keep instruction explicit and concise.
- Some SDK/runtime combinations may reject realtime model calls over
MultiModalConversation; use the probe script below to verify compatibility.
Local demo script
Use the probe script to verify realtime compatibility in your current SDK/runtime, and optionally fallback to a non-realtime model for immediate output:
.venv/bin/python skills/ai/audio/alicloud-ai-audio-tts-realtime/scripts/realtime_tts_demo.py \
--text "This is a realtime speech demo." \
--fallback \
--output output/ai-audio-tts-realtime/audio/fallback-demo.wavStrict mode (for CI / gating):
.venv/bin/python skills/ai/audio/alicloud-ai-audio-tts-realtime/scripts/realtime_tts_demo.py \
--text "realtime health check" \
--strictOutput location
- Default output:
output/ai-audio-tts-realtime/audio/ - Override base dir with
OUTPUT_DIR.
Validation
mkdir -p output/alicloud-ai-audio-tts-realtime
for f in skills/ai/audio/alicloud-ai-audio-tts-realtime/scripts/*.py; do
python3 -m py_compile "$f"
done
echo "py_compile_ok" > output/alicloud-ai-audio-tts-realtime/validate.txtPass criteria: command exits 0 and output/alicloud-ai-audio-tts-realtime/validate.txt is generated.
Output And Evidence
- Save artifacts, command outputs, and API response summaries under
output/alicloud-ai-audio-tts-realtime/. - Include key parameters (region/resource id/time range) in evidence files for reproducibility.
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/sources.md
interface:
display_name: "Alibaba Cloud AI Audio TTS Realtime"
short_description: "Qwen realtime TTS workflows"
default_prompt: "Use $alicloud-ai-audio-tts-realtime to complete this ai/audio realtime synthesis task on Alibaba Cloud."
- https://help.aliyun.com/zh/model-studio/qwen-tts-realtime
- https://help.aliyun.com/zh/model-studio/newly-released-models
#!/usr/bin/env python3
"""Probe realtime TTS model compatibility and optionally fallback to non-realtime TTS.
Usage:
.venv/bin/python skills/ai/audio/alicloud-ai-audio-tts-realtime/scripts/realtime_tts_demo.py \
--text "hello" --fallback
"""
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)
REALTIME_MODEL = "qwen3-tts-instruct-flash-realtime"
FALLBACK_MODEL = "qwen3-tts-instruct-flash"
DEFAULT_VOICE = "Cherry"
DEFAULT_LANGUAGE = "Chinese"
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 _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 _probe_realtime(text: str, voice: str, instruction: str | None, language_type: str, base_url: str) -> dict[str, Any]:
dashscope.base_http_api_url = base_url
try:
stream = dashscope.MultiModalConversation.call(
model=REALTIME_MODEL,
api_key=os.getenv("DASHSCOPE_API_KEY"),
text=text,
voice=voice,
instruction=instruction,
language_type=language_type,
stream=True,
)
except Exception as exc: # pragma: no cover
return {
"ok": False,
"model": REALTIME_MODEL,
"stage": "call",
"error": str(exc),
}
chunk_count = 0
statuses: list[dict[str, Any]] = []
has_audio_chunk = False
try:
for chunk in stream:
chunk_count += 1
status_code = getattr(chunk, "status_code", None)
code = getattr(chunk, "code", None)
message = getattr(chunk, "message", None)
statuses.append({"status_code": status_code, "code": code, "message": message})
out = getattr(chunk, "output", None)
audio = getattr(out, "audio", None) if out is not None else None
if audio:
data = audio.get("data") if hasattr(audio, "get") else None
if data:
has_audio_chunk = True
if isinstance(status_code, int) and status_code >= 400:
return {
"ok": False,
"model": REALTIME_MODEL,
"stage": "stream",
"chunk_count": chunk_count,
"statuses": statuses,
"error": f"status_code={status_code}, code={code}, message={message}",
}
except Exception as exc:
return {
"ok": False,
"model": REALTIME_MODEL,
"stage": "stream-exception",
"chunk_count": chunk_count,
"statuses": statuses,
"error": str(exc),
}
if not has_audio_chunk:
return {
"ok": False,
"model": REALTIME_MODEL,
"stage": "stream",
"chunk_count": chunk_count,
"statuses": statuses,
"error": "No audio chunks returned.",
}
return {
"ok": True,
"model": REALTIME_MODEL,
"stage": "stream",
"chunk_count": chunk_count,
"statuses": statuses,
}
def _fallback_generate(text: str, voice: str, instruction: str | None, language_type: str, base_url: str, output: Path) -> dict[str, Any]:
dashscope.base_http_api_url = base_url
response = dashscope.MultiModalConversation.call(
model=FALLBACK_MODEL,
api_key=os.getenv("DASHSCOPE_API_KEY"),
text=text,
voice=voice,
instruction=instruction,
language_type=language_type,
stream=False,
)
status_code = getattr(response, "status_code", None)
if isinstance(status_code, int) and status_code >= 400:
return {
"ok": False,
"model": FALLBACK_MODEL,
"error": f"status_code={status_code}, code={response.code}, message={response.message}",
}
audio = getattr(response.output, "audio", None)
audio_url = audio.get("url") if audio else None
if not audio_url:
return {
"ok": False,
"model": FALLBACK_MODEL,
"error": "Missing audio_url in response.",
}
_download_audio(audio_url, output)
return {
"ok": True,
"model": FALLBACK_MODEL,
"audio_url": audio_url,
"output": str(output),
"sample_rate": audio.get("sample_rate") if audio else None,
"format": audio.get("format") if audio else None,
}
def main() -> None:
parser = argparse.ArgumentParser(description="Probe realtime TTS and optionally fallback to non-realtime model")
parser.add_argument("--text", required=True, help="Text to synthesize")
parser.add_argument("--voice", default=DEFAULT_VOICE)
parser.add_argument("--language-type", default=DEFAULT_LANGUAGE)
parser.add_argument("--instruction", default="Warm and calm tone, slightly slower pace.")
parser.add_argument("--base-url", default="https://dashscope.aliyuncs.com/api/v1")
parser.add_argument("--fallback", action="store_true", help="Fallback to non-realtime model when probe fails")
parser.add_argument(
"--strict",
action="store_true",
help="Exit non-zero when realtime probe fails even if fallback succeeds",
)
default_output = Path(os.getenv("OUTPUT_DIR", "output")) / "ai-audio-tts-realtime" / "audio" / "fallback-demo.wav"
parser.add_argument("--output", default=str(default_output), help="Fallback output path")
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.", file=sys.stderr)
sys.exit(1)
probe = _probe_realtime(
text=args.text,
voice=args.voice,
instruction=args.instruction,
language_type=args.language_type,
base_url=args.base_url,
)
result: dict[str, Any] = {"realtime_probe": probe}
if not probe.get("ok") and args.fallback:
fallback = _fallback_generate(
text=args.text,
voice=args.voice,
instruction=args.instruction,
language_type=args.language_type,
base_url=args.base_url,
output=Path(args.output),
)
result["fallback"] = fallback
print(json.dumps(result, ensure_ascii=False))
# Exit semantics:
# - strict: realtime probe must pass
# - non-strict: probe pass OR fallback pass
if args.strict:
if not probe.get("ok"):
sys.exit(2)
sys.exit(0)
if probe.get("ok"):
sys.exit(0)
fallback_ok = bool(result.get("fallback", {}).get("ok")) if isinstance(result.get("fallback"), dict) else False
if fallback_ok:
sys.exit(0)
sys.exit(1)
if __name__ == "__main__":
main()
Related skills
How it compares
Pick alicloud-ai-audio-tts-realtime for websocket streaming voice agents; use aliyun-qwen-tts for batch non-realtime speech generation.
FAQ
Which Qwen models does alicloud-ai-audio-tts-realtime support?
alicloud-ai-audio-tts-realtime lists five exact model strings: qwen3-tts-flash-realtime, qwen3-tts-instruct-flash-realtime, qwen3-tts-instruct-flash-realtime-2026-01-22, qwen3-tts-vd-realtime-2026-01-15, and qwen3-tts-vc-realtime-2026-01-15.
How do you authenticate alicloud-ai-audio-tts-realtime calls?
alicloud-ai-audio-tts-realtime requires the dashscope Python SDK with DASHSCOPE_API_KEY set as an environment variable or dashscope_api_key in ~/.alibabacloud/credentials.
How do you validate alicloud-ai-audio-tts-realtime locally?
alicloud-ai-audio-tts-realtime provides realtime_tts_demo.py to probe websocket streaming compatibility, with --strict for CI gating and py_compile validation of bundled scripts.