diff --git a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallMediaAsync.java b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallMediaAsync.java index 0aa4da5ce69ae..aa6826a17f86c 100644 --- a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallMediaAsync.java +++ b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/CallMediaAsync.java @@ -278,11 +278,10 @@ PlayRequest getPlayRequest(PlayOptions options) { private PlaySourceInternal getPlaySourceInternalFromFileSource(FileSource playSource) { FileSourceInternal fileSourceInternal = new FileSourceInternal().setUri(playSource.getUrl()); - PlaySourceInternal playSourceInternal = new PlaySourceInternal() + return new PlaySourceInternal() .setSourceType(PlaySourceTypeInternal.FILE) .setFileSource(fileSourceInternal) .setPlaySourceId(playSource.getPlaySourceId()); - return playSourceInternal; } private PlaySourceInternal getPlaySourceInternalFromTextSource(TextSource playSource) { @@ -296,21 +295,27 @@ private PlaySourceInternal getPlaySourceInternalFromTextSource(TextSource playSo if (playSource.getVoiceName() != null) { textSourceInternal.setVoiceName(playSource.getVoiceName()); } + if (playSource.getCustomVoiceEndpointId() != null) { + textSourceInternal.setCustomVoiceEndpointId(playSource.getCustomVoiceEndpointId()); + } - PlaySourceInternal playSourceInternal = new PlaySourceInternal() + return new PlaySourceInternal() .setSourceType(PlaySourceTypeInternal.TEXT) .setTextSource(textSourceInternal) .setPlaySourceId(playSource.getPlaySourceId()); - return playSourceInternal; } private PlaySourceInternal getPlaySourceInternalFromSsmlSource(SsmlSource playSource) { SsmlSourceInternal ssmlSourceInternal = new SsmlSourceInternal().setSsmlText(playSource.getSsmlText()); - PlaySourceInternal playSourceInternal = new PlaySourceInternal() + + if (playSource.getCustomVoiceEndpointId() != null) { + ssmlSourceInternal.setCustomVoiceEndpointId(playSource.getCustomVoiceEndpointId()); + } + + return new PlaySourceInternal() .setSourceType(PlaySourceTypeInternal.SSML) .setSsmlSource(ssmlSourceInternal) .setPlaySourceId(playSource.getPlaySourceId()); - return playSourceInternal; } private PlaySourceInternal convertPlaySourceToPlaySourceInternal(PlaySource playSource) { @@ -319,6 +324,8 @@ private PlaySourceInternal convertPlaySourceToPlaySourceInternal(PlaySource play playSourceInternal = getPlaySourceInternalFromFileSource((FileSource) playSource); } else if (playSource instanceof TextSource) { playSourceInternal = getPlaySourceInternalFromTextSource((TextSource) playSource); + } else if (playSource instanceof SsmlSource) { + playSourceInternal = getPlaySourceInternalFromSsmlSource((SsmlSource) playSource); } return playSourceInternal; } @@ -398,6 +405,12 @@ private RecognizeRequest getRecognizeRequestFromChoiceConfiguration(CallMediaRec } } + if (choiceRecognizeOptions.getSpeechModelEndpointId() != null) { + if (!choiceRecognizeOptions.getSpeechModelEndpointId().isEmpty()) { + recognizeOptionsInternal.setSpeechRecognitionModelEndpointId(choiceRecognizeOptions.getSpeechModelEndpointId()); + } + } + PlaySourceInternal playSourceInternal = getPlaySourceInternalFromRecognizeOptions(recognizeOptions); RecognizeRequest recognizeRequest = new RecognizeRequest() @@ -422,6 +435,12 @@ private RecognizeRequest getRecognizeRequestFromSpeechConfiguration(CallMediaRec recognizeOptionsInternal.setInitialSilenceTimeoutInSeconds((int) speechRecognizeOptions.getInitialSilenceTimeout().getSeconds()); + if (speechRecognizeOptions.getSpeechModelEndpointId() != null) { + if (!speechRecognizeOptions.getSpeechModelEndpointId().isEmpty()) { + recognizeOptionsInternal.setSpeechRecognitionModelEndpointId(speechRecognizeOptions.getSpeechModelEndpointId()); + } + } + PlaySourceInternal playSourceInternal = getPlaySourceInternalFromRecognizeOptions(recognizeOptions); RecognizeRequest recognizeRequest = new RecognizeRequest() @@ -459,6 +478,11 @@ private RecognizeRequest getRecognizeRequestFromSpeechOrDtmfConfiguration(CallMe .setInterruptPrompt(speechOrDtmfRecognizeOptions.isInterruptPrompt()) .setTargetParticipant(CommunicationIdentifierConverter.convert(speechOrDtmfRecognizeOptions.getTargetParticipant())); + if (speechOrDtmfRecognizeOptions.getSpeechModelEndpointId() != null) { + if (!speechOrDtmfRecognizeOptions.getSpeechModelEndpointId().isEmpty()) { + recognizeOptionsInternal.setSpeechRecognitionModelEndpointId(speechOrDtmfRecognizeOptions.getSpeechModelEndpointId()); + } + } recognizeOptionsInternal.setInitialSilenceTimeoutInSeconds((int) speechOrDtmfRecognizeOptions.getInitialSilenceTimeout().getSeconds()); PlaySourceInternal playSourceInternal = getPlaySourceInternalFromRecognizeOptions(recognizeOptions); diff --git a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/CallMediaRecognizeOptions.java b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/CallMediaRecognizeOptions.java index b0eece84d716b..75727412c16cf 100644 --- a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/CallMediaRecognizeOptions.java +++ b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/CallMediaRecognizeOptions.java @@ -54,6 +54,12 @@ public abstract class CallMediaRecognizeOptions { @JsonProperty(value = "initialSilenceTimeout") private Duration initialSilenceTimeout; + /* + * Endpoint where the custom model was deployed. + */ + @JsonProperty(value = "speechModelEndpointId") + private String speechModelEndpointId; + /* * Target participant of DTFM tone recognition. */ @@ -224,4 +230,24 @@ public CallMediaRecognizeOptions setInitialSilenceTimeout(Duration initialSilenc public CommunicationIdentifier getTargetParticipant() { return this.targetParticipant; } + + /** + * Get the speech model endpoint id. + * + * @return the speech model endpoint id. + */ + public String getSpeechModelEndpointId() { + return speechModelEndpointId; + } + + /** + * Set the speechModelEndpointId property: Endpoint where the custom model was deployed. + * + * @param speechModelEndpointId the initialSilenceTimeout value to set. + * @return the CallMediaRecognizeSpeechOrDtmfOptions object itself. + */ + public CallMediaRecognizeOptions setSpeechModelEndpointId(String speechModelEndpointId) { + this.speechModelEndpointId = speechModelEndpointId; + return this; + } } diff --git a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/SsmlSource.java b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/SsmlSource.java index 199ae2119ce13..c2d8e8907feb3 100644 --- a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/SsmlSource.java +++ b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/SsmlSource.java @@ -15,6 +15,12 @@ public final class SsmlSource extends PlaySource { @JsonProperty(value = "ssmlText", required = true) private String ssmlText; + /* + * Endpoint where the Custom Voice was deployed. + */ + @JsonProperty(value = "customVoiceEndpointId") + private String customVoiceEndpointId; + /** * Get the ssmlText property: Ssml string for the cognitive service to be played. * @@ -34,4 +40,24 @@ public SsmlSource setSsmlText(String ssmlText) { this.ssmlText = ssmlText; return this; } + + /** + * Get the customVoiceEndpointId property: Endpoint where the custom voice was deployed. + * + * @return the customVoiceEndpointId value. + */ + public String getCustomVoiceEndpointId() { + return this.customVoiceEndpointId; + } + + /** + * Set the customVoiceEndpointId property: Endpoint where the custom voice was deployed. + * + * @param customVoiceEndpointId the customVoiceEndpointId value to set. + * @return the TextSourceInternal object itself. + */ + public SsmlSource setCustomVoiceEndpointId(String customVoiceEndpointId) { + this.customVoiceEndpointId = customVoiceEndpointId; + return this; + } } diff --git a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/TextSource.java b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/TextSource.java index eb1b8e782ff1a..235c990dcaf22 100644 --- a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/TextSource.java +++ b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/TextSource.java @@ -33,6 +33,12 @@ public final class TextSource extends PlaySource { @JsonProperty(value = "voiceName") private String voiceName; + /* + * Endpoint where the Custom Voice was deployed. + */ + @JsonProperty(value = "customVoiceEndpointId") + private String customVoiceEndpointId; + /** * Get the text property: Text for the cognitive service to be played. * @@ -112,4 +118,24 @@ public TextSource setVoiceName(String voiceName) { this.voiceName = voiceName; return this; } + + /** + * Get the customVoiceEndpointId property: Endpoint where the custom voice was deployed. + * + * @return the customVoiceEndpointId value. + */ + public String getCustomVoiceEndpointId() { + return this.customVoiceEndpointId; + } + + /** + * Set the customVoiceEndpointId property: Endpoint where the custom voice was deployed. + * + * @param customVoiceEndpointId the customVoiceEndpointId value to set. + * @return the TextSourceInternal object itself. + */ + public TextSource setCustomVoiceEndpointId(String customVoiceEndpointId) { + this.customVoiceEndpointId = customVoiceEndpointId; + return this; + } } diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncUnitTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncUnitTests.java index 69d6770e5c72a..07c8146e9935a 100644 --- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncUnitTests.java +++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncUnitTests.java @@ -58,9 +58,11 @@ public void setup() { playTextSource.setVoiceGender(GenderType.MALE); playTextSource.setSourceLocale("en-US"); playTextSource.setVoiceName("LULU"); + playTextSource.setCustomVoiceEndpointId("customVoiceEndpointId"); playSsmlSource = new SsmlSource(); - playSsmlSource.setSsmlText(""); + playSsmlSource.setSsmlText(""); + playSsmlSource.setCustomVoiceEndpointId("customVoiceEndpointId"); } @Test @@ -260,6 +262,7 @@ public void recognizeWithResponseWithFileSourceChoiceOptions() { recognizeOptions.setInterruptPrompt(true); recognizeOptions.setInitialSilenceTimeout(Duration.ofSeconds(4)); recognizeOptions.setSpeechLanguage("en-US"); + recognizeOptions.setSpeechModelEndpointId("customModelEndpointId"); StepVerifier.create( callMedia.startRecognizingWithResponse(recognizeOptions)) @@ -306,6 +309,7 @@ public void recognizeWithResponseTextSpeechOptions() { recognizeOptions.setOperationContext("operationContext"); recognizeOptions.setInterruptPrompt(true); recognizeOptions.setInitialSilenceTimeout(Duration.ofSeconds(4)); + recognizeOptions.setSpeechModelEndpointId("customModelEndpointId"); StepVerifier.create( callMedia.startRecognizingWithResponse(recognizeOptions)) @@ -325,6 +329,7 @@ public void recognizeWithResponseTextSpeechOrDtmfOptions() { recognizeOptions.setOperationContext("operationContext"); recognizeOptions.setInterruptPrompt(true); recognizeOptions.setInitialSilenceTimeout(Duration.ofSeconds(4)); + recognizeOptions.setSpeechModelEndpointId("customModelEndpointId"); StepVerifier.create( callMedia.startRecognizingWithResponse(recognizeOptions)) diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaUnitTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaUnitTests.java index 390b9b5f6dbe8..0b6e0bc7cb676 100644 --- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaUnitTests.java +++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaUnitTests.java @@ -45,6 +45,7 @@ public void setup() { playTextSource.setVoiceGender(GenderType.MALE); playTextSource.setSourceLocale("en-US"); playTextSource.setVoiceName("LULU"); + playTextSource.setCustomVoiceEndpointId("customVoiceEndpointId"); } @Test