How to Parse Google Speech API response in text box - c#

I am working on google speech API in c#.
Google is returning results with no problem and its response is shown on my text box.
Now I want limited text to be displayed on text box. As given response below, I want only recognized text to be displayed e.g. the Text box should display you said Ball.
Result string and alternative transcripts should be eliminated.
this is the response from google speech API when I said Ball:
{"result":[]}
{"result":[
{"alternative":[
{"transcript":"boa"},
{"transcript":"ball"},
{"transcript":"bull"},
{"transcript":"boys"},
{"transcript":"call"}
],
"final":true}
],
"result_index":0}

You probably want to pass the single_utterance option to StreamingRecognitionConfig. There's some more information available here:
https://cloud.google.com/speech/reference/rpc/google.cloud.speech.v1beta1#google.cloud.speech.v1beta1.StreamingRecognitionConfig
If you're not going to use the alternatives, you can also set maxAlternatives to 1 or leave it with the default of 1. interim_results should also be set to the default value of false.
I'm not sure the exact syntax in C#. You'll still have to pick out the final transcript, but there will be less unwanted information in the response.

Related

How to parse response text from some service?

so this is my problem.
I use a prepaid account.
I call *100#, and get response from my phone operator about my account balance.
response link
This says "You have 1.12 BAM left on you account and you can use it until 02.08.2014.
Here is the question.
I want to make this cal programmatically, from code.
I know it's easy, using PhoneCallTask.
Is there any way to parse this response???
No, there is no way to parse the response and no way to make the call programmatically (PhoneCallTask just shows the UI with the number filled in and the user has to confirm it)

ABBYY OCR - How to use multiple region parameters in the Uri?

I'm working with ABBYY cloud OCR, when my popruse is to scan 3 specific places in each document that I'm scanning. These 3 places will always be the same so I want to use the ProcessFields function do it and having some problems with it.
When I want to scan only one specific place I used this :
string url1 = String.Format("http://cloud.ocrsdk.com/processFields?region=0,0,200,200&language=english");
When trying to scan 2 places I've tried this :
string url1 = String.Format("http://cloud.ocrsdk.com/processFields?region=0,0,200,200 region 100,100,100,100&language=english");
it gave me an error.
Anyone has any advise how to do it?
I also tried defieng 3 Uri's but as the upload is done only once - how can I reach the 2 other Uri's without scanning it again?
thanks a lot!
According to documentation of processField method, you can't pass field parameters in URI, you should form an XML and submit it using POST method instead of GET. There is also a sample XML file on that page.
Simple method with URI works only for one field and processTextField method.

Get visible lines in Scintilla.NET component

How can I get the first visible (top) and last visible (bottom) lines number for Scintilla component in C#? For example, if I scroll the text and I am able to see lines 5-41 (no folding, it is the number of lines which are shown by the component at the moment; the rest, you have to scroll to them), how do I get those numbers programatically?
If you ever want to find out how to do something with Scintilla, your first stop should always be the core Scintilla Documentation. It is comprehensive, and usually kept fully up to date.
The correct way to do what you want is to use the SCI_GETFIRSTVISIBLELINE message to get the first line, and then use the SCI_LINESONSCREEN message to calculate the last line.
There are probably Scintilla.NET wrapper methods for those messages. But the Scintilla.NET documentation seems very poor, and doesn't provide a complete description of its API - although I suppose you could always use the SendMessageDirect method (which is documented) to send the messages directly if you can't guess what the wrapper method is called.
For ScintillaNET 2 it would be:
scintilla.Lines.FirstVisibleIndex
scintilla.Lines.VisibleCount
In ScintillaNET 3 names were refactored to be more like core scintilla:
scintilla.FirstVisibleLine
scintilla.LinesOnScreen

Validate Max Text Input Size MVC

I'm struggling on logic here - can i get some ideas please! :)
basically i have a c# MVC3 application that accepts a huge amount of text (100+ text areas), modifies it, and then outputs it.
i want to check the length of the combined text boxes and have the process fail validation if they are over X length.
the only solution i can think of is by combining all the text into a string server side and get the length. I'm expecting my competitors to fully abuse the system and attempt to overload my servers when i go live, so i want to try and validate on the client side too if possible.
can anyone think of an efficient way to do this (client or server-side if you have a nice idea).
You could use maxlength css property or you could decorate your model with [StringLength] data annotation to check length of the string
Build a custom validator using a technique similar to this answer by Daron Dimitrov. That will do the check on both client and server side and you can use a ViewModel to decorate the attribute to apply to all of the inputs.

C# code for downloading item, that checks text/binary, and gzip/non-compressed?

QUESTION: Anyone have some code they could post that will download a file from a URL/Link that will automatically handle:
(a) binary or text based
(b) gzip encoded
BACKGROUND: I've been starting to do this but hitting hurdles. Like I was using WebClient however it seems it can't handle the gzip bit (need to drop back to HTTPWebRequest). Also I'm getting a little confused re how to tell if the link/URL (e.g. taken from a HTML page) is really Text or Binary. Is there a well list of all content types that would be TEXT, or the ones that would be BINARY?
Thanks
You can check for ContentType header in the Response's headers, primarily all text types begin with "text/*" like "text/html", "text/xml" etc etc, however here is a list of content types that can be useful. "application/javascript" etc are also text based but they are in different category.
Content Types
Does the answer to this question Does .NET's HttpWebResponse uncompress automatically GZiped and Deflated responses? give you what you want?

Categories

Resources