Asynchronous recognition API v2
To use the API v2, you will need:
- Yandex Object Storage bucket to upload your audio file to.
- Service account with the
ai.speechkit-stt.userandstorage.uploaderroles for accessing SpeechKit and Object Storage. - IAM token or API key for authentication.
Read more about the preparation steps in How to asynchronously recognize pre-recorded audio.
Warning
You can recognize audio files asynchronously only as a service account. Do not use any other Yandex Cloud accounts for this purpose.
The asynchronous recognition service for the API v2 is located at transcribe.api.cloud.yandex.net/speech/stt/v2/longRunningRecognize.
Sending a file for recognition
Request body parameters
The request body structure is as follows:
{
"config": {
"specification": {
"languageCode": "string",
"model": "string",
"profanityFilter": boolean,
"literature_text": boolean,
"audioEncoding": "string",
"sampleRateHertz": integer,
"audioChannelCount": integer,
"rawResults": boolean
}
},
"audio": {
"uri": "string"
}
}
|
Parameter |
Description |
|
config |
object |
|
config. |
object |
|
config. |
string |
|
config. |
string |
|
config. |
boolean
|
|
config. |
boolean |
|
config. |
string
|
|
config. |
integer (int64)
|
|
config. |
integer (int64) |
|
config. |
boolean
|
|
audio. |
string |
Response
If your request is written correctly, the service will return the Operation object with the recognition operation id:
{
"done": false,
"id": "e03sup6d5h1q********",
"createdAt": "2019-04-21T22:49:29Z",
"createdBy": "ajes08feato8********",
"modifiedAt": "2019-04-21T22:49:29Z"
}
Use this ID at the next step.
Getting recognition results
To check the operation status and get the recognition results, send a request at operation.api.cloud.yandex.net.
Monitor the recognition results using the ID you got. The number of result monitoring requests is limited: it takes about 10 seconds to recognize one minute of a single-channel audio file.
Warning
Recognition results are stored on the server for 3 days. Afterwards, you will not be able to request the recognition results using the ID you got.
Path parameters
| Parameter | Description |
|---|---|
| operationId | Operation ID received when sending the recognition request. |
Response
The Operation object is returned in response to your request. Response example:
{
"done": true,
"response": {
"@type": "type.googleapis.com/yandex.cloud.ai.stt.v2.LongRunningRecognitionResponse",
"chunks": [
{
"alternatives": [
{
"words": [
{
"startTime": "0.879999999s",
"endTime": "1.159999992s",
"word": "when",
"confidence": 1
},
{
"startTime": "1.219999995s",
"endTime": "1.539999988s",
"word": "writing",
"confidence": 1
},
...
],
"text": "when writing The Hobbit, Tolkien referred to the Norse mythology of the Old English poem Beowulf",
"confidence": 1
}
],
"channelTag": "1"
},
...
]
},
"id": "e03sup6d5h1q********",
"createdAt": "2019-04-21T22:49:29Z",
"createdBy": "ajes08feato8********",
"modifiedAt": "2019-04-21T22:49:36Z"
}
|
Parameter |
Description |
|
done |
boolean |
|
response |
object |
|
response. |
string |
|
response. |
array |
|
response. |
array |
|
response. |
array |
|
response. |
string |
|
response. |
string |
|
response. |
string |
|
response. |
integer (int64) |
|
response. |
string |
|
response. |
integer (int64) |
|
response. |
string |
|
id |
string |
|
createdAt |
google.protobuf.Timestamp |
|
createdBy |
string |
|
modifiedAt |
google.protobuf.Timestamp |
For more on response format and codes, see Response status codes.