Speech to Text (ASR)

Convert the speech content in an audio or video file into text. Supports multiple language codes and can return sentence-level or word-level timestamps. If you already have the exact script, pass it in for script alignment to get timestamps for every sentence and word of your script. For multi-person conversations, speaker diarization labels every sentence with who said it.

Prefer not to code? Upload files and process them in Gitruck Toolbox. Just sign in; results match this API.Open Audio to Text →

Create Task

Basic Information

ItemValue
Request MethodPOST
Request Path/task/asr
Content-Typeapplication/json
AuthenticationRaw API key in the Authorization header

Request Body

ParameterTypeRequiredDefaultDescription
file_idstringYes-Uploaded audio or video file ID
languagestringNo"zh-CN"Standard locale language code. See the full supported list below
word_levelbooleanNofalseWhether to return word-level timestamps. Word-level timestamps cover these 18 languages: zh-CN, zh-HK, en-US, ja-JP, ko-KR, fr-FR, de-DE, it-IT, es-ES, es-MX, pt-PT, pt-BR, ru-RU, ar-SA, fil-PH, id-ID, ms-MY, th-TH. For any other language, word_tc_list is empty and word_count is 0; sentence-level results and the full text are unaffected
script_textstringNo-Known script text, up to 20000 characters. A non-empty script switches the task to script alignment mode: no content recognition, timestamps are produced for your script
speaker_diarizationbooleanNofalseWhen true, enables speaker diarization: every sentence gets a speaker number; priced separately
speaker_countnumberNo-Known number of speakers (2–10). Only valid with speaker_diarization: true; detected automatically when omitted

Supported Language Codes

Pass the standardized locale code in language. The current implementation accepts 103 values:

Codes outside this list are rejected at submission time with 400 / error code 6015. No credits are charged and no task is queued; the error message suggests an actionable alternative (for Cantonese, use zh-HK).

Request languageLanguage name
zh-CNChinese (China)
en-USEnglish (United States)
ja-JPJapanese (Japan)
ko-KRKorean (South Korea)
fr-FRFrench (France)
de-DEGerman (Germany)
es-MXSpanish (Mexico)
es-ESSpanish (Spain)
pt-BRPortuguese (Brazil)
pt-PTPortuguese (Portugal)
ru-RURussian (Russia)
zh-HKChinese (Hong Kong SAR China)
id-IDIndonesian (Indonesia)
fil-PHFilipino (Philippines)
ms-MYMalay (Malaysia)
th-THThai (Thailand)
ar-SAArabic (Saudi Arabia)
af-ZAAfrikaans (South Africa)
am-ETAmharic (Ethiopia)
as-INAssamese (India)
az-AZAzerbaijani (Azerbaijan)
ba-RUBashkir (Russia)
be-BYBelarusian (Belarus)
bg-BGBulgarian (Bulgaria)
bn-INBangla (India)
bo-CNTibetan (China)
br-FRBreton (France)
bs-BABosnian (Bosnia & Herzegovina)
ca-ESCatalan (Spain)
cs-CZCzech (Czechia)
cy-GBWelsh (United Kingdom)
da-DKDanish (Denmark)
el-GRGreek (Greece)
et-EEEstonian (Estonia)
eu-ESBasque (Spain)
fa-IRPersian (Iran)
fi-FIFinnish (Finland)
fo-FOFaroese (Faroe Islands)
gl-ESGalician (Spain)
gu-INGujarati (India)
ha-NGHausa (Nigeria)
haw-USHawaiian (United States)
he-ILHebrew (Israel)
hi-INHindi (India)
hr-HRCroatian (Croatia)
ht-HTHaitian Creole (Haiti)
hu-HUHungarian (Hungary)
hy-AMArmenian (Armenia)
is-ISIcelandic (Iceland)
it-ITItalian (Italy)
jw-IDJavanese (Indonesia)
ka-GEGeorgian (Georgia)
kk-KZKazakh (Kazakhstan)
km-KHKhmer (Cambodia)
kn-INKannada (India)
la-VALatin (Vatican City)
lb-LULuxembourgish (Luxembourg)
ln-CDLingala (Congo - Kinshasa)
lo-LALao (Laos)
lt-LTLithuanian (Lithuania)
lv-LVLatvian (Latvia)
mg-MGMalagasy (Madagascar)
mi-NZMāori (New Zealand)
mk-MKMacedonian (North Macedonia)
ml-INMalayalam (India)
mn-MNMongolian (Mongolia)
mr-INMarathi (India)
mt-MTMaltese (Malta)
my-MMBurmese (Myanmar (Burma))
ne-NPNepali (Nepal)
nl-NLDutch (Netherlands)
nn-NONorwegian Nynorsk (Norway)
no-NONorwegian (Norway)
oc-FROccitan (France)
pa-INPunjabi (India)
pl-PLPolish (Poland)
ps-AFPashto (Afghanistan)
ro-RORomanian (Romania)
sa-INSanskrit (India)
sd-INSindhi (India)
si-LKSinhala (Sri Lanka)
sk-SKSlovak (Slovakia)
sl-SISlovenian (Slovenia)
sn-ZWShona (Zimbabwe)
so-SOSomali (Somalia)
sq-ALAlbanian (Albania)
sr-RSSerbian (Serbia)
su-IDSundanese (Indonesia)
sv-SESwedish (Sweden)
sw-KESwahili (Kenya)
ta-INTamil (India)
te-INTelugu (India)
tg-TJTajik (Tajikistan)
tk-TMTurkmen (Turkmenistan)
tl-PHFilipino (Philippines)
tr-TRTurkish (Türkiye)
tt-RUTatar (Russia)
uk-UAUkrainian (Ukraine)
ur-PKUrdu (Pakistan)
uz-UZUzbek (Uzbekistan)
vi-VNVietnamese (Vietnam)
yi-DEYiddish (Germany)
yo-NGYoruba (Nigeria)

Tip: fil-PH and tl-PH are both accepted. For Cantonese content from Hong Kong, prefer zh-HK.

Script Alignment Mode

Built for read-from-script audio such as voice-overs and talking-head recordings: you already have the exact script and only need where it falls in the audio. When script_text is passed:

  • No content recognition: asr_text is your script verbatim, sentence_tc_list follows the sentences of your script (sentence text without sentence-break punctuation), and word_tc_list gives a timestamp for every word or character of the script — non-empty regardless of word_level.
  • Only these 13 languages: zh-CN, zh-HK, en-US, ja-JP, ko-KR, fr-FR, de-DE, it-IT, es-ES, es-MX, pt-PT, pt-BR, ru-RU. Any other language in script alignment mode is rejected at submission time with 400 / error code 6015 (the message lists the usable codes). No credits are charged and no task is queued.
  • The script must broadly match the audio: small word differences are usually fine; large mismatches, such as a whole paragraph that was never read or a different script altogether, make the task fail (it does not fall back to recognition results).
  • Same output format as recognition mode, with one extra output_result key: mode, whose value is script.
  • Billed the same as recognition mode (per minute of audio). A script longer than 20000 characters, or one that is not a string, is rejected at submission time with 400 / error code 6016, free of charge.

Speaker Diarization

For multi-person conversations such as meetings, interviews and podcasts, pass speaker_diarization: true and every sentence of the same transcript is labeled with who said it:

  • Every sentence carries a speaker number: sentence_tc_list[].speaker starts at 1, numbered in order of who speaks first. You also get speaker_list (total speaking seconds per person) and speaker_segments (speaker time ranges, handy for drawing a timeline or jumping to someone's voice). Numbers are only meaningful within this file; you name who number 1 is.
  • Pass speaker_count if you know it (2–10): without it the number of speakers is detected automatically, which now and then splits one person into an extra speaker with only a line or two. Passing the count avoids that.
  • Always recognized as word_level: true: sentences keep their punctuation so the transcript reads well; the word_level you pass has no effect in this mode.
  • Short interjections are sometimes misattributed: very short replies like “yeah” or “mm” are occasionally credited to the person speaking next to them; longer turns are almost always right.
  • Not combinable with script_text: sentences in script alignment come from splitting your script, so the two modes are not combined for now.
  • Priced separately: billed per minute as “Speech to Text · Speaker Diarization”; see the price list (expand Speech to Text). If speaker diarization fails, the task fails and is refunded rather than returning a transcript without speakers.
  • A speaker_count that is not an integer from 2 to 10, a speaker_count without speaker_diarization: true, speaker_diarization together with script_text, or a non-boolean speaker_diarization is rejected at submission time with 400 / error code 6016, free of charge.
Prefer not to code? Upload files and process them in Gitruck Toolbox. Just sign in; results match this API.Open Meeting & Interview Transcription →

Request Example

curl -X POST https://api.ai-mcn.tv:10000/task/asr \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "file_id": "537489015178246",
    "language": "zh-CN",
    "word_level": true
  }'

Script alignment mode (with script_text):

curl -X POST https://api.ai-mcn.tv:10000/task/asr   -H "Authorization: YOUR_API_KEY"   -H "Content-Type: application/json"   -d '{
    "file_id": "537489015178246",
    "language": "en-US",
    "script_text": "Today we talk about engineering discipline. Ship it, then talk."
  }'

Success Example

{
  "code": 200,
  "msg": "success",
  "data": {
    "task_id": "537489015178247",
    "task_type": "asr",
    "status": "queued"
  }
}

Query Task Result

Basic Information

ItemValue
Request MethodGET
Request Path/task/asr/{task_id}
AuthenticationRaw API key in the Authorization header

Output Result (output_result)

The full transcription is delivered as a JSON file (its size grows linearly with audio duration). output_result itself only carries the file reference plus a summary. Download asr_result_download_url to get the complete transcription JSON.

ParameterTypeDescription
asr_result_file_idstringFile ID of the full transcription JSON
asr_result_download_urlstringDownload URL of the full transcription JSON
text_previewstringPreview of the recognized text (first 500 characters)
word_countnumberNumber of word-level timestamp entries
sentence_countnumberNumber of sentence-level timestamp entries
text_lengthnumberTotal character count of the full recognized text
modestringPresent only in script alignment mode, with value script; absent in recognition mode
speaker_countnumberPresent only with speaker diarization: number of speakers

Transcription File Content (JSON downloaded from asr_result_download_url)

ParameterTypeDescription
asr_textstringFull recognition text (the script verbatim in script alignment mode)
sentence_tc_listarraySentence-level timestamp list
sentence_tc_list[].textstringSentence text. Keeps the original punctuation (commas, periods, question marks, etc.) when word_level: true; punctuation is stripped when word_level: false. Token text in word_tc_list never carries punctuation in either mode
sentence_tc_list[].start_timenumberSentence start time
sentence_tc_list[].end_timenumberSentence end time
word_tc_listarrayWord-level timestamps. In recognition mode, non-empty only when word_level: true and the language is covered by word-level timestamps; always non-empty in script alignment mode
word_tc_list[].textstringWord or token text
word_tc_list[].start_timenumberStart time
word_tc_list[].end_timenumberEnd time
sentence_tc_list[].speakernumberPresent only with speaker diarization: the speaker number of this sentence, starting at 1
speaker_listarrayPresent only with speaker diarization: [{speaker, duration_sec}], total speaking seconds per person
speaker_segmentsarrayPresent only with speaker diarization: [{speaker, start_time, end_time}], speaker time ranges in seconds

The transcription file shares the same lifecycle as other media outputs (cleaned up on expiry). Download and archive it promptly after the task completes.

Success Example

{
  "code": 200,
  "msg": "success",
  "data": {
    "task_id": "537489015178247",
    "status": "completed",
    "progress": 100,
    "output_result": {
      "asr_result_file_id": "537489015178301",
      "asr_result_download_url": "https://api.ai-mcn.tv:9000/cloud/file/ab/537489015178301.json",
      "text_preview": "Hello world, this is a test clip.",
      "word_count": 2,
      "sentence_count": 1,
      "text_length": 33
    },
    "create_time": "2026-04-05T08:00:00Z",
    "update_time": "2026-04-05T08:00:10Z"
  }
}

Transcription File Example (downloaded content)

{
  "asr_text": "Hello world, this is a test clip.",
  "sentence_tc_list": [
    { "text": "Hello world, this is a test clip.", "start_time": 0.0, "end_time": 3.5 }
  ],
  "word_tc_list": [
    { "text": "Hello", "start_time": 0.0, "end_time": 0.6 },
    { "text": "world", "start_time": 0.6, "end_time": 1.1 }
  ]
}

Transcription file with speaker diarization (excerpt):

{
  "asr_text": "Let's start with this page. Sure.",
  "sentence_tc_list": [
    { "text": "Let's start with this page.", "start_time": 0.0, "end_time": 2.0, "speaker": 1 },
    { "text": "Sure.", "start_time": 2.2, "end_time": 2.8, "speaker": 2 }
  ],
  "word_tc_list": [],
  "speaker_list": [
    { "speaker": 1, "duration_sec": 2.1 },
    { "speaker": 2, "duration_sec": 0.8 }
  ],
  "speaker_segments": [
    { "speaker": 1, "start_time": 0.0, "end_time": 2.1 },
    { "speaker": 2, "start_time": 2.1, "end_time": 2.9 }
  ]
}

Error Codes

Error CodeHTTP StatusDescriptionResolution
6013400Missing file_idPass the file_id field
6015400Unsupported language code (in script alignment mode: not one of the 13 alignment languages)Switch to a code from the table above, or to an alignment language in script alignment mode. The error message suggests usable codes
6016400script_text is longer than 20000 characters or is not a string; speaker_count is not an integer from 2 to 10 or is passed without speaker_diarization: true; speaker_diarization is passed with script_text or is not a booleanFix the parameter named in the error message and try again
6004404File not foundVerify the file_id
6502401Authentication failedCheck the Authorization header
6202402Insufficient balanceRecharge in the Dashboard