|
| 1 | +--- |
| 2 | +title: include file |
| 3 | +description: Windows 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/20223 |
| 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 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](https://www.microsoft.com/en-us/microsoft-teams/premium#tabx93f55452286a4264a2778ef8902fb81a) 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 the QuickStart below. |
| 23 | +
|
| 24 | +## Models |
| 25 | +| Name | Description | |
| 26 | +|------|-------------| |
| 27 | +| TeamsCaptionsCallFeature | API for TeamsCall captions | |
| 28 | +| StartCaptionOptions | Closed caption options like spoken language | |
| 29 | +| CaptionsReceived | Listener for captions data | |
| 30 | +| TeamsCaptionsInfo | Data object received for each CaptionsActiveChanged 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 | +``` cs |
| 39 | +TeamsCaptionsCallFeature captionsCallFeature = call.Features.TeamsCaptions; |
| 40 | +``` |
| 41 | + |
| 42 | +### Microsoft 365 users |
| 43 | + |
| 44 | +``` cs |
| 45 | +TeamsCaptionsCallFeature captionsCallFeature = teamCall.Features.TeamsCaptions; |
| 46 | +``` |
| 47 | + |
| 48 | +## Subscribe to listeners |
| 49 | + |
| 50 | +### Add a listener to receive captions active/inactive status |
| 51 | + |
| 52 | +``` cs |
| 53 | +captionsCallFeature.CaptionsActiveChanged += OnIsCaptionsActiveChanged; |
| 54 | + |
| 55 | +private void OnIsCaptionsActiveChanged(object sender, PropertyChangedEventArgs args) |
| 56 | +{ |
| 57 | + if (captionsCallFeature.IsCaptionsFeatureActive) |
| 58 | + { |
| 59 | + } |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +### Add listener for captions data received |
| 64 | + |
| 65 | +``` cs |
| 66 | +captionsCallFeature.CaptionsReceived += OnCaptionsReceived; |
| 67 | + |
| 68 | +private void OnCaptionsReceived(object sender, TeamsCaptionsInfo info) |
| 69 | +{ |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +## Start captions |
| 74 | + |
| 75 | +Once you've got all your listeners setup you can now start captions. |
| 76 | + |
| 77 | +``` cs |
| 78 | + |
| 79 | +private async void StartCaptions() |
| 80 | +{ |
| 81 | + var options = new StartCaptionsOptions |
| 82 | + { |
| 83 | + SpokenLanguage = "en-US" |
| 84 | + }; |
| 85 | + try |
| 86 | + { |
| 87 | + await captionsCallFeature.StartCaptionsAsync(options); |
| 88 | + } |
| 89 | + catch (Exception ex) |
| 90 | + { |
| 91 | + } |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +## Stop captions |
| 96 | + |
| 97 | +``` cs |
| 98 | +private async void StopCaptions() |
| 99 | +{ |
| 100 | + try |
| 101 | + { |
| 102 | + await captionsCallFeature.StopCaptionsAsync(); |
| 103 | + } |
| 104 | + catch (Exception ex) |
| 105 | + { |
| 106 | + } |
| 107 | +} |
| 108 | +``` |
| 109 | + |
| 110 | +## Remove caption received listener |
| 111 | + |
| 112 | +``` cs |
| 113 | +captionsCallFeature.CaptionsReceived -= OnCaptionsReceived; |
| 114 | +``` |
| 115 | + |
| 116 | +## Spoken language support |
| 117 | + |
| 118 | +### Get list of supported spoken languages |
| 119 | +Get a list of supported spoken languages that your users can select from when enabling closed captions. |
| 120 | + |
| 121 | +``` cs |
| 122 | +// bcp 47 formatted language code |
| 123 | +IReadOnlyList<string> sLanguages = captionsCallFeature.SupportedSpokenLanguages;``` |
| 124 | + |
| 125 | +### Set spoken language |
| 126 | +When the user selects the spoken language, your app can set the spoken language that it expects captions to be generated from. |
| 127 | + |
| 128 | +``` cs |
| 129 | +public async void SetSpokenLanguage() |
| 130 | +{ |
| 131 | + try |
| 132 | + { |
| 133 | + await captionsCallFeature.SetSpokenLanguageAsync("en-us"); |
| 134 | + } |
| 135 | + catch (Exception ex) |
| 136 | + { |
| 137 | + } |
| 138 | +} |
| 139 | +``` |
| 140 | + |
| 141 | +## Caption language support |
| 142 | + |
| 143 | +### Get supported caption language |
| 144 | + |
| 145 | +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 will be done against their own user account if they meeting organizer doesn't have a Teams premium license. |
| 146 | + |
| 147 | +``` cs |
| 148 | +// ISO 639-1 formatted language code |
| 149 | +IReadOnlyList<string> cLanguages = captionsCallFeature.SupportedCaptionLanguages; |
| 150 | +``` |
| 151 | +### Set caption language |
| 152 | + |
| 153 | +``` cs |
| 154 | +public async void SetCaptionLanguage() |
| 155 | +{ |
| 156 | + try |
| 157 | + { |
| 158 | + await captionsCallFeature.SetCaptionLanguageAsync("en"); |
| 159 | + } |
| 160 | + catch (Exception ex) |
| 161 | + { |
| 162 | + } |
| 163 | +} |
| 164 | +``` |
0 commit comments