Skip to content

Commit f6c80de

Browse files
authored
Update play-audio-with-ai-csharp.md
update based on feedback
1 parent 1726cc4 commit f6c80de

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

articles/communication-services/how-tos/call-automation/includes/play-audio-with-ai-csharp.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ You can test creating your own audio file using our [Speech synthesis with Audio
4141

4242
## (Optional) Connect your Azure Cognitive Service to your Azure Communication Service
4343

44-
If you would like to use Text-To-Speech capabilities, then it's required for you to connect your Azure Cognitive Service to your Azure Communication Service.
45-
``` code
46-
az communication bind-cognitive-service --name “{Azure Communication resource name}” --resource-group “{Azure Communication resource group}” --resource-id “{Cognitive service resource id}” --subscription{subscription Name of Cognitive service} –identity{Cognitive Services Identity}
44+
If you would like to use Text-To-Speech capabilities, then it's required for you to connect your [Azure Cognitive Service to your Azure Communication Service](../../../concepts/call-automation/azure-communication-services-azure-cognitive-services-integration.md).
4745

48-
```
4946
## Establish a call
5047

5148
By this point you should be familiar with starting calls, if you need to learn more about making a call, follow our [quickstart](../../../quickstarts/call-automation/callflows-for-customer-interactions.md). In this quickstart, we answer an incoming call.
@@ -66,44 +63,58 @@ Once the call has been established, there are multiple options for how you may w
6663

6764
### Play source - Audio file
6865

69-
To play audio to participants using audio files, you need to make sure the audio file is a WAV file, mono and 16 KHz. To play audio files you need to make sure you provide ACS with a uri to a file you host in a location where ACS can access it.
66+
To play audio to participants using audio files, you need to make sure the audio file is a WAV file, mono and 16 KHz. To play audio files you need to make sure you provide ACS with a uri to a file you host in a location where ACS can access it. The FileSource type in our SDK can be used to specify audio files for the play action.
7067

7168
``` csharp
7269
FileSource playSource = new FileSource (new Uri(<audioUri>));
7370
```
7471

7572
### Play source - Text-To-Speech
7673

77-
To play audio using Text-To-Speech through Azure Cognitive Services you need to provide the text you wish to play, as well either the SourceLocale, and VoiceGender or the VoiceName you wish to use.
74+
To play audio using Text-To-Speech through Azure Cognitive Services you need to provide the text you wish to play, as well either the SourceLocale, and VoiceGender or the VoiceName you wish to use. We support all voice names supported by Cognitive Services, full list [here]().
7875

7976
```csharp
8077
String textToPlay = "Welcome to Contoso";
78+
79+
//you can provide SourceLocale and VoiceGender as one option for playing audio
8180
TextSource playSource = new TextSource(textToPlay);
8281
{
8382
SourceLocale = "en-US",
84-
VoiceGender = GenderType.Female,
85-
VoiceName = "en-US-ElizabethNeural"
83+
VoiceGender = GenderType.Female,
8684
};
8785
```
8886

89-
## Play audio to a specific participant
87+
```csharp
88+
String textToPlay = "Welcome to Contoso";
9089

91-
In this scenario audio is played to a specific participant.
90+
//you can provide VoiceName
91+
TextSource playSource = new TextSource(textToPlay);
92+
{
93+
VoiceName = "en-US-ElizabethNeural"
94+
};
95+
```
96+
97+
Once you've decided on which playSource you wish to use for playing audio you can then choose whether you want to play it to a specific participant or to all participants.
98+
99+
100+
## Play audio to all participants
101+
102+
In this scenario audio is played to all participants on the call.
92103

93104
``` csharp
94-
var targetUser = new PhoneNumberIdentifier(<target>);
95105
var callMedia = callAutomationClient.GetCallConnection(<callConnectionId>).GetCallMedia();
96-
var playResponse = await callMedia.PlayAsync(playSource, new PhoneNumberIdentifier[] { targetUser });
106+
var playResponse = await callMedia.PlayToAllAsync(playSource);
97107
Assert.AreEqual(202, playResponse.Status) // The request was accepted.
98108
```
99109

100-
## Play audio to all participants
110+
## Play audio to a specific participant
101111

102-
In this scenario audio is played to all participants on the call.
112+
In this scenario audio is played to a specific participant.
103113

104114
``` csharp
115+
var targetUser = new PhoneNumberIdentifier(<target>);
105116
var callMedia = callAutomationClient.GetCallConnection(<callConnectionId>).GetCallMedia();
106-
var playResponse = await callMedia.PlayToAllAsync(playSource);
117+
var playResponse = await callMedia.PlayAsync(playSource, new PhoneNumberIdentifier[] { targetUser });
107118
Assert.AreEqual(202, playResponse.Status) // The request was accepted.
108119
```
109120

0 commit comments

Comments
 (0)