Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closed captions documentation #770

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading