Updated on 2025-08-26 GMT+08:00

HTTP Interface

Function

This API is used for real-time recognition of short sentences. Audio files within 1 minute can be uploaded at a time without segmentation, and the recognition result can be returned immediately.

URI

POST /v1/{project_id}/asr/short-audio

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It is used to obtain the permission to call APIs. For details about how to obtain a user token, see Authentication. The token is the value of X-Subject-Token in the response header.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

config

Yes

Config object

Configuration information.

data

Yes

String

Base64-encoded voice data. The size of the Base64-encoded voice data cannot exceed 4 MB, and the audio duration cannot exceed 1 minute. For example, /+MgxAAUeHpMAUkQAANhuRAC..... If the prefix data:audio/mp3;base64, is carried, an error is reported.

Table 4 Config

Parameter

Mandatory

Type

Description

audio_format

Yes

String

Supported audio format. For details, see Table 5.

property

Yes

String

Model feature string in use, which is generally in the Language_Sampling rate_Domain format. The sampling rate must be the same as the audio sampling rate. For details about the value range, see Table 6.

add_punc

No

String

Whether to add punctuation marks to the recognition result. The value can be yes or no. The default value is no.

digit_norm

No

String

Whether to convert digits in the speech into Arabic numerals. The value can be yes or no. The default value is yes.

vocabulary_id

No

String

Hot word table ID. If no hot word table is used, this field can be left blank. This parameter is currently not supported on the international website.

need_word_info

No

String

Whether to output the word segmentation result in the recognition result. The value can be yes or no. The default value is no.

Table 5 Value range of audio_format

Value

Description

pcm16k16bit

16 kHz, 16-bit mono-channel audio recording data

pcm8k16bit

8 kHz, 16-bit mono-channel audio recording data

ulaw16k8bit

16 kHz, 8-bit u-law mono-channel audio recording data

ulaw8k8bit

8 kHz, 8-bit u-law mono-channel audio recording data

alaw16k8bit

16 kHz, 8-bit A-law mono-channel audio recording data

alaw8k8bit

8 kHz, 8-bit A-law mono-channel audio recording data

mp3

MP3 audio recording data Currently, only mono-channel audio is supported.

aac

AAC audio recording data Currently, only mono-channel audio is supported.

wav

Format with the WAV encapsulation header. The format is automatically determined by the encapsulation header. Currently, only the 8 kHz/16 kHz sampling rate, mono channel, and pcm encoding format are supported.

amr

AMR narrowband (8 kHz) compressed audio recording data. Currently, only mono-channel audio is supported.

amrwb

AMR broadband (16 kHz) compressed audio recording data. Currently, only mono-channel audio is supported.

auto

The engine automatically determines and decodes the audio data in amr, flac, m4a, mp3, ogg, webm, wav, aac, ac3, mov, wma, and amrwb format.

Table 6 Value range of property

Value

Description

chinese_16k_general

Supports speech recognition of Chinese Mandarin with a sampling rate of 8 kHz or 16 kHz. The next-gen end-to-end recognition algorithm is used to achieve higher recognition accuracy.

arabic_16k_general

Supports Arabic speech recognition at a sampling rate of 16 kHz and supports Standard Arabic, Egyptian dialect, and Saudi dialect. The add_punc, digit_norm, and vocabulary_id parameters are currently not supported.

english_16k_common

Supports English speech recognition at a sampling rate of 8 kHz or 16 kHz. The digit_norm parameter is currently not supported.

english_8k_common

Supports English speech recognition at a sampling rate of 8 kHz. This model is an old version and will not be maintained later. You are advised to use english_16k_common.

Response Parameters

Status code: 200

Table 7 Response body parameters

Parameter

Mandatory

Type

Description

trace_id

Yes

String

Internal token used to trace a specific process in logs. This parameter is not included when the API fails to be called.

In some error cases, this field may not exist.

result

Yes

Result object

If the calling is successful, this parameter indicates the recognition result. Otherwise, this parameter is invalid.

Table 8 Result

Parameter

Mandatory

Type

Description

text

Yes

String

Recognition result of a successful call

score

Yes

Float

Confidence of a successful call. The value ranges from 0 to 1.

word_info

No

Array of WordInfo objects

Word segmentation information list

Word segmentation refers to splitting the recognized text into individual words.

Table 9 WordInfo

Parameter

Mandatory

Type

Description

start_time

No

Integer

Start time

end_time

No

Integer

End time

word

No

String

Word segmentation

Status code: 400

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code when the API call fails. This parameter is not returned for a successful call.

error_msg

String

Error message when the API call fails. This parameter is not returned for a successful call.

Example Requests

The endpoint is the request URL for calling an API. Endpoints vary according to services and regions. For details, see Endpoints.

  • Upload a short audio and quickly obtain the recognition result.
    POST https://{endpoint}/v1/{project_id}/asr/short-audio
    
    Request header:
    Content-Type: application/json
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...   
    
    Request body: 
    {
      "config":
      {
        "audio_format": "wav",
        "property": "arabic_16k_general",
        "add_punc": "yes",
        "need_word_info": "yes"
      },
      "data": "/+MgxAAUeHpMAUkQAANhuRAC..."
    }

Example Responses

Status code: 200

Example response for a successful request

{
  "trace_id": "567e8537-a89c-13c3-a882-826321939651",
  "result":{
   "text": "Nice to meet you",
    "score": 0.9,
  }
}

Status code: 400

Example response for a failed request

{ 
    "error_code":"SIS.0001", 
    "error_msg":"***" 
}

Status Codes

See Status Codes.

Error Codes

See Error Codes.