Skip to content

Commit 9d545f9

Browse files
authored
Update closed-captions-teams-interop-web.md
Update format of doc and enhance code snippets
1 parent c0620f3 commit 9d545f9

File tree

1 file changed

+84
-46
lines changed

1 file changed

+84
-46
lines changed

articles/communication-services/how-tos/calling-sdk/includes/closed-captions/closed-captions-teams-interop-web.md

Lines changed: 84 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,20 @@ ms.service: azure-communication-services
66
ms.subservice: calling
77
ms.topic: include
88
ms.topic: include file
9-
ms.date: 03/20/20223
9+
ms.date: 03/20/2023
1010
ms.author: kpunjabi
1111
---
1212

1313
## Prerequisites
1414
- Azure account with an active subscription, for details see [Create an account for free.](https://azure.microsoft.com/free/)
1515
- Azure Communication Services resource. See [Create an Azure Communication Services resource](../../../quickstarts/create-communication-resource.md?tabs=windows&pivots=platform-azp). Save the connection string for this resource.
1616
- An app with voice and video calling, refer to our [Voice](../../quickstarts/voice-video-calling/getting-started-with-calling.md) and [Video](../../quickstarts/voice-video-calling/get-started-with-video-calling.md) calling quickstarts.
17-
- [Access tokesn](../../quickstarts/manage-teams-identity.md) for Microsoft 365 users.
18-
- [Access tokesn](../../quickstarts/identity/access-tokens.md) for External identity users.
19-
- For Translated captions you will need to have a [Teams premium] license.
17+
- [Access tokens](../../quickstarts/manage-teams-identity.md) for Microsoft 365 users.
18+
- [Access tokens](../../quickstarts/identity/access-tokens.md) for External identity users.
19+
- For Translated captions you will need to have a [Teams premium](/MicrosoftTeams/teams-add-on-licensing/licensing-enhance-teams#meetings) license.
2020

2121
>[!NOTE]
22-
>Please note that you will need to have a voice calling app using ACS calling SDKs to access the closed captions feature that is described in the quickstart below.
23-
24-
## Join a Teams meeting
25-
22+
>Please note that you will need to have a voice calling app using ACS calling SDKs to access the closed captions feature that is described in this guide.
2623
2724
## Models
2825
| Name | Description |
@@ -32,83 +29,124 @@ ms.author: kpunjabi
3229
| TeamsCaptionHandler | Callback definition for handling CaptionsReceivedEventType event |
3330
| TeamsCaptionsInfo | Data structure received for each CaptionsReceivedEventType event |
3431

35-
## Get captions feature for External Identity users
32+
## Get closed captions feature
33+
34+
### External Identity users
35+
36+
If you're building an application that allows ACS users to join a Teams meeting.
3637

3738
``` typescript
3839
let teamsCaptions: SDK.TeamsCaptionsCallFeature = call.feature(SDK.Features.TeamsCaptions);
3940
```
4041

41-
## Get captions feature for Microsoft 365 users on ACS SDK
42+
### Microsoft 365 users on ACS SDK
43+
44+
If you're building an app for Microsoft 365 Users using ACS SDK.
4245

4346
``` typescript
4447
let teamsCaptions: SDK.TeamsCaptionsCallFeature = teamsCall.feature(SDK.Features.TeamsCaptions);
4548
```
4649

47-
## Set captions handler and start captions
50+
## Subscribe to listeners
4851

49-
Set the `captionsReceived` event handler via the `on` API
52+
### Add a listener to receive captions active/inactive status
5053

51-
``` typescript
52-
const teamsCaptionsHandler = (data: TeamsCaptionsInfo) => { /* USER CODE HERE - E.G. RENDER TO DOM */ };
54+
```typescript
55+
const isCaptionsActiveChangedHandler = () => {
56+
if (teamsCaptions.isCaptionsFeatureActive()) {
57+
/* USER CODE HERE - E.G. RENDER TO DOM */
58+
}
59+
}
60+
teamsCaptions.on('isCaptionsActiveChanged', isCaptionsActiveChangedHandler);
61+
```
5362

54-
try {
55-
// on the call object, associated with External Identity users
56-
const teamsCaptionsApi = call.feature(Features.TeamsCaptions);
57-
teamsCaptionsApi.on('captionsReceived', teamsCaptionsHandler);
58-
await teamsCaptionsApi.startCaptions({ spokenLanguage: 'en-us' });
63+
### Add a listener for captions data received
5964

60-
// alternatively, on the TeamsCall object, associated with M365 identity users const teamsCaptionsApi = teamsCall.feature(Features.TeamsCaptions); teamsCaptionsApi.on('captionsReceived', teamsCaptionsHandler); await teamsCaptionsApi.startCaptions({ spokenLanguage: 'en-us' });
61-
} catch (e) {
62-
console.log('Internal error occurred when Starting Teams Captions'); }
65+
```typescript
66+
const captionsReceivedHandler : TeamsCaptionsHandler = (data: TeamsCaptionsInfo) => { /* USER CODE HERE - E.G. RENDER TO DOM */ };
67+
teamsCaptions.on('captionsReceived', captionsReceivedHandler);
6368
```
6469

65-
## Get supported languages
70+
## Start captions
6671

67-
Access the `supportedSpokenLanguages` property on the `Features.TeamsCaptions` API. Earlier, the API was set to TeamsCaptionsApi. The property will return an array of langauges in bcp-47 format.
72+
Once you've got all your listeners setup you can now start captions.
6873

6974
``` typescript
70-
const spokenLanguages = teamsCaptionsApi.supportedSpokenLanguages;
75+
try {
76+
await teamsCaptions.startCaptions({ spokenLanguage: 'en-us' });
77+
} catch (e) {
78+
/* USER ERROR HANDLING CODE HERE */
79+
}
7180
```
7281

73-
## Update spoken language
74-
75-
Pass a value in from the supported spoken languages array to ensure that the requested language is supported. By default, if contoso provides no language or an unsupported language, the spoken language defaults to 'en-us'.
82+
## Stop captions
7683

7784
``` typescript
78-
// bcp 47 formatted language code
79-
const language = 'en-us';
85+
try {
86+
teamsCaptionsApi.stopCaptions();
87+
} catch (e) {
88+
/* USER ERROR HANDLING CODE HERE */
89+
}
90+
```
8091

81-
// Altneratively, pass a value fromt he supported spoken languages array
82-
const language = spokenLanguages[0];
83-
teamsCaptionsApi.setSpokenLanguage(language);
92+
## Unsubscribe to listeners
93+
```typescript
94+
teamsCaptions.off('isCaptionsActiveChanged', isCaptionsActiveChangedHandler);
95+
teamsCaptions.off('captionsReceived', captionsReceivedHandler);
8496
```
8597

86-
## Get supported caption languages
98+
## Spoken language support
8799

88-
If your organization has Teams premium license you can allow your users to leverage translated captions provided by Teams captions. The property returns an array of two-letter langauge codes in `ISO 639-1` standard.
100+
### Get a list of supported spoken languages
89101

90-
Access the `supportedCaptionLanguages` property on the `Features.TeamsCaptions` API.
102+
Get a list of supported spoken languages that your users can select from when enabling closed captions.
103+
The property will return an array of langauges in bcp 47 format.
91104

92105
``` typescript
93-
const captionLanguages = teamsCaptionsApi.supportedCaptionLanguages;
106+
const spokenLanguages = teamsCaptions.supportedSpokenLanguages;
94107
```
95108

96-
## Update caption language
97-
If your organization has Teams premium license you can allow your users to leverage translated captions provided by Teams captions. Contoso can generate a list of supported caption languages by calling `teamsCaptions.supportedCaptionLanguages` that returns an array of two-letter langauge codes in `ISO 639-1` standard.
109+
### Set spoken language
98110

99-
Pass a value in from the supported caption languages array to ensure that the requested language is supported.
111+
Pass a value in from the supported spoken languages array to ensure that the requested language is supported. By default, if contoso provides no language or an unsupported language, the spoken language defaults to 'en-us'.
100112

101113
``` typescript
102-
// ISO 639-1 formatted language code
114+
// bcp 47 formatted language code
103115
const language = 'en-us';
104116

105-
// Altneratively, pass a value fromt he supported spoken languages array
106-
const language = captionLanguages[0]; teamsCaptionsApi.setCaptionLanguage(language);
117+
// Altneratively, pass a value from the supported spoken languages array
118+
const language = spokenLanguages[0];
119+
120+
try {
121+
teamsCaptions.setSpokenLanguage(language);
122+
} catch (e) {
123+
/* USER ERROR HANDLING CODE HERE */
124+
}
107125
```
108126

109-
## Stop captions
127+
## Caption language support
128+
129+
### Get a list of supported caption languages
130+
131+
If your organization has an active Teams premium license you can allow your users to leverage translated captions provided by Teams captions. As for users with a Microsoft 365 identity, if the meeting organizer does not have an active Teams premium license, captions language check will be done against the Microsoft 365 users account.
132+
133+
The property returns an array of two-letter langauge codes in `ISO 639-1` standard.
110134

111135
``` typescript
112-
teamsCaptionsApi.stopCaptions();
113-
teamsCaptionsApi.off('captionsReceived', teamsCaptionsHandler);
136+
const captionLanguages = teamsCaptions.supportedCaptionLanguages;
137+
```
138+
139+
### Set caption language
140+
141+
``` typescript
142+
// ISO 639-1 formatted language code
143+
const language = 'en';
144+
145+
// Altneratively, pass a value from the supported caption languages array
146+
const language = captionLanguages[0];
147+
try {
148+
teamsCaptions.setCaptionLanguage(language);
149+
} catch (e) {
150+
/* USER ERROR HANDLING CODE HERE */
151+
}
114152
```

0 commit comments

Comments
 (0)