//native
type Telnyx = {
apiKey: string
}
/**
* Transcription start
* Start real-time transcription. Transcription will stop on call hang-up, or can be initiated via the Transcription stop command.
**Expected Webhooks (see [callback schema](https://developers.telnyx.com/api/call-control/start-call-transcription#callbacks) below):**
- `call.transcription`
*/
export async function main(
auth: Telnyx,
call_control_id: string,
body: {
transcription_engine?: 'A' | 'B'
language?:
| 'af'
| 'sq'
| 'am'
| 'ar'
| 'hy'
| 'az'
| 'eu'
| 'bn'
| 'bs'
| 'bg'
| 'my'
| 'ca'
| 'yue'
| 'zh'
| 'hr'
| 'cs'
| 'da'
| 'nl'
| 'en'
| 'et'
| 'fil'
| 'fi'
| 'fr'
| 'gl'
| 'ka'
| 'de'
| 'el'
| 'gu'
| 'iw'
| 'hi'
| 'hu'
| 'is'
| 'id'
| 'it'
| 'ja'
| 'jv'
| 'kn'
| 'kk'
| 'km'
| 'ko'
| 'lo'
| 'lv'
| 'lt'
| 'mk'
| 'ms'
| 'ml'
| 'mr'
| 'mn'
| 'ne'
| 'no'
| 'fa'
| 'pl'
| 'pt'
| 'pa'
| 'ro'
| 'ru'
| 'rw'
| 'sr'
| 'si'
| 'sk'
| 'sl'
| 'ss'
| 'st'
| 'es'
| 'su'
| 'sw'
| 'sv'
| 'ta'
| 'te'
| 'th'
| 'tn'
| 'tr'
| 'ts'
| 'uk'
| 'ur'
| 'uz'
| 've'
| 'vi'
| 'xh'
| 'zu'
| 'he'
| 'la'
| 'mi'
| 'cy'
| 'br'
| 'sn'
| 'yo'
| 'so'
| 'oc'
| 'be'
| 'tg'
| 'sd'
| 'yi'
| 'fo'
| 'ht'
| 'ps'
| 'tk'
| 'nn'
| 'mt'
| 'sa'
| 'lb'
| 'bo'
| 'tl'
| 'mg'
| 'as'
| 'tt'
| 'haw'
| 'ln'
| 'ha'
| 'ba'
| 'jw'
| 'auto_detect'
interim_results?: false | true
enable_speaker_diarization?: false | true
min_speaker_count?: number
max_speaker_count?: number
client_state?: string
transcription_tracks?: string
command_id?: string
}
) {
const url = new URL(
`https://api.telnyx.com/v2/calls/${call_control_id}/actions/transcription_start`
)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.apiKey
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 428 days ago