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 4, 2024
1 parent 9382d47 commit 7544c8c
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 1 deletion.
130 changes: 130 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,130 @@
---
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 and can be started.
- `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 disable closed caption events
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"

# disable closed caption events
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 caption events

Once closed captions are 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

0 comments on commit 7544c8c

Please sign in to comment.