|
| 1 | +--- |
| 2 | +title: include file |
| 3 | +description: Android how-to guide for enabling Closed captions during a call. |
| 4 | +author: Kunaal |
| 5 | +ms.service: azure-communication-services |
| 6 | +ms.subservice: calling |
| 7 | +ms.topic: include |
| 8 | +ms.topic: include file |
| 9 | +ms.date: 03/20/2023 |
| 10 | +ms.author: kpunjabi |
| 11 | +--- |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | +- Azure account with an active subscription, for details see [Create an account for free.](https://azure.microsoft.com/free/) |
| 15 | +- 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. |
| 16 | +- 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 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 need to have a [Teams premium](/MicrosoftTeams/teams-add-on-licensing/licensing-enhance-teams#meetings) license. |
| 20 | + |
| 21 | +>[!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 this guide. |
| 23 | +
|
| 24 | +## 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 | |
| 31 | + |
| 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 |
| 37 | + |
| 38 | +``` 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); |
| 48 | +``` |
| 49 | + |
| 50 | +## Subscribe to listeners |
| 51 | + |
| 52 | +### Add a listener to receive captions active/inactive status |
| 53 | + |
| 54 | +``` java |
| 55 | +public void addOnIsCaptionsActiveChangedListener() { |
| 56 | + captionsCallFeature.addOnCaptionsActiveChangedListener( (PropertyChangedEvent args) -> { |
| 57 | + if(captionsCallFeature.isCaptionsFeatureActive()) { |
| 58 | + |
| 59 | + } |
| 60 | + }); |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +### Add listener for captions data received |
| 65 | + |
| 66 | +``` java |
| 67 | +TeamsCaptionsListener captionsListener = (TeamsCaptionsInfo captionsInfo) -> { |
| 68 | + |
| 69 | +}; |
| 70 | +public void addOnCaptionsReceivedListener() { |
| 71 | + captionsCallFeature.addOnCaptionsReceivedListener(captionsListener); |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +## Start captions |
| 76 | + |
| 77 | +Once you've got all your listeners setup, you can now start captions. |
| 78 | + |
| 79 | +``` java |
| 80 | +public void startCaptions() { |
| 81 | + StartCaptionsOptions startCaptionsOptions = new StartCaptionsOptions(); |
| 82 | + startCaptionsOptions.setSpokenLanguage("en-us"); |
| 83 | + captionsCallFeature.startCaptions(startCaptionsOptions).whenComplete((result, error) -> { |
| 84 | + if (error != null) { |
| 85 | + } |
| 86 | + }); |
| 87 | +} |
| 88 | +``` |
| 89 | + |
| 90 | +## Stop captions |
| 91 | + |
| 92 | +``` java |
| 93 | +public void stopCaptions() { |
| 94 | + captionsCallFeature.stopCaptions().whenComplete((result, error) -> { |
| 95 | + if (error != null) { |
| 96 | + } |
| 97 | + }); |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +## Remove caption received listener |
| 102 | + |
| 103 | +``` java |
| 104 | +public void removeOnCaptionsReceivedListener() { |
| 105 | + captionsCallFeature.removeOnCaptionsReceivedListener(captionsListener); |
| 106 | +} |
| 107 | +``` |
| 108 | + |
| 109 | +## Spoken language support |
| 110 | + |
| 111 | +### Get a list of supported spoken languages |
| 112 | + |
| 113 | +Get a list of supported spoken languages that your users can select from when enabling closed captions. |
| 114 | + |
| 115 | +``` java |
| 116 | +// bcp 47 formatted language code |
| 117 | +captionsCallFeature.getSupportedSpokenLanguages(); |
| 118 | +``` |
| 119 | + |
| 120 | +### Set spoken language |
| 121 | + |
| 122 | +When the user selects the spoken language, your app can set the spoken language that it expects captions to be generated from. |
| 123 | + |
| 124 | +``` java |
| 125 | +public void setSpokenLanguage() { |
| 126 | + captionsCallFeature.setSpokenLanguage("en-us").whenComplete((result, error) -> { |
| 127 | + if (error != null) { |
| 128 | + } |
| 129 | + }); |
| 130 | +} |
| 131 | +``` |
| 132 | + |
| 133 | +## Caption language support |
| 134 | + |
| 135 | +### Get supported caption language |
| 136 | + |
| 137 | +If your organization has an active Teams premium license, then your ACS users can enable translated captions as long as the organizer of the meeting has a Teams premium license. As for users with Microsoft 365 identities this check is done against their own user account if they meeting organizer doesn't have a Teams premium license. |
| 138 | + |
| 139 | +``` java |
| 140 | +// ISO 639-1 formatted language code |
| 141 | +captionsCallFeature.getSupportedCaptionLanguages(); |
| 142 | +``` |
| 143 | +### Set caption language |
| 144 | + |
| 145 | +``` java |
| 146 | +public void setCaptionLanguage() { |
| 147 | + captionsCallFeature.setCaptionLanguage("en").whenComplete((result, error) -> { |
| 148 | + if (error != null) { |
| 149 | + } |
| 150 | + }); |
| 151 | +} |
| 152 | +``` |
| 153 | + |
| 154 | + |
| 155 | + |
0 commit comments