You plan to use Azure Speech service to convert text to speech and output it to a speaker.
First you create a speech configuration and next you synthesize speech to the speaker output.
Given that the prerequisites are met, Speech SDK is installed and required packages are included, review the code below and complete it by choosing the appropriate answer choices.
(select two options)
static async Task SynthesizeAudioAsync() { var config = ……………………………..FromSubscription("<subscription key>","<azure region>"); using var synthesizer = new …………………………...(config); await synthesizer.SpeakTextAsync("<speaker output>"); }
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answers: A and D
Here is the completed code snippets
<pre class="brush:java;">static async Task SynthesizeAudioAsync()
{
var config = SpeechConfig.FromSubscription("&lt;subscription key&gt;","&lt;azure region&gt;");
using var synthesizer = new SpeechSynthesizer(config);
await synthesizer.SpeakTextAsync("&lt;speaker output&gt;");
}
</pre>Option A is correct because SpeechConfig provides the key and associated azure region details that is one of the ways to initialize SpeechConfig.
The other options are to use an authorization token, pass a host address or pass a Speech service endpoint.
Option B is incorrect because the AudioConfig object is used to contain information when the output is intended to a file.
Option C is incorrect because the AudioDataStream object is used when output is intended to an in memory data stream.
Option D is correct because the SpeechSynthesizer method executes speech to text and output to the speaker.
You may also output to a file or as an in memory stream using the SpeechSynthesizer method.
Reference:
To learn more about text to speech output, use the link given below:
Sure, I can provide a detailed explanation of the code and the answer choices for you.
The code you provided is a C# method that uses the Azure Speech service to synthesize speech and output it to a speaker. The method is named SynthesizeAudioAsync and it is an asynchronous method, which means that it will run in the background and not block the main thread of the application.
The code contains some placeholders denoted by <subscription key>, <azure region> and <speaker output> that need to be replaced with actual values.
To use Azure Speech service in the code, you need to create a SpeechConfig object that contains the subscription key and the Azure region. The subscription key is a unique identifier that links your application to your Azure Speech service account, and the Azure region is the geographical region where your Speech service instance is hosted.
The answer choices A and D are both related to SpeechConfig and SpeechSynthesizer objects, which are the correct choices to fill in the missing code in the method. Specifically:
var config = SpeechConfig.FromSubscription("<subscription key>", "<azure region>");
using var synthesizer = new SpeechSynthesizer(config);
Therefore, the correct answer is A and D, SpeechConfig and SpeechSynthesizer. Answer choices B and C are not applicable to the code as they are related to AudioConfig and AudioDataStream objects, which are not used in this specific scenario of synthesizing speech and outputting it to a speaker.