Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

How to integrate Bing Speech API

Hi,
I'm trying to integrate Bing Speech API, because the local speech recognition only supports english. The problem is, that both the client library and the documentation for the REST API, isn't compatible with UAP.
I have no idea how I can connect. Do you have an idea or maybe a working code snippet?
Kind regards from Germany

Answers

  • Options
    trzytrzy ✭✭✭

    Unfortunately I don't have an answer for this but I'm also curious. Connectivity shouldn't be a big problem, though -- should be doable with raw sockets, no?

    But what about recording snippets of voice? I haven't looked in detail at the relevant microphone APIs but is there a way for the microphone to detect when the user is likely to have started and then stopped speaking, so as to avoid having to continually record and monitor the audio stream in order to manually extract dialog out?

  • Options
    DaradonnDaradonn
    edited July 2017

    Recording is pretty easy. In the HoloToolkit there is a class called MicStream.
    So you just have to use the following lines:

    //Start Recording
    MicStream.MicInitializeDefault((int)MicStream.StreamCategory.HIGH_QUALITY_VOICE);
    MicStream.MicStartRecording("record.wav", true);
    
    //Stop Recording
    String filePath = MicStream.MicStopRecording();
    

    I don't know what my problem with the connection is.
    Getting the token works fine, but sending the audio to get the response times out.
    This is my code:

    private string requestUri= "https://speech.platform.bing.com/speech/recognition/dictation/cognitiveservices/v1?language=de-DE";
    
    
    //calling the sending task from another method
    string result = await SendRequestAsync(requestUri, authentication.GetAccessToken(), "audio/wav; samplerate=16000", filePath);
    
    
    //the sending task
    private async Task<string> SendRequestAsync(string url, string bearerToken, string contentType, string filePath)
        {
            var content = new StreamContent(File.OpenRead(@filePath));
            content.Headers.TryAddWithoutValidation("Content -Type", contentType);
    
            using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken);
                var response = await httpClient.PostAsync(url, content).ConfigureAwait(false);
    
                return await response.Content.ReadAsStringAsync();
            }
        }
    
Sign In or Register to comment.