Google Cloud API Graphics

Using this code I found on YouTube video (don't know if I can post):

if (File.Exists("audio.raw"))
{
    var speech = SpeechClient.Create();
    var response = speech.Recognize(new RecognitionConfig()
    {
        Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
        SampleRateHertz = 16000,
        LanguageCode = "iw",
    }, RecognitionAudio.FromFile("audio.raw"));

    textBox1.Text = "";

    foreach (var result in response.Results)
    {
        foreach (var alternative in result.Alternatives)
        {
            textBox1.Text = textBox1.Text + " " + alternative.Transcript;
        }
    }

    if(textBox1.Text.Length == 0)
        textBox1.Text = "No Data ";
    StreamingMicRecognizeAsync(10);
}
else
{
    textBox1.Text = "Audio File Missing ";
}

      

I have managed to build speech recognition based on google cloud api.

However, I can't seem to find a way to create the grammar this way, so I'm looking for suggestions.

How can I create a grammar filter for google api?

Maybe a project created by someone, or some apis that already does this (ex: entering the main line "one", "two", "three" and then if you enter for example "tu" 'll output "two", if you enter "today" it will output that nothing matches, etc., eg Microsoft grammar)

I've read about SpeechContexts but only read in C # and I really couldn't get anything to work.

Any suggestions?

Edit:

Also how can I use it offline? it would be great ... or at least make it faster.

I tried the streaming option but not entirely accurate.

+3


source to share


1 answer


Assuming you just want to add SpeechContext

to your request, just add instances to the property RecognitionConfig

SpeechContexts

:

var context = new SpeechContext { Phrases = { "first", "second" } };
var config = new RecognitionConfig()
{
    Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
    SampleRateHertz = 16000,
    LanguageCode = "iw",
    SpeechContexts = { context }
};

      



(In general, protobuf properties representing maps and lists are read-only, but you can add to them by explicitly calling Add

or using collection initializers as above.)

+3


source







All Articles