public TTSRequest Build(TalkerParameters parameters) { var request = new TTSRequest(); request.Headers.Add(new KeyValuePair <string, string>("Content-Type", "application/ssml+xml")); string outputFormat = ConvertOutputFormat(parameters.OutputFormat); request.Headers.Add(new KeyValuePair <string, string>("X-Microsoft-OutputFormat", outputFormat)); // authorization Header request.Headers.Add(new KeyValuePair <string, string>("Authorization", parameters.AuthorizationToken)); // Refer to the doc request.Headers.Add(new KeyValuePair <string, string>("X-Search-AppId", "07D3234E49CE426DAA29772419F436CA")); // Refer to the doc request.Headers.Add(new KeyValuePair <string, string>("X-Search-ClientID", "1ECFAE91408841A480F00935DC390960")); // The software originating the requestB request.Headers.Add(new KeyValuePair <string, string>("User-Agent", "TTSClient")); request.RequestMessage = new HttpRequestMessage(HttpMethod.Post, parameters.RequestUri) { Content = new StringContent(parameters.Ssml) }; return(request); }
public void VoiceNameTest() { var ssmlBuilder = new SimpleTextSsmlBuilder(); var serviceClient = new Talker(); serviceClient.OnAudioAvailable += PlayAudio; serviceClient.OnError += ErrorHandler; string voiceName = "Microsoft Server Speech Text to Speech Voice (en-US, Jessa24KRUS)"; // string voiceName = "Microsoft Server Speech Text to Speech Voice (en-US, Guy24KRUS)"; // string voiceName = "Microsoft Server Speech Text to Speech Voice (en-US, ZiraRUS)"; string ssml = ssmlBuilder.GenerateSsml("en-US", voiceName, "Hello. You are so awesome!"); var requestParams = new TalkerParameters() { AuthorizationToken = _accessToken, RequestUri = _requestUri, OutputFormat = AudioOutputFormat.Riff24Khz16BitMonoPcm, Ssml = ssml }; serviceClient.Speak(CancellationToken.None, requestParams).Wait(); }