Skip to content

Commit 7e86ae7

Browse files
authored
Update play-audio-with-ai-java.md
update based on feedback
1 parent f6c80de commit 7e86ae7

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Azure Communication Services Call Automation SDK package is retrieved from the A
5959
<dependency>
6060
<groupId>com.azure</groupId>
6161
<artifactId>azure-communication-callautomation</artifactId>
62-
<version>1.0.0-alpha.20230210.2</version>
62+
<version>1.0.0-alpha.20230228.1</version>
6363
</dependency>
6464
```
6565

@@ -113,49 +113,60 @@ To play audio using Text-To-Speech through Azure Cognitive Services you need to
113113
```java
114114
var playSource = new TextSource();
115115
playSource.setText("some text to play");
116+
117+
//you can provide SourceLocale and VoiceGender as one option for playing audio
116118
playSource.setSourceLocale("en-US");
117119
playSource.setVoiceGender(GenderType.M);
118-
playSource.setVoiceName("LULU");
119120
```
120121

121-
## Play audio to a specific participant
122+
```java
123+
var playSource = new TextSource();
124+
playSource.setText("Welcome to Contoso");
122125

123-
In this scenario audio is played to a specific participant.
126+
//you can provide VoiceName
127+
playSource.setVoiceName("en-US-ElizabethNeural");
128+
```
129+
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.
124130

125-
``` java
126-
var targetUser = new PhoneNumberIdentifier(<target>);
131+
## Play audio to all participants
132+
133+
In this scenario audio is played to all participants on the call.
134+
135+
``` java
127136
var callConnection = callAutomationAsyncClient.getCallConnectionAsync(<callConnectionId>);
128137

129138
var playOptions = new PlayOptions()
130139
.setLoop(false)
131140
.setOperationContext("operationContext");
132141

133-
var playResponse = callConnection.getCallMediaAsync().playWithResponse(
142+
var playResponse = callConnection.getCallMediaAsync().playToAllWithResponse(
134143
playSource,
135-
Collections.singletonList(targetUser), // Can be a list of multiple users
136144
playOptions
137145
).block();
138146
assertEquals(202, playResponse.getStatusCode()); // The request was accepted
139147
```
140148

141-
## Play audio to all participants
149+
## Play audio to a specific participant
142150

143-
In this scenario audio is played to all participants on the call.
151+
In this scenario audio is played to a specific participant.
144152

145-
``` java
153+
``` java
154+
var targetUser = new PhoneNumberIdentifier(<target>);
146155
var callConnection = callAutomationAsyncClient.getCallConnectionAsync(<callConnectionId>);
147156

148157
var playOptions = new PlayOptions()
149158
.setLoop(false)
150159
.setOperationContext("operationContext");
151160

152-
var playResponse = callConnection.getCallMediaAsync().playToAllWithResponse(
161+
var playResponse = callConnection.getCallMediaAsync().playWithResponse(
153162
playSource,
163+
Collections.singletonList(targetUser), // Can be a list of multiple users
154164
playOptions
155165
).block();
156166
assertEquals(202, playResponse.getStatusCode()); // The request was accepted
157167
```
158168

169+
159170
## Handle play action event updates
160171

161172
Your application receives action lifecycle event updates on the callback URL that was provided to Call Automation service at the time of answering the call. An example of a successful play event update.

0 commit comments

Comments
 (0)