• 製品
  • 料金
  • リソース
  • サポート
このページは現在英語版のみで提供されており、日本語版も近日中に提供される予定です。ご利用いただきありがとうございます。

Websocket Access (New)

API Description

This service uses the WebSocket protocol to recognize a real-time audio stream and return recognition results synchronously, so text appears as the speaker talks.
Note:
Starting September 24, 2026, new users should use this document to integrate the new v3 API.
Users who have already integrated the legacy WebSocket v2 protocol can refer to WebSocket Access (Legacy) for details.

Prerequisites

You need two credentials: SDKAppID and SecretKey.
Parameter
Where to get it
Description
SDKAppID
TRTC Console > Application Details
TRTC application ID; the only customer dimension in v3.
SecretKey
TRTC Console > Application Details
Used to generate the UserSig; never transmitted over the network.
Note:
For the international site, sign up at trtc.io (a Tencentcloud account is created automatically; no real-name verification is required), create an application in the TRTC Console, and activate "AI Speech Recognition". This service is only available with an RTC Engine Lite (or higher) monthly subscription; Free Trial is not supported. See Activate the Service.

API Requirements

Item
Description
Languages
Mandarin Chinese, Chinese dialects, English, and other languages such as Japanese, Korean, and French.
Industry
General.
Audio properties
Sample rate: 16000 Hz or 8000 Hz; sample depth: 16 bits; channel: mono.
Audio formats
1 pcm, 4 speex, 6 silk, 8 mp3, 10 opus (raw Opus frame stream), 11 ogg (Ogg container, including .opus/.ogg files), 12 wav, 14 m4a, 16 aac.
Note:
Opus is a codec, and there are two ways to package it for transmission, corresponding to different voice_format values:
10 (raw Opus frame stream): the audio is a continuous sequence of Opus frames, each preceded by a 2-byte little-endian length prefix.
11 (Ogg container): the audio is an Ogg container file whose first 4 bytes are OggS. Common .opus and .ogg files fall into this category (the codec inside the container may be Opus or Vorbis). When streaming an existing audio file, choose 11.
To check, look at the first 4 bytes of the file: if they are OggS, use 11.
Protocol
WSS.
Endpoint
wss://asr-intl.cloud-rtc.com/asr/v3?voice_id=<voice_id>; Authentication information is passed in the auth block of the first message. The URL carries no authentication parameters.
Response format
JSON.
Data sending
Send a 40 ms audio packet every 40 ms (a 1:1 real-time rate). The corresponding PCM size is 640 bytes at 8 kHz and 1280 bytes at 16 kHz. A single frame must not exceed 256 KB. After the connection is established, the first message must be sent within 3 seconds. If the interval between audio packets exceeds 15 seconds, the backend returns an error and closes the connection.
Concurrency limit
By default, a single account (SDKAppID) is limited to 100 concurrent streams.
Note:
If you need higher concurrency, please contact us.

Flow Chart




Corresponding SDK behavior: Start() completes steps 1 and 2 (it waits synchronously for the ack, and returns an error immediately on authentication or parameter errors); Write() corresponds to the step 3 upstream audio; downstream messages are delivered through listener callbacks OnSentenceBegin / OnRecognitionResultChange / OnSentenceEnd / OnRecognitionComplete; Stop() sends end and waits for final:1.

API Call Flow

The call flow has three phases: connection, authentication, and recognition. In the authentication and recognition phases, the backend returns text messages whose content is a JSON-serialized string. Common fields are described below:
Field
Type
Description
code
Integer
Status code. 0 means success; a non-zero value indicates an error.
message
String
Error description.
voice_id
String
Globally unique ID of the audio stream; one WebSocket connection corresponds to one voice_id. Generated by the user (a UUID is recommended), up to 128 characters.
message_id
String
Unique ID of this message.
result
Result
Latest speech recognition result. See Recognition Result below.
final
Integer
When this field is 1, recognition of the whole audio stream has finished.

Connection Phase

The client initiates a WebSocket connection request. The request URL format is: wss://asr-intl.cloud-rtc.com/asr/v3?voice_id=<voice_id>.
The URL carries only voice_id and no authentication parameters. voice_id appears both in the URL ?voice_id= and in the first-message params.voice_id; the two must be identical, or it can be omitted from params. The SDK generates a UUID by default; you can specify one with SetVoiceID.

Authentication Phase

After the connection is established, the client must send a first text message within 3 seconds. Its content is JSON and it carries both authentication and parameters:
{
"type": "start",
"auth": {"sdkappid": "1400000001", "usersig": "eJw..."},
"params": {"engine_model_type": "bigmodel", "language": "zh", "voice_format": 1, "needvad": 1}
}
Type is always start. If the first-message JSON is invalid or type is not start, the server returns 4010; if the first message is not sent within 3 seconds, it returns 4008.
After authentication succeeds, the server returns an acknowledgment with code 0:
{"code": 0, "message": "success", "voice_id": "faab2b17-ba43-4ea4-be58-a03180ba26dd"}
If authentication or parameter validation fails, the server returns an error frame with a non-zero code (such as 4002 for authentication failure or 4001 for invalid parameters) and then closes the connection normally.
The SDK's Start() waits synchronously for this ack, so authentication and parameter errors are returned directly from Start().

auth Fields

One WebSocket connection is one stream. voice_id is both the stream identity and the signature identifier, so it is not repeated in the auth block.
Field
Type
Required
Description
sdkappid
String
Yes
TRTC application ID, taken from the credential and filled in automatically by the SDK.
usersig
String
Yes
TRTC signature; identifier = the current voice_id, and the SDK signs with that value. For how to calculate it, see Authentication & UserSig.
Note:
The online protocol has no request_id. request_id is a concept of the offline APIs, where "one request = one transaction"; it does not exist in the streaming protocol.

Signature Rules

1. If credential.SetUserSig() is not called, the SDK generates the signature locally from SDKAppID + SecretKey. It is valid for 86400 seconds and is regenerated for every connection, so long-running services do not need to manage expiry.
2. If you pass a fixed signature with credential.SetUserSig(sig), the SDK no longer generates or refreshes it. The server verifies the signature against the current identifier (voice_id for online), so the signature must be issued with the same identifier. In fixed-signature scenarios (such as a browser receiving a signature from your backend), you must handle expiry and identifier alignment yourself.
3. Signatures are bound to the site. SetSite(common.SiteIntl) determines the host and the verification cluster; international-site credentials cannot be used on the China site, and vice versa.
4. SecretKey is never transmitted over the network; the signature is only used for server-side verification.

params Fields

Parameter
Required
Type
Description
voice_id
No
String
Globally unique ID of the audio stream; one WebSocket connection corresponds to one. Generated by the user (a UUID is recommended), up to 128 characters. Must match the URL parameter, or be omitted.
engine_model_type
Yes
String
Speech Recognition 2.0 (recommended)
bigmodel: large-model engine; supports real-time speaker diarization.
Speech Recognition 1.0
Basic engine: 8k_zh.
Standard engines: 8k_zh_large, 16k_zh_large, or 16k_zh_en.
Advanced engines: ASR engines for other languages; pass "16k_" followed by the language code, for example 16k_vi (Vietnamese).

language

No
String
Speech Recognition 2.0 (recommended)
bigmodel supports zh (Mandarin, Chinese dialects, and mixed Chinese-English), en (English), yue (Cantonese), and other languages.
Chinese dialects: Anhui, Northeastern, Fujian, Gansu, Guizhou, Hebei, Henan, Hubei, Hunan, Jiangxi, Ningxia, Shandong, Shaanxi, Shanxi, Sichuan, Tianjin, Yunnan, Zhejiang, Cantonese (Hong Kong accent), Cantonese (Guangdong accent), Wu, Hokkien (Minnan).
Other languages: ar (Arabic), de (German), fr (French), es (Spanish), pt (Portuguese), id (Indonesian), it (Italian), ko (Korean), ru (Russian), th (Thai), vi (Vietnamese), ja (Japanese), tr (Turkish), hi (Hindi), ms (Malay), nl (Dutch), sv (Swedish), da (Danish), fi (Finnish), pl (Polish), cs (Czech), fa (Persian), el (Greek), ro (Romanian), hu (Hungarian), mk (Macedonian).
Speech Recognition 1.0
Basic: 8k_zh supports Mandarin and Chinese dialects.
Standard: 8k_zh_large and 16k_zh_large support Mandarin and Chinese dialects; 16k_zh_en supports Mandarin, Chinese dialects, English, and mixed Chinese-English.
Advanced: vi (Vietnamese), ja (Japanese), ko (Korean), id (Indonesian), th (Thai), pt (Portuguese), tr (Turkish), ar (Arabic), es (Spanish), hi (Hindi), fr (French), ms (Malay), fil (Filipino), de (German), it (Italian), ru (Russian), sv (Swedish), da (Danish), no (Norwegian).
If you need more languages, please contact us for evaluation.
Note:
When engine_model_type is bigmodel and language is omitted, the model detects the language automatically; when using the SDK, we recommend setting it explicitly.
voice_format
No
Integer
Audio encoding format. Default 1. Values: 1 pcm, 4 speex, 6 silk, 8 mp3, 10 opus (raw Opus frame stream), 11 ogg (Ogg container, including .opus/.ogg files), 12 wav, 14 m4a, 16 aac.
Note:
Opus is a codec, and there are two ways to package it, corresponding to different values. 10 raw Opus frame stream: a continuous sequence of Opus frames, each preceded by a 2-byte little-endian length prefix; 11 Ogg container: an Ogg container file whose first 4 bytes are OggS; common .opus and .ogg files belong here (the codec inside may be Opus or Vorbis). When streaming an existing audio file, choose 11.
To check, look at the first 4 bytes of the file: if they are OggS, use 11.
For real-time streaming, pcm (16 kHz, 16-bit, mono) is recommended.
input_sample_rate
No
Integer
Upsamples 8 kHz PCM audio to 16 kHz before recognition when it does not match the engine sample rate, which effectively improves accuracy. Only 8000 is supported.
Note:
This parameter only applies to PCM audio. If omitted, the default applies: the engine sample rate is assumed to equal the PCM audio sample rate.
needvad
No
Integer
0 turn VAD off.
1 turn VAD on.
If omitted, the engine decides (the Go SDK sends 1 by default). To ensure recognition quality, speech segments longer than 60 seconds are forcibly split at 60 s; enabling VAD (voice activity detection and segmentation) is recommended for audio longer than 60 s to improve splitting.
vad_silence_time
No
Integer
Sentence-break detection threshold: a silence longer than this value is treated as a sentence break (mostly used in intelligent customer service; use together with needvad=1). Range 240-2000 (default 800), in ms. Changing this parameter is not recommended, as it may affect recognition quality.
vad_level
No
Integer
VAD scenario level:
0 high recall.
1 far-field filtering.
Default 1. Setting noise_threshold overrides this level.
noise_threshold
No
Float
Noise threshold, range [0.0, 4.0]. For some audio segments, a larger value makes it more likely to be judged as noise; a smaller value makes it more likely to be judged as human voice. If omitted, the server default applies.
speaker_diarization
No
Integer
Real-time speaker diarization:
0 off.
1 on (anonymous clustering).
3 on, plus role authentication; use together with voiceprint_ids or speaker_roles.
Default 0.
Note:
When set to 1 or 3, the server forces VAD on and adjusts word_info.
enable_speaker_context
No
Integer
Resume speaker diarization from a breakpoint:
0 off;
1 return the recovery state synchronously;
2 return immediately in the first response (ID only);
Use together with speaker_diarization=1/3.
voiceprint_ids
No
String Array
IDs of registered voiceprints to match in real time. The values are obtained through the voiceprint registration API. It is an array supporting up to 32 voiceprints. Takes effect only when speaker_diarization=3. Example: ["550e8400-e29b-41d4-a716-446655440000","550e8400-e29b-41d4-a716-446655440002"].
speaker_roles
No
Object Array
Temporary voiceprints, valid only for this recognition and only when speaker_diarization=3. Format: [{"audio_url":"...","role_name":"..."}]. When matched, role_name is echoed in the speaker_name of the recognition result.
max_speak_time
No
Integer
Forced sentence break, range 5000-90000 (in ms), default 60000. When speech continues without a pause, this parameter forces a sentence break (the result becomes stable, slice_type=2). For example, in game commentary where the commentator speaks continuously, setting this to 10000 produces a slice_type=2 callback every 10 seconds.
filter_dirty
No
Integer
Whether to filter profanity (Mandarin only). Default 0.
0 do not filter.
1 filter.
2 replace with *.
filter_modal
No
Integer
Whether to filter modal particles (Mandarin only). Default 0.
0 do not filter.
1 partial filtering.
2 strict filtering.
filter_punc
No
Integer
Whether to filter the period at the end of a sentence (Mandarin only). Default 0.
0 do not filter.
1 filter.
filter_empty_result
No
Integer
Whether to deliver empty results:
0 deliver.
1 do not deliver.
Default 1.
convert_num_mode
No
Integer
Whether to intelligently convert numbers to Arabic numerals:
0 no conversion, output Chinese numerals directly.
1 convert intelligently based on context.
3 math mode.
Default 1.
word_info
No
Integer
Whether to show word-level timestamps:
0 no.
1 yes, without punctuation timestamps.
2 yes, with punctuation timestamps;
100 subtitle mode.
Default 0.
word_with_space
No
Integer
Whether to output spaces between English words. Default 0.
hotword_id
No
String
Hotword list ID (SDKAppID scope). Create the hotword list in the console first.
hotword_list
No
String
Temporary hotword list to improve recognition accuracy. Single hotword format: "hotword|weight". Each hotword must not exceed 30 characters (or 10 Chinese characters). Supported weights: 1-11 or 100. For example: "Tencent|5" or "ASR|11". Multiple hotwords must be separated by commas. A maximum of 128 hotwords is supported. For example: "hotword|10,Tencent|5,ASR|11".
Note:
A weight of 11 upgrades the hotword to a super hotword. Use this weight only for important terms that must take effect; configuring too many super hotwords may reduce overall recognition accuracy. A weight of 100 enables enhanced homophone replacement.
For example, if "site|100" is configured, recognition results such as "sight" or "cite", which share the same pronunciation, are forcibly replaced with "site". Use this setting only for important terms that must take effect; configuring too many such hotwords may reduce overall recognition accuracy. Hotwords cannot contain spaces.

Recognition Phase

Uploading Data

After authentication succeeds, the client keeps uploading binary messages to the backend containing the audio stream. Send a 40 ms audio packet every 40 ms (a 1:1 real-time rate); the PCM size is 640 bytes at 8 kHz and 1280 bytes at 16 kHz. A single frame must not exceed 256 KB. If the interval between audio packets exceeds 15 seconds, the backend returns 4008 and closes the connection.
When the audio stream has been fully uploaded, the client must send the following text message to tell the backend to finish recognition.
{"type": "end"}

Receiving Messages

While uploading, the client must receive real-time recognition results from the backend at the same time. Example result:
{
"code": 0,
"message": "success",
"voice_id": "23c33398-4da0-4ba7-b0ec-7565b325301d",
"message_id": "756d2992-5a23-488a-b391-9c9c0c36bedf",
"result": {
"slice_type": 0,
"index": 0,
"start_time": 0,
"end_time": 6000,
"voice_text_str": "Welcome to ASR.",
"language": "en",
"word_size": 0,
"word_list": []
}
}
After the backend has recognized all uploaded audio, it finally returns a message with final set to 1 and closes the connection.
{
"code": 0,
"message": "success",
"voice_id": "faab2b17-ba43-4ea4-be58-a03180ba26dd",
"message_id": "8d9e6337-2c8a-49e2-aee9-9179d71ab7a8",
"final": 1
}
If an error occurs during recognition, the backend returns a message with a non-zero code and closes the connection.
{
"code": 4008,
"message": "Timeout while waiting for audio segments from the server backend recognition.",
"voice_id": "faab2b17-ba43-4ea4-be58-a03180ba26dd",
"message_id": "8d9e6337-2c8a-49e2-aee9-9179d71ab7a8"
}

Recognition Result

Field
Type
Description
slice_type
Integer
Recognition result type:
0 a sentence starts being recognized.
1 a sentence is being recognized, voice_text_str is an unstable result (it may still change).
2 a sentence has been recognized, voice_text_str is a stable result (it will not change).
Depending on the audio sent, the slice_type sequences that may be returned are:
0-1-2 (sentence start, recognition in progress with possibly several 1 returns, sentence end).
0-2.
Or a direct 2 (the complete recognition result of a sentence).
index
Integer
Sequence number of this sentence in the whole audio stream, starting from 0 and increasing sentence by sentence.
start_time
Integer
Start time of this sentence in the whole audio stream.
end_time
Integer
End time of this sentence in the whole audio stream.
voice_text_str
String
Text result of this sentence, UTF-8 encoded.
language
String
Language recognized for this sentence, for example zh.
word_size
Integer
Number of words in this sentence (equal to the length of the word_list array).
word_list
Word Array
Word list of this sentence; see the structure below. Requires word_info != 0.
speaker_segments
SpeakerSegment Array
Returned when real-time speaker diarization is enabled; the speaker segments of the current sentence.
finish_silence_ms
Integer
Length of trailing silence (ms) that triggered the sentence break.
last_token_runtime_ms
Integer
Server decoding time of the last character (ms).

Word Structure

Field
Type
Description
word
String
Content of the word.
start_time
Integer
Start time of the word in the whole audio stream.
end_time
Integer
End time of the word in the whole audio stream.
stable_flag
Integer
Stability of the word:
0 the word may change in later recognition.
1 the word will not change in later recognition.
speaker_id
Integer
Present when real-time speaker diarization is enabled.
-1 unknown speaker.
>0 speaker ID.
speaker_name
String
Identifier of the registered-voiceprint speaker.

Speaker Diarization

After speaker_diarization is enabled, speaker labels are returned through two entry points:
result.speaker_segments[] (recommended): one result may contain several speakers, and sentence-level attribution is inherently ambiguous, so the protocol returns results split into segments by speaker. len(speaker_segments) == 1 means a single-speaker sentence.
result.word_list[].speaker_id: word-level attribution; word_info != 0 must also be set.
speaker_id semantics: valid within a session, numbered from 1; -1 means unknown speaker; 0 is reserved.

speaker_segments Fields

Field
Type
Description
speaker_id
Integer
Speaker ID.
-1 unknown speaker.
>0 speaker ID.
speaker_name
String
Identifier of the registered-voiceprint speaker. Returned only when speaker_diarization=3 and a registered voiceprint is matched; equal to the request-side role_name.
start_time
Integer
Segment start time (ms).
end_time
Integer
Segment end time (ms).
text
String
Text of this segment.
word_start
Integer
Start index into word_list (inclusive). Not returned when word_info=0.
word_end
Integer
End index into word_list (inclusive), i.e. word_list[word_start:word_end+1]. Not returned when word_info=0.
stable_flag
Integer
Whether the result is stable:
1 stable.
0 unstable.

VAD Tuning

Method
Value
Description
SetVadLevel(level)
0 / 1
0 high recall.
1 far-field filtering (server default).
SetNoiseThreshold(v)
0.0 - 4.0
Fine-tunes noise suppression: the larger the value, the stronger the suppression and the lower the recall. Once set, it overrides the vad_level level.
SetVadSilenceTime(ms)
240 - 2000
Silence threshold for sentence breaks.
Both are tri-state: they are sent only when the setter is called explicitly, so an explicit 0 can be distinguished from "not configured" (the server default for vad_level is 1). Out-of-range values cause a local error at Start() and do not waste a connection.

Developer Resources

Installation

go get github.com/Tencent-RTC/trtc-asr-sdk-go@latest
Requires Go 1.21 or later.

SDKs

Tencent-RTC SDK for Go: GitHub
Tencent-RTC SDK for Python: GitHub
Tencent-RTC SDK for Node.js: GitHub
Tencent-RTC SDK for Java: GitHub
Tencent-RTC SDK for Rust: GitHub
Tencent-RTC SDK for C++: GitHub

SDK Examples

Initialize Credentials

import (
v3 "github.com/Tencent-RTC/trtc-asr-sdk-go/asr/v3"
"github.com/Tencent-RTC/trtc-asr-sdk-go/common"
)

// The first argument is the SDKAppID (such as 1400xxxxxx); v3 does not need a Tencent Cloud AppID.
credential := v3.NewCredential(sdkAppID, "your-sdk-secret-key")
credential.SetSite(common.SiteIntl) // International site; required. It selects the host and the verification cluster.

Start Real-Time Recognition

type MyListener struct{ v3.UnimplementedSpeechRecognitionListener }

func (l *MyListener) OnSentenceEnd(resp *v3.SpeechRecognitionResponse) {
log.Printf("Sentence end: %s", resp.Result.VoiceTextStr)
}
func (l *MyListener) OnFail(resp *v3.SpeechRecognitionResponse, err error) {
log.Printf("Failed: %v", err) // err is *common.ASRError; Code is the server error code
}

recognizer := v3.NewSpeechRecognizer(credential, "bigmodel", &MyListener{})
recognizer.SetLanguage("zh") // with bigmodel, setting the language explicitly is recommended
if err := recognizer.Start(); err != nil {
log.Fatal(err) // authentication failures / invalid parameters are returned synchronously here
}
// recognizer.Write(pcmChunk) ... send audio in a loop
recognizer.Stop() // sends {"type":"end"} and waits for final

Enable Speaker Diarization

recognizer := v3.NewSpeechRecognizer(credential, "bigmodel", &MyListener{})
recognizer.SetLanguage("zh")
recognizer.SetWordInfo(1) // enable when word-level speakers are needed
recognizer.SetSpeakerDiarization(v3.SpeakerDiarizationCluster) // 1: anonymous clustering

// Voiceprint role authentication (returns role names):
// recognizer.SetSpeakerDiarization(v3.SpeakerDiarizationVoiceprint) // 3
// recognizer.SetSpeakerRoles([]v3.SpeakerRole{
// {RoleName: "teacher", AudioURL: "https://example.com/teacher.wav"},
// })
// recognizer.SetVoiceprintIDs([]string{"vp-1"}) // registered voiceprints

// Read segment results in the callback:
func (l *MyListener) OnSentenceEnd(resp *v3.SpeechRecognitionResponse) {
for _, seg := range resp.Result.SpeakerSegments {
name := seg.SpeakerName // only present when speaker_diarization=3
if name == "" {
name = fmt.Sprintf("spk%d", seg.SpeakerID)
}
log.Printf("[%s] %s", name, seg.Text)
}
}

Run the Example

# Get the example code (the examples directory is in the SDK repository)
git clone https://github.com/Tencent-RTC/trtc-asr-sdk-go.git
cd trtc-asr-sdk-go

cd examples/v3_realtime_asr
go run main.go -e bigmodel -f ../test.pcm

# Speaker diarization (anonymous clustering + word-level speakers)
go run main.go -e bigmodel -f ../test.pcm -diarization 1 -word-info 1

# Speaker diarization (voiceprint role authentication, returns role names)
go run main.go -e bigmodel -f ../test.pcm -diarization 3 \\
-roles "teacher=https://example.com/teacher.wav,student=https://example.com/student.wav"

# Show all options
go run main.go -h

Configuration Options

Method
Description
Default
SetVoiceFormat(f)
Audio format.
1 (PCM)
SetNeedVad(v)
Whether to enable VAD (an explicit 0 is actually sent to turn it off).
1 (on)
SetConvertNumMode(m)
Number conversion: 0 none / 1 smart / 3 math (an explicit 0 takes effect).
1 (smart)
SetHotwordID(id)
Hotword list ID (SDKAppID scope).
-
SetHotwordList(list)
Temporary hotword list word|weight,....
-
SetFilterDirty(m)
Profanity filtering.
0 (off)
SetFilterModal(m)
Modal particle filtering.
0 (off)
SetFilterPunc(m)
Period filtering.
0 (off)
SetFilterEmptyResult(m)
Whether to call back empty results.
1 (no callback)
SetWordInfo(m)
Word/character-level timing: 0 off / 1 on / 2 with punctuation / 100 subtitles.
0 (off)
SetWordWithSpace(m)
Output spaces between English words.
0 (off)
SetVadSilenceTime(ms)
VAD silence threshold (240-2000).
800 ms
SetVadLevel(level)
VAD scenario level: 0 high recall / 1 far-field filtering.
1
SetNoiseThreshold(v)
VAD noise fine-tuning (0.0-4.0); overrides the scenario level.
Not set
SetMaxSpeakTime(ms)
Forced sentence-break time (5000-90000).
60000 ms
SetInputSampleRate(r)
Input PCM sample rate; only 8000.
-
SetSpeakerDiarization(m)
Speaker diarization: 0 off / 1 clustering / 3 voiceprint roles.
0 (off)
SetSpeakerRoles(roles)
Temporary voiceprint roles (mode 3 only, {RoleName, AudioURL}).
-
SetVoiceprintIDs(ids)
Registered voiceprint IDs (mode 3 only).
-
SetLanguage(lang)
Specify the recognition language.
Auto-detect
SetVoiceID(id)
Custom voice_id (the UserSig is bound to this value automatically).
Auto UUID

Error Codes

Code
Description
4000
Too much audio data sent.
Note:
Real-time recognition works as "text appears while speaking"; the total duration of audio sent within 1 second should be 1 second.
4001
Invalid parameter; see message for details.
4002
Authentication failed. Check that sdkappid and usersig were passed correctly in the auth block of the first message, that the signature identifier equals the current voice_id, and that the signature is valid and not expired.
4003
The service is not activated for this AppID. Activate it in the console.
4004
Resource package exhausted. Enable pay-as-you-go billing or purchase a resource package.
4005
Service stopped because the account is overdue. Please top up promptly.
4006
The account's current concurrent calls exceed the limit.
4007
Audio decoding failed. Check that the uploaded audio format matches the call parameters.
4008
Timeout. The first message was not sent within 3 seconds after the connection was established, or no audio was sent for 15 seconds during recognition.
4009
Client connection disconnected.
4010
Client uploaded an unknown text message. The first-message JSON is invalid, or type is not start.
5000
Failure caused by high server load, network jitter, etc. Please start a new recognition.
Note:
This is usually transient. A small number of occurrences can be ignored; just start a new recognition.
5001
Same as 5000.
5002
Same as 5000.
SDK local error codes: The error returned by the SDK is *common.ASRError, and its Code is the server error code. Local SDK errors use the 10xx range, for example 1001 (local parameter error) and 1002 (connection failed).