|
| 1 | +--- |
| 2 | +id: startTranscription |
| 3 | +title: Start Transcription |
| 4 | +slug: /voice/bxml/startTranscription |
| 5 | +description: A general overview of Bandwidth's startTranscription BXML Verb |
| 6 | +keywords: |
| 7 | + - bandwidth |
| 8 | + - voice |
| 9 | + - bxml |
| 10 | + - start |
| 11 | + - transcribing |
| 12 | +hide_title: false |
| 13 | +image: ../../static/img/bandwidth-logo.png |
| 14 | +--- |
| 15 | + |
| 16 | +import Tabs from '@theme/Tabs'; |
| 17 | +import TabItem from '@theme/TabItem'; |
| 18 | + |
| 19 | +The `StartTranscription` verb allows a segment of a call to be transcribed, and optionally for the live transcription to be sent off to another destination for additional processing. |
| 20 | +The transcription will continue until the call ends or the [`<StopTranscription>`][1] verb is used. |
| 21 | +When a `destination` is specified, live transcription updates for one or both sides (tracks) of the call will be sent to the specified destination. |
| 22 | +A total of 4 concurrent track transcriptions are allowed on a call. A `<StartTranscription>` request that uses `both` tracks will count as 2 of the permitted 4 concurrent track transcriptions. |
| 23 | + |
| 24 | +A call has only two tracks, which are named after the direction of the media from the perspective of the Programmable Voice platform: |
| 25 | +- `inbound`: media received by Programmable Voice from the call executing the BXML; |
| 26 | +- `outbound`: media sent by Programmable Voice to the call executing the BXML. |
| 27 | + |
| 28 | +Note that this has no correlation to the direction of the call itself. For example, if either an inbound or outbound call is being transcribed and executes a `<SpeakSentence>`, the `inbound` track will be the callee's audio and the `outbound` track will be the text-to-speech audio. |
| 29 | + |
| 30 | +## Text Content |
| 31 | + |
| 32 | +There is no text content available to be set for the `<StartTranscription>` verb. |
| 33 | + |
| 34 | +## Attributes |
| 35 | + |
| 36 | +| Attribute | Description | |
| 37 | +|:-------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 38 | +| name | (optional) A name to refer to this transcription by. Used when sending [`<StopTranscription>`][1]. If not provided, it will default to the generated transcription id as sent in the [`Real-Time Transcription Started`][2] webhook. | |
| 39 | +| tracks | (optional) The part of the call to send a transcription from. `inbound`, `outbound` or `both`. Default is `inbound`. | |
| 40 | +| transcriptionEventUrl | (optional) URL to send the associated Webhook events to during this real-time transcription's lifetime. Does not accept BXML. May be a relative URL. | |
| 41 | +| transcriptionEventMethod | (optional) The HTTP method to use for the request to `transcriptionEventUrl`. GET or POST. Default value is POST. | |
| 42 | +| username | (optional) The username to send in the HTTP request to `transcriptionEventUrl`. If specified, the `transcriptionEventUrl` must be TLS-encrypted (i.e., `https`). | |
| 43 | +| password | (optional) The password to send in the HTTP request to `transcriptionEventUrl`. If specified, the `transcriptionEventUrl` must be TLS-encrypted (i.e., `https`). | |
| 44 | +| destination | (optional) A websocket URI to send the transcription to. A transcription of the specified tracks will be sent via websocket to this URL as a series of JSON messages. See below for more details on the websocket packet format. | |
| 45 | +| stabilized | (optional) Whether to send transcription update events to the specified `destination` only after they have become stable. Requires `destination`. Defaults to `true`. | |
| 46 | + |
| 47 | +If the `destination` and `transcriptionEventUrl` attributes are specified, then the [Real-Time Transcription Started][2], [Real-Time Transcription Rejected][3] and [Real-Time Transcription Stopped][4] events will be sent to the URL when the transcription starts, if there is an error starting the transcription and when the transcription ends respectively. BXML returned in response to this callback will be ignored. |
| 48 | +If the `transcriptionEventUrl` attribute is specified, then the [Real-Time Transcription Available][5] event will be sent once the transcription has ended providing a URL from where the transcription can be downloaded. BXML returned in response to this callback will be ignored. |
| 49 | + |
| 50 | +:::note |
| 51 | +While multiple real-time transcriptions for the same call are allowed, each real-time transcription MUST have a unique name. Attempting to start a real-time transcription on the same call with the name of an already existing real-time transcription will result in a [Real-Time Transcription Rejected][3] event. |
| 52 | +::: |
| 53 | + |
| 54 | +## Webhooks Received |
| 55 | + |
| 56 | +| Webhooks | Can reply with more BXML | |
| 57 | +|:---------------------------|:-------------------------| |
| 58 | +| [Real-Time Transcription Started][2] | No | |
| 59 | +| [Real-Time Transcription Rejected][3] | No | |
| 60 | +| [Real-Time Transcription Stopped][4] | No | |
| 61 | +| [Real-Time Transcription Available][5] | No | |
| 62 | + |
| 63 | +## Nested Tags |
| 64 | + |
| 65 | +You may specify up to 12 `<CustomParam/>` elements nested within a `<StartTranscription>` tag. These elements define optional user specified parameters that will be sent to the destination URL when the real-time transcription is first started. |
| 66 | + |
| 67 | +### CustomParam Attributes |
| 68 | + |
| 69 | +| Attribute | Description | |
| 70 | +|:----------|:---------------------------------------------------------------| |
| 71 | +| name | (required) The name of this parameter, up to 256 characters. | |
| 72 | +| value | (required) The value of this parameter, up to 2048 characters. | |
| 73 | + |
| 74 | +## Websocket Packet Format |
| 75 | + |
| 76 | +If a `destination` is specified, it will be sent JSON messages for the duration of the real-time transcription. There will be an initial `start` message when the connection is first established. This will be followed by zero or more `transcription` messages containing transcription updates for the tracks being transcribed. Finally, when a real-time transcription is stopped, a `stop` message will be sent. |
| 77 | + |
| 78 | +### Start and Stop Message Parameters |
| 79 | + |
| 80 | +| Parameter | Description | |
| 81 | +|:-------------|:------------| |
| 82 | +| eventType | What type of message this is, one of `start`, or `stop` | |
| 83 | +| metadata | Details about the real-time transcription this message is for. See further details below. | |
| 84 | +| customParams | (optional) (`start` message only) If any `<CustomParam/>` elements were specified in the `<StartTranscription>` request, they will be copied here as a map of `name : value` pairs | |
| 85 | + |
| 86 | +#### Metadata Parameters |
| 87 | + |
| 88 | +| Parameter | Description | |
| 89 | +|:------------------------------|:------------| |
| 90 | +| accountId | The user account associated with the call | |
| 91 | +| callId | The call id associated with the real-time transcription | |
| 92 | +| realTimeTranscriptionId | The unique id of the real-time transcription | |
| 93 | +| transcriptionName | The user supplied name of the real-time transcription | |
| 94 | +| tracks | A list of one or more tracks being transcribed in real-time | |
| 95 | +| tracks.name | The name of the track being transcribed, will be used to identify which transcription updates belong to which track | |
| 96 | +| stabilized | Whether transcription updates will be sent only after they have become stable or not | |
| 97 | + |
| 98 | +### Transcription Message Parameters |
| 99 | + |
| 100 | +| Parameter | Description | |
| 101 | +|:----------|:-----------------------| |
| 102 | +| eventType | Will always be `transcription` | |
| 103 | +| track | The name of the track this transcription update is for, will be one of the names specified in the `start` message | |
| 104 | +| startTime | The time at which this segment started | |
| 105 | +| endTime | The time at which this segment ended | |
| 106 | +| isPartial | Indicates if the segment is complete | |
| 107 | +| language | The detected language of the segment | |
| 108 | +| transcript | The transcription of this segment as a flattened string | |
| 109 | +| items | The list of items making up this segment | |
| 110 | +| items.content | A word or punctuation | |
| 111 | +| items.startTime | The time at which this item started | |
| 112 | +| items.endTime | The time at which this item ended | |
| 113 | +| items.confidence | The confidence score associated with a word or phrase in your transcript. | |
| 114 | +| items.stable | Indicates whether the specified item is stable (true) or if it may change when the segment is complete (false). | |
| 115 | +| items.type | Either `PRONUNCIATION` or `PUNCTUATION` | |
| 116 | + |
| 117 | +## Examples |
| 118 | + |
| 119 | +### A `start` Websocket Message |
| 120 | + |
| 121 | +```json |
| 122 | +{ |
| 123 | + "eventType": "start", |
| 124 | + "metadata": { |
| 125 | + "accountId": "5555555", |
| 126 | + "callId": "c-2a913f94-7fa91773-a426-4118-8b8b-b691ab0a0ae1", |
| 127 | + "realTimeTranscriptionId": "s-2a913f94-93e372e2-60da-4c89-beb0-0d3a219b287c", |
| 128 | + "transcriptionName": "live_audience", |
| 129 | + "tracks": [ |
| 130 | + { |
| 131 | + "name": "inbound", |
| 132 | + }, |
| 133 | + { |
| 134 | + "name": "outbound", |
| 135 | + } |
| 136 | + ] |
| 137 | + }, |
| 138 | + "customParams": { |
| 139 | + "foo": "bar", |
| 140 | + "foos": "bars" |
| 141 | + } |
| 142 | +} |
| 143 | +``` |
| 144 | + |
| 145 | +### A `transcription` Websocket Message |
| 146 | +```json |
| 147 | +{ |
| 148 | + "eventType": "transcription", |
| 149 | + "track": "inbound", |
| 150 | + "startTime": "2023-03-31T20:05.101Z", |
| 151 | + "endTime": "2023-03-31T20:07.493Z", |
| 152 | + "isPartial": false, |
| 153 | + "language": "en-US", |
| 154 | + "transcript": "hello world!", |
| 155 | + "items": [ |
| 156 | + { |
| 157 | + "content": "hello", |
| 158 | + "startTime": "2023-03-31T20:05.101Z", |
| 159 | + "endTime": "2023-03-31T20:06.285Z", |
| 160 | + "confidence": 0.9, |
| 161 | + "stable": true, |
| 162 | + "type": "PRONUNCIATION" |
| 163 | + }, |
| 164 | + { |
| 165 | + "content": "world", |
| 166 | + "startTime": "2023-03-31T20:06.984Z", |
| 167 | + "endTime": "2023-03-31T20:07.493Z", |
| 168 | + "confidence": 0.6, |
| 169 | + "stable": true, |
| 170 | + "type": "PRONUNCIATION" |
| 171 | + }, |
| 172 | + { |
| 173 | + "content": "!", |
| 174 | + "startTime": "2023-03-31T20:07.493Z", |
| 175 | + "endTime": "2023-03-31T20:07.493Z", |
| 176 | + "confidence": 0.9, |
| 177 | + "stable": false, |
| 178 | + "type": "PUNCTUATION" |
| 179 | + } |
| 180 | + ] |
| 181 | +} |
| 182 | +``` |
| 183 | + |
| 184 | +### A `stop` Websocket Message |
| 185 | + |
| 186 | +```json |
| 187 | +{ |
| 188 | + "eventType": "stop", |
| 189 | + "metadata": { |
| 190 | + "accountId": "5555555", |
| 191 | + "callId": "c-2a913f94-7fa91773-a426-4118-8b8b-b691ab0a0ae1", |
| 192 | + "realTimeTranscriptionId": "s-2a913f94-93e372e2-60da-4c89-beb0-0d3a219b287c", |
| 193 | + "transcriptionName": "live_audience", |
| 194 | + "tracks": [ |
| 195 | + { |
| 196 | + "name": "inbound", |
| 197 | + }, |
| 198 | + { |
| 199 | + "name": "outbound", |
| 200 | + } |
| 201 | + ] |
| 202 | + } |
| 203 | +} |
| 204 | +``` |
| 205 | + |
| 206 | +[1]: /docs/voice/bxml/stopTranscription |
| 207 | +[2]: /docs/voice/webhooks/realTimeTranscriptionStarted |
| 208 | +[3]: /docs/voice/webhooks/realTimeTranscriptionRejected |
| 209 | +[4]: /docs/voice/webhooks/realTimeTranscriptionStopped |
| 210 | +[5]: /docs/voice/webhooks/realTimeTranscriptionAvailable |
0 commit comments