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 Task <HttpResponseMessage> SendAsync(TTSRequest ttsRequest, HttpCompletionOption completionOption, CancellationToken cancellationToken) { _client.DefaultRequestHeaders.Clear(); foreach (var header in ttsRequest.Headers) { _client.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value); } var response = _client.SendAsync(ttsRequest.RequestMessage); return(response); }