POST
/
transcriptions
/
async-generate-speaker
Async Generate Speaker
curl --request POST \
  --url https://mavi-backend.memories.ai/serve/api/v2/transcriptions/async-generate-speaker \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "asset_id": "re_657929111888723968"
}
'
{
  "code": "0000",
  "msg": "success",
  "data": {
    "task_id": "ec2449885ba84c4f943a80ff0633158e"
  },
  "failed": false,
  "success": true
}
This endpoint allows you to identify speakers asynchronously.

Code Example

import requests

BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2/transcriptions"
API_KEY = "sk-5f8843b8c0641efd5a3a6478b7679caa"
HEADERS = {
    "Authorization": f"{API_KEY}"
}

def async_generate_speaker(asset_id: str):
    url = f"{BASE_URL}/async-generate-speaker"
    data = {"asset_id": asset_id}
    resp = requests.post(url, json=data, headers=HEADERS)
    return resp.json()

# Usage example
result = async_generate_speaker("re_657929111888723968")
print(result)

Response

Returns the speaker identification task information.
{
  "code": "0000",
  "msg": "success",
  "data": {
    "task_id": "ec2449885ba84c4f943a80ff0633158e"
  },
  "failed": false,
  "success": true
}

Response Parameters

ParameterTypeDescription
codestringResponse code indicating the result status
msgstringResponse message describing the operation result
dataobjectResponse data object containing task information
data.task_idstringUnique identifier of the speaker identification task
successbooleanIndicates whether the operation was successful
failedbooleanIndicates whether the operation failed

Callback Response Parameters

When the speaker identification is complete, a callback will be sent to your configured webhook URL.
ParameterTypeDescription
codestringResponse code (“0000” indicates success)
messagestringStatus message (e.g., “SUCCESS”)
dataobjectResponse data object containing the speaker diarization result and metadata
data.dataobjectInner data object containing speaker segments and usage information
data.data.dataarrayArray of speaker segments with timestamps
data.data.data[].startnumberStart time of the speaker segment in seconds
data.data.data[].endnumberEnd time of the speaker segment in seconds
data.data.data[].speakerstringSpeaker identifier (e.g., “SPEAKER_00”, “SPEAKER_06”)
data.data.usage_metadataobjectUsage statistics for the API call
data.data.usage_metadata.durationnumberTotal audio duration in seconds
data.data.usage_metadata.modelstringThe model used for speaker diarization (e.g., “pyannote”)
data.data.usage_metadata.output_tokensintegerNumber of output tokens (0 for speaker diarization)
data.data.usage_metadata.prompt_tokensintegerNumber of prompt tokens (0 for speaker diarization)
data.msgstringDetailed message about the operation result
data.successbooleanIndicates whether the speaker identification was successful
task_idstringThe task ID associated with this speaker identification request

Understanding the Callback Response

The callback response has a nested structure with the speaker segments and usage information inside data.data. Response Structure:
callback_response
├── code: "0000"
├── message: "SUCCESS"
├── data
│   ├── data
│   │   ├── data: [array of speaker segments]
│   │   │   └── [
│   │   │       {
│   │   │         start: 0.43596875,
│   │   │         end: 1.68471875,
│   │   │         speaker: "SPEAKER_06"
│   │   │       },
│   │   │       ...
│   │   │     ]
│   │   └── usage_metadata
│   │       ├── duration: 20.75346875
│   │       ├── model: "pyannote"
│   │       ├── output_tokens: 0
│   │       └── prompt_tokens: 0
│   ├── msg: "Speech diarization completed successfully"
│   └── success: true
└── task_id: "0d2d50fbdd0c4597a6a45c0359a42d76"
How to access the data:
  • Speaker segments: callback_response.data.data.data
  • First segment speaker: callback_response.data.data.data[0].speaker
  • First segment time range: callback_response.data.data.data[0].start to callback_response.data.data.data[0].end
  • Usage statistics: callback_response.data.data.usage_metadata
  • Audio duration: callback_response.data.data.usage_metadata.duration
  • Model used: callback_response.data.data.usage_metadata.model
  • Success status: callback_response.data.success
  • Task ID: callback_response.task_id

Authorizations

Authorization
string
header
required

Body

application/json
asset_id
string
required

The asset ID to identify speakers for

Example:

"re_657929111888723968"

Response

200 - application/json

Speaker identification task information

code
string

Response code indicating the result status

Example:

"0000"

msg
string

Response message describing the operation result

Example:

"success"

data
object

Response data object containing task information

success
boolean

Indicates whether the operation was successful

Example:

true

failed
boolean

Indicates whether the operation failed

Example:

false