c# - Google Speech API v2 result is blank -


I want to use the Google Speech API in my current project.

How do I use the API

As described on Github, you have to send a post web circle to the server and get the result as Jason.

I found some source code used for V1 API

The request is not difficult to set up:

 < Code> WebRequest request = WebRequest.Create (Constants.GoogleRequestString); request. Method = "post"; Request.ContentType = "audio / x-flac; rate =" + sampleRate; Request.ContentLength = bytes.Length;   

In my example where the constants are GoogleRequestString is equal https://www.google.com/speech-api/v2/recognize?output = Jason & amp; Lang = en-us & amp; key = AIzaSyCnl6MRydhw_5fLXIdASxkLJzcJh5iX0M4

I downloaded the .flac files from the github link and wrote a little program in C # which is loading the bytes of the flac file, it is slightly modified method Send with GoogleRequest (byte [] bytes, int sampling)

I open the stream as shown in the method, and all the bytes to the server I get a response but

I am getting JSON string: "{\" result \ ": []}"

I do not know why it not working. Either the file with the file or the bid in the file is not correct (but if I listen to it with VLC, then I can hear plainly speaking texts) or there are some bugs in my program.

Have you ever encountered the problem Speech - to get results from the API? It should be said that like results: what is the matter or any other error message did not understand?

I have just tried to exclude the .wav file. It worked for me

Your code assumes that it is okay like this:

  var uriBuilder = new Uribbilder ("https", "www.google.com", 443, "Speech-API / V2 / Identity", "? Production = JSON and Lang = N-U And key = yapi "); Int sampling = 44100; (Var stream = File.Open ("c: \\ tmp \\ g2.flac", FileMode.Open)) {HttpWebRequest request = (HttpWebRequest) WebRequest.Create (uriBuilder.Uri); request. Method = "post"; Request.ContentType = "audio / x-flac; rate =" + sampleRate; request. Automatic Decompression = Depression Remover GGIP; Stream.CopyTo (request.GetRequestStream ()); Try {{var resp = request.GetResponse (). GetResponseStream ()) {usage (var sr = new StreamReader (resp)} {Debug.WriteLine (sr.ReadToEnd ()); }}} Cache (WebException EE) {var all = New Stream Reader (E.E. Response Gateresonsstream ()). Reddend (); Debug.WriteLine (All); }}   

What is important though is the exact format of the FLAC file. I used to control how I would save my audio track.

After recording, I changed the track settings to:

  • Mono
  • Sample format: 16-bit PCM
  • Rate: 44100 Hz

    The following screenshots show those settings:

    Tracks with default stereo and 32-bit float sample formats I could not find the speech API to create any other results if you got blank Jason Payload.

    My result is with the above settings: <("Transcript": "Translate this", "Confidence": 0.92849225}, {"Transcript": "Translation day" [" "Translate": "translate", "translate", "translate", "translate", " Last ": true}]," result_ index ": 0}

    My English pronunciation is not very good because Google thinks that I translate the fish I would like to ...

    If you get an HTTP error (eg 403 prohibited) the exception handler tries to read the complete respo, if your authentication key is incorrect from the NSS http body, it will tell you that < / p>

    Follow the instructions for working with your API-key to the speech API

    Ensure that you are a member of Chromium-div @ chromium.ORA (you simply Chromium-dev to choose not to receive more mail).

    You can then create a server:



Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -