Audio tagging

Updated at:

Annotate a recorded audio or video file asynchronously to obtain time-aligned speech, sound effects, background sounds, and a description of the overall scene.

Features

  • Comprehensive audio transcription and summarization: Extracts and transcribes speech content, speaker information, timestamps, environmental sounds, sound effects, and background music, and automatically generates a structured summary of the audio.
  • Acoustic scene analysis: Classifies and identifies environmental sound effects, types of background noise, and spatial acoustic characteristics for acoustic scene understanding and audio monitoring.
  • Track separation in complex scenes: Optimized for conversations with multiple speakers and overlapping sounds, the model extracts and separates individual voices and background audio to improve the analysis of complex recordings.
  • Audio editing and annotation: Outputs millisecond timestamps and multitrack markers for automated audio editing, timeline alignment, and the automated annotation and processing of large datasets.

Get started

This example uses the China (Beijing) region. In the Model Studio console, obtain an API key and set the DASHSCOPE_API_KEY environment variable to that key. Replace {WorkspaceId} in the example with your workspace ID for the same region.

This Python example submits a Mandarin recording, waits for the task to finish, and then downloads and parses the annotations for each channel.

import json
import os
import time
from urllib.request import Request, urlopen

base_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"
auth = {"Authorization": "Bearer " + os.environ["DASHSCOPE_API_KEY"]}
body = {
    "model": "qwen-audio-3.1-captioner",
    "input": {"file_url": "https://g-adoc.alcasset.com/media/maas_docs/sfm-cn/zh/audios/6a4b3c2d1e0f9093.wav"},
    "parameters": {"channel_id": [0]},
}
request = Request(
    base_url + "/services/audio/asr/transcription",
    data=json.dumps(body).encode(),
    headers={**auth, "Content-Type": "application/json", "X-DashScope-Async": "enable"},
)
with urlopen(request, timeout=30) as response:
    task_id = json.load(response)["output"]["task_id"]

while True:
    with urlopen(Request(f"{base_url}/tasks/{task_id}", headers=auth), timeout=30) as response:
        output = json.load(response)["output"]
    if output["task_status"] not in ("PENDING", "RUNNING"):
        break
    time.sleep(3)

if output["task_status"] != "SUCCEEDED" or output.get("subtask_status") != "SUCCEEDED":
    raise RuntimeError(output.get("message") or output)
with urlopen(output["transcription_url"], timeout=30) as response:
    result = json.load(response)
for channel in result["transcripts"]:
    annotations = json.loads(channel["text"])
    print(json.dumps(annotations, ensure_ascii=False, indent=2))

The example prints annotations for each channel: time-aligned speech, sound effects, background sounds, and a description of the overall scene.

Input requirements

  • Input: Submit one publicly accessible, direct download URL for an audio or video file per task.
  • Size and duration: Up to 2 GB and 5 minutes per file.
  • Audio and video formats: aac, amr, avi, flac, flv, m4a, mkv, mov, mp3, mp4, mpeg, ogg, opus, wav, webm, wma, wmv.
  • Sample rate: 8 kHz or higher.
  • Languages: Chinese, English, Japanese, Korean, French, German, and Spanish.

Supported model

China (Beijing)

  • Qwen-Audio-3.1-Captioner: qwen-audio-3.1-captioner

API reference