Skip to content

Commit da6f9ca

Browse files
Merge pull request #245785 from valindrae/ga-closed-captions
Ga closed captions
2 parents 3864fbc + 1fa21cb commit da6f9ca

File tree

4 files changed

+302
-144
lines changed

4 files changed

+302
-144
lines changed

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

Lines changed: 78 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: include file
3-
description: Android how-to guide for enabling Closed captions during a call.
3+
description: Android how-to guide for enabling Closed captions during a Teams interop call.
44
author: Kunaal
55
ms.service: azure-communication-services
66
ms.subservice: calling
77
ms.topic: include
88
ms.topic: include file
9-
ms.date: 03/20/2023
9+
ms.date: 07/21/20223
1010
ms.author: kpunjabi
1111
---
1212

@@ -16,46 +16,52 @@ ms.author: kpunjabi
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.
1717
- [Access tokens](../../../../quickstarts/manage-teams-identity.md) for Microsoft 365 users.
1818
- [Access tokens](../../../../quickstarts/identity/access-tokens.md) for External identity users.
19-
- For Translated captions, you need to have a [Teams premium](/MicrosoftTeams/teams-add-on-licensing/licensing-enhance-teams#meetings) license.
19+
- For Translated captions, you need to have a [Teams premium](/MicrosoftTeams/teams-add-on-licensing/licensing-enhance-teams#meetings) license.
2020

2121
>[!NOTE]
2222
>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.
2323
2424
## Models
25-
| Name | Description |
26-
|------|-------------|
27-
| TeamsCaptionsCallFeature | API for TeamsCall captions |
28-
| StartCaptionOptions | Closed caption options like spoken language |
29-
| TeamsCaptionsListener | Listener for addOnCaptionsReceivedListener |
30-
| TeamsCaptionsInfo | Data object received for each TeamsCaptionsListener event |
25+
| Name | Description |
26+
| -------------------------- | --------------------------------------------------------- |
27+
| CaptionsCallFeature | API for captions call feature |
28+
| TeamsCaptions | API for Teams captions |
29+
| StartCaptionOptions | Closed caption options like spoken language |
30+
| TeamsCaptionsListener | Listener for TeamsCaptions addOnCaptionsReceivedListener |
31+
| TeamsCaptionsReceivedEvent | Data object received for each TeamsCaptionsListener event |
3132

3233
## Get closed captions feature
3334

34-
### External Identity users
35+
### External Identity users and Microsoft 365 users
3536

36-
If you're building an application that allows ACS users to join a Teams meeting
37+
If you're building an application that allows users to join a Teams meeting
3738

3839
``` java
39-
TeamsCaptionsCallFeature captionsCallFeature = call.feature(Features.TEAMS_CAPTIONS);
40-
```
41-
42-
### Microsoft 365 users
43-
44-
If you're building an application for Microsoft 365 Users using ACS SDK.
45-
46-
``` java
47-
TeamsCaptionsCallFeature captionsCallFeature = teamsCall.feature(Features.TEAMS_CAPTIONS);
40+
CaptionsCallFeature captionsCallFeature = call.feature(Features.CAPTIONS);
41+
captionsCallFeature.getCaptions().whenComplete(
42+
((captions, throwable) -> {
43+
if (throwable == null) {
44+
CallCaptions callCaptions = captions;
45+
if (captions.getCaptionsType() == CaptionsType.TEAMS_CAPTIONS) {
46+
// teams captions
47+
TeamsCaptions teamsCaptions = (TeamsCaptions) captions;
48+
}
49+
} else {
50+
// get captions failed
51+
// throwable is the exception/cause
52+
}
53+
}));
4854
```
4955

5056
## Subscribe to listeners
5157

52-
### Add a listener to receive captions active/inactive status
58+
### Add a listener to receive captions enabled/disabled status
5359

5460
``` java
55-
public void addOnIsCaptionsActiveChangedListener() {
56-
captionsCallFeature.addOnCaptionsActiveChangedListener( (PropertyChangedEvent args) -> {
57-
if(captionsCallFeature.isCaptionsFeatureActive()) {
58-
61+
public void addOnIsCaptionsEnabledChangedListener() {
62+
teamsCaptions.addOnCaptionsEnabledChangedListener( (PropertyChangedEvent args) -> {
63+
if(teamsCaptions.isEnabled()) {
64+
// captions enabled
5965
}
6066
});
6167
}
@@ -64,23 +70,57 @@ public void addOnIsCaptionsActiveChangedListener() {
6470
### Add listener for captions data received
6571

6672
``` java
67-
TeamsCaptionsListener captionsListener = (TeamsCaptionsInfo captionsInfo) -> {
68-
73+
TeamsCaptionsListener captionsListener = (TeamsCaptionsReceivedEvent args) -> {
74+
// Information about the speaker.
75+
// CallerInfo participantInfo = args.getSpeaker();
76+
// The original text with no transcribed.
77+
// args.getSpokenText();
78+
// language identifier for the captions text.
79+
// args.getCaptionLanguage();
80+
// language identifier for the speaker.
81+
// args.getSpokenLanguage();
82+
// The transcribed text.
83+
// args.getCaptionText();
84+
// Timestamp denoting the time when the corresponding speech was made.
85+
// args.getTimestamp();
86+
// CaptionsResultType is Partial if text contains partially spoken sentence.
87+
// It is set to Final once the sentence has been completely transcribed.
88+
// args.getResultType() == CaptionsResultType.FINAL;
6989
};
7090
public void addOnCaptionsReceivedListener() {
71-
captionsCallFeature.addOnCaptionsReceivedListener(captionsListener);
91+
teamsCaptions.addOnCaptionsReceivedListener(captionsListener);
92+
}
93+
```
94+
95+
### Add a listener to receive active spoken language changed status
96+
97+
``` java
98+
public void addOnActiveSpokenLanguageChangedListener() {
99+
teamsCaptions.addOnActiveSpokenLanguageChangedListener( (PropertyChangedEvent args) -> {
100+
// teamsCaptions.getActiveSpokenLanguage()
101+
});
102+
}
103+
```
104+
105+
### Add a listener to receive active caption language changed status
106+
107+
``` java
108+
public void addOnActiveCaptionLanguageChangedListener() {
109+
teamsCaptions.addOnActiveCaptionLanguageChangedListener( (PropertyChangedEvent args) -> {
110+
// teamsCaptions.getActiveCaptionLanguage()
111+
});
72112
}
73113
```
74114

75115
## Start captions
76116

77-
Once you've got all your listeners setup, you can now start captions.
117+
Once you've set up all your listeners, you can now start adding captions.
78118

79119
``` java
80120
public void startCaptions() {
81121
StartCaptionsOptions startCaptionsOptions = new StartCaptionsOptions();
82122
startCaptionsOptions.setSpokenLanguage("en-us");
83-
captionsCallFeature.startCaptions(startCaptionsOptions).whenComplete((result, error) -> {
123+
teamsCaptions.startCaptions(startCaptionsOptions).whenComplete((result, error) -> {
84124
if (error != null) {
85125
}
86126
});
@@ -91,7 +131,7 @@ public void startCaptions() {
91131

92132
``` java
93133
public void stopCaptions() {
94-
captionsCallFeature.stopCaptions().whenComplete((result, error) -> {
134+
teamsCaptions.stopCaptions().whenComplete((result, error) -> {
95135
if (error != null) {
96136
}
97137
});
@@ -102,28 +142,26 @@ public void stopCaptions() {
102142

103143
``` java
104144
public void removeOnCaptionsReceivedListener() {
105-
captionsCallFeature.removeOnCaptionsReceivedListener(captionsListener);
145+
teamsCaptions.removeOnCaptionsReceivedListener(captionsListener);
106146
}
107147
```
108148

109-
## Spoken language support
110-
111-
### Get a list of supported spoken languages
149+
## Spoken language support
112150

151+
### Get list of supported spoken languages
113152
Get a list of supported spoken languages that your users can select from when enabling closed captions.
114153

115154
``` java
116155
// bcp 47 formatted language code
117-
captionsCallFeature.getSupportedSpokenLanguages();
156+
teamsCaptions.getSupportedSpokenLanguages();
118157
```
119158

120159
### Set spoken language
121-
122160
When the user selects the spoken language, your app can set the spoken language that it expects captions to be generated from.
123161

124162
``` java
125163
public void setSpokenLanguage() {
126-
captionsCallFeature.setSpokenLanguage("en-us").whenComplete((result, error) -> {
164+
teamsCaptions.setSpokenLanguage("en-us").whenComplete((result, error) -> {
127165
if (error != null) {
128166
}
129167
});
@@ -138,18 +176,15 @@ If your organization has an active Teams premium license, then your ACS users ca
138176

139177
``` java
140178
// ISO 639-1 formatted language code
141-
captionsCallFeature.getSupportedCaptionLanguages();
179+
teamsCaptions.getSupportedCaptionLanguages();
142180
```
143181
### Set caption language
144182

145183
``` java
146184
public void setCaptionLanguage() {
147-
captionsCallFeature.setCaptionLanguage("en").whenComplete((result, error) -> {
185+
teamsCaptions.setCaptionLanguage("en").whenComplete((result, error) -> {
148186
if (error != null) {
149187
}
150188
});
151189
}
152190
```
153-
154-
155-

0 commit comments

Comments
 (0)