Skip to content

Commit

Permalink
closed captions documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Oct 8, 2024
1 parent 9382d47 commit a8b07f4
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 2 deletions.
162 changes: 162 additions & 0 deletions docusaurus/video/docusaurus/docs/api/transcription/closed_captions.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
---
id: closed-captions
sidebar_position: 2
title: Closed captions
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import apiJson from '../video-client-openapi.json';
import OpenApiModels from '../_common_/OpenApiModels.jsx';

The Stream API supports adding real-time closed captions (subtitles for participants) to your calls.

## Call and call type settings

Make sure that the closed caption feature is enabled in your app's dashboard. The closed caption feature can be set on the call type level, and the available options are:

- `available`: the feature is available for your call, but you need to explicitly start closed captioning with an API call.
- `disabled`: the feature is not available for your call
- `auto-on`: the feature is available and will be started automatically once the user is connected to the call.

It's also possible to override the call type's default when creating/updating a call:

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
// Call type level
client.video.updateCallType({
name: 'default',
settings: {
transcription: {
mode: 'available',
closed_caption_mode: 'available',
},
},
});

// Call level
await call.getOrCreate({
data: {
settings_override: {
transcription: {
mode: 'available',
closed_caption_mode: 'available',
},
},
created_by_id: 'john',
},
});
```

</TabItem>
<TabItem value="curl" label="cURL">

```bash
# Call type level
curl -X PUT "https://video.stream-io-api.com/api/v2/video/calltypes/${CALL_TYPE_NAME}?api_key=${API_KEY}" \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"settings_override": {
"transcription": {
"mode": "available",
"closed_caption_mode": "available"
}
}
}'

# Call level
curl -X POST "https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE}/${CALL_ID}?api_key=${API_KEY}" \
-H "Authorization: ${TOKEN}" \
-H "Content-Type: application/json" \
-H "stream-auth-type: jwt" \
-d '{
"data": {
"created_by_id": "john",
"settings_override": {
"transcription": {
"mode": "available",
"closed_caption_mode": "available"
}
}
}
}'
```

</TabItem>
</Tabs>

## Start-stop closed captions

If you set `closed_caption_mode` to `available` you need to start closed caption events when you want to see captions:

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
await call.startClosedCaptions();

// to end
await call.stopClosedCaptions();
```

</TabItem>
<TabItem value="curl" label="cURL">

```bash
curl -X POST "https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE}/${CALL_ID}/start_closed_captions?api_key=${API_KEY}" \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt"

# to end
curl -X POST "https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE}/${CALL_ID}/stop_closed_captions?api_key=${API_KEY}" \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt"
```

</TabItem>
</Tabs>

## Closed captioning status

This is how you can check if closed captioning is currently in progress or not:

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
const response = await call.get();

// if true closed captioning is in progress
console.log(response.call.captioning);
```

</TabItem>
<TabItem value="curl" label="cURL">

```bash
curl -X GET "https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE}/${CALL_ID}?api_key=${API_KEY}" \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt"
```

</TabItem>
</Tabs>

The following events are emitted when closed captioning status changes:

- [`CallClosedCaptionsStartedEvent`](../../streaming/events/#CallClosedCaptionsStartedEvent) - emitted when closed captioning was started (either by API call or automatically)
- [`CallClosedCaptionsStoppedEvent`](../../streaming/events/#CallClosedCaptionsStoppedEvent) - emitted when closed captioning was stopped (either by API call or automatically)
- [`CallClosedCaptionsFailedEvent`](../../streaming/events/#CallClosedCaptionsFailedEvent) - emitted when closed captioning failed to start, or an unexpected error occurred during captioning

## Closed caption events

Once closed captioning is started, clients will start receiving closed caption events.

<OpenApiModels
modelName={'ClosedCaptionEvent'}
apiJson={apiJson}
></OpenApiModels>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: storage
sidebar_position: 2
sidebar_position: 3
slug: /transcribing/storage
title: Storage
---
Expand Down

Large diffs are not rendered by default.

0 comments on commit a8b07f4

Please sign in to comment.