Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

HTTP Interface

Updated on 2023-11-10 GMT+08:00

Functions

This API is used for real-time recognition of short sentences. The audio duration cannot exceed 30s.

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 Message

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

Audio data (encoded by Base64). The size of the encoded audio data cannot exceed 2 MB. The audio duration cannot exceed 30 seconds. 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

Audio format. For details about the supported audio formats, 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. Currently, the international website does not support this parameter.

vocabulary_id

No

String

Hot word table ID. If no hot word table is used, this field can be left blank. Currently, the international website does not support this parameter.

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. Currently, this parameter is not supported on HUAWEI CLOUD (International).

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

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.

Table 6 Value range of property

Value

Description

english_8k_common

English speech recognition with a sampling rate of 8 kHz

english_16k_common

English speech recognition with a sampling rate of 16 kHz

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 Currently, this parameter is not supported on HUAWEI CLOUD (International).

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 returned when the API fails to be called. This parameter is not included when the API is successfully called.

error_msg

String

Error message when the API call fails. This parameter is not included when the API is successfully called.

Example Requests

NOTE:

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": "english_8k_common",
        "add_punc": "yes",
      },
      "data": "/+MgxAAUeHpMAUkQAANhuRAC..."
    }

Example Responses

Status code: 200

Example response (successful request)

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

Status code: 400

Failure response example

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

Status Codes

For details about status codes, see Status Codes.

Error Codes

For details about error codes, see Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback