locked
Save to MemoeryStream RRS feed

  • Question

  • I am using the Text to Speech in an Api App.

    I took the C# sample code from TTSHttpOxford and am using is as such.

     [Metadata("GetVoiceStream", "Gets a voice stream")]
            [Route("Voice")]
            [HttpGet]
            [SwaggerOperation("GetVoiceStream")]
            [SwaggerResponse(HttpStatusCode.Created)]
            [SwaggerResponse(HttpStatusCode.BadRequest)]
            public  Task GetVoiceStream(
               [Metadata("Text", "Text to be for Voice File")] string txt)
            {
                AccessTokenInfo token;
                var auth = new Authentication("XXXXXX", "XXXXXXXXXXX");
                token = auth.GetAccessToken();
    
                 var cortana = new Synthesize(new Synthesize.InputOptions
                 {
                     RequestUri = new Uri(requestUri),
                     // Text to be spoken.
                     Text = txt,
                     VoiceType = Gender.Male,
                     // Refer to the documentation for complete list of supported locales.
                     Locale = "en-US",
                     // You can also customize the output voice. Refer to the documentation to view the different
                     // voices that the TTS service can output.
                     VoiceName = "Microsoft Server Speech Text to Speech Voice (en-US, BenjaminRUS)",
                     // Service can return audio in different output format. 
                     OutputFormat = AudioOutputFormat.Riff16Khz16BitMonoPcm,
                     AuthorizationToken = "Bearer " + token.access_token
                 });
    
                return  cortana.Speak(CancellationToken.None);
               
            }


    Ideally I need to return an HttpResponseMessage.

    Or a the vary least save to file.


    Howard S. Edidin MCTS BizTalk Server 2010 http://biztalkin-howard.blogspot.com/

    Saturday, July 23, 2016 7:36 PM