2

hello I'm trying to find free and useful speech recognition for C# windows application. I've tried System.Speech.Recognition; but if phrase or word is not pre-recorded and I want use DictationGrammar sometimes I have to say 20 times same phrase or word, but 20 times I have wrong recognition results. So I do not mean that it does not work well, but it doesn't work for my case. So if I can somehow to make it work better, need your help here:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//using System.Speech;
using System.Speech.Recognition;

public class Program
{
    public static void Main()
    {

        SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
        Grammar dictationGrammar = new DictationGrammar();
        recognizer.LoadGrammar(dictationGrammar);

        try
        {

            recognizer.SetInputToDefaultAudioDevice();
            RecognitionResult result = recognizer.Recognize();
            Console.WriteLine (result.Text);
        }
        catch (InvalidOperationException exception)
        {
            Console.WriteLine (String.Format("Could not recognize input from default aduio device. Is a microphone or sound card available?\r\n{0} - {1}.", exception.Source, exception.Message));
        }
        finally
        {
            recognizer.UnloadAllGrammars();
        }

        Console.Read();

    }

}

I have tried before Google Speech Recognition with Python and it was 95% correct at least, more then enough to say, that for me this is enough, but apparently if I do not have a key it is not available for free:

System.Net.WebException: The remote server returned an error: (403) Forbidden.
   at System.Net.HttpWebRequest.GetResponse()
   at GoogleRequest.Program.Main(String[] args) in C:\FOLDER\02_WORKFILE\Program.cs:line 36

Says that API keys are only for Chromium development and not to ask questions on this list https://www.chromium.org/developers/how-tos/api-keys Maybe there is some other way to use it:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;

namespace GoogleRequest
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {

                FileStream fileStream = File.OpenRead("good-morning-google.flac");
                MemoryStream memoryStream = new MemoryStream();
                memoryStream.SetLength(fileStream.Length);
                fileStream.Read(memoryStream.GetBuffer(), 0, (int)fileStream.Length);
                byte[] BA_AudioFile = memoryStream.GetBuffer();
                HttpWebRequest _HWR_SpeechToText = null;
                _HWR_SpeechToText =
                            (HttpWebRequest)HttpWebRequest.Create(
                                "https://www.google.com/speech-api/v2/recognize?output=json&lang=en-us&key=YOUR_API_KEY_HERE");
                _HWR_SpeechToText.Credentials = CredentialCache.DefaultCredentials;
                _HWR_SpeechToText.Method = "POST";
                _HWR_SpeechToText.ContentType = "audio/x-flac; rate=44100";
                _HWR_SpeechToText.ContentLength = BA_AudioFile.Length;
                Stream stream = _HWR_SpeechToText.GetRequestStream();
                stream.Write(BA_AudioFile, 0, BA_AudioFile.Length);
                stream.Close();

                HttpWebResponse HWR_Response = (HttpWebResponse)_HWR_SpeechToText.GetResponse();
                if (HWR_Response.StatusCode == HttpStatusCode.OK)
                {
                    StreamReader SR_Response = new StreamReader(HWR_Response.GetResponseStream());
                    Console.WriteLine(SR_Response.ReadToEnd());
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            Console.ReadLine();
        }
    }
}

Also I tried to use Bing Speech API, but seems it's only for use in XAML apps here msdn.microsoft.com/en-us/library/dn434606.aspx and msdn.microsoft.com/en-us/library/dn467592.aspx

then I found this list of tools, but seems like is nothing for free http://www.dmoz.org/Computers/Speech_Technology/Toolkits/

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
  • Do you need full dictation grammar, or only need to recognize a list of commands? Microsoft Speech Recognition has more accuracy if it only has to match with a smaller (custom made) grammar list of commands, other than trying to match with the entire language dictionary. – Gerardo Grignoli Aug 19 '16 at 04:39
  • @Gerardo Grignoli hello yes with pre-recorded commands `System.Speech.Recognition;` works very good, fast, but with dictation grammar result is different, so I need recognize not pre-recorded speech –  Aug 19 '16 at 04:50
  • 1
    Googles Speech Rec. Api is not free at all, at least not for commercial use. Going a page further you see the pricing, 60 Minutes in a month are free, for more you pay $0,006 per 15 Seconds. https://www.quora.com/What-are-the-top-ten-speech-recognition-APIs. IBMs Watson Service let you process 1000 Minutes a month for free though. But keep in mind, that with a decent user basis those minutes will be used quite fast. – prizm1 Aug 19 '16 at 07:15
  • A Speech Recognition Engine will only recognize those words which are inside its vocabulary. It does not create "new" words by recognizing and combining phonems (at least nowadays). When ever a word is not recognized, search for it in the vocabulary, and add it if is not yet there. You may also need to add some pronounciation hints. Creating vocabulary is a tedious job! – Bernhard Hiller Aug 19 '16 at 08:24
  • @Bernhard Hiller in my case main thing is recognize "new" word or phrase, otherwise it is not what I want. I need something that works as a Google Speech Recognition, but not sure what can work for me this way –  Aug 19 '16 at 11:53
  • @prizm1 I still use it in Python, works very good. it's not for commercial use, but how can I get this 60 minutes for free in my C# windows form? –  Aug 19 '16 at 11:56
  • 1
    @zrubi "main thing is recognize "new" word or phrase" Well, then you have to create your own SRE... – Bernhard Hiller Aug 19 '16 at 12:00

0 Answers0