Microsoft Speech Platform - how to update rules at runtime - c#

I am using the System.Speech to build a C# application with voice recognition capabilities.
I read this post http://msdn.microsoft.com/en-us/library/jj127913.aspx that mentions how to update rules dynamically at runtime.
I wonder how I can do the same trick with the C# System.Speech API.
Do you have any idea?
Thank you

System.Speech is a bit different from the SAPI described under this link, however, it's even easier to construct grammars in runtime, you can use GrammarBuilder class for that. You can add any structure of choices and rules to construct the language you need to recognize.
Once you updated the grammar you can load the grammar into recognizer recognizer with LoadGrammar

Related

How to control third-party text-to-speech voices using SAPI 5?

Windows includes the SAPI 5 API that lets you control TTS voices. However I'm using Acapela Peter and it does not show up in the window TTS dialog. So I cannot use this voice with the typical .NET APIs (for example this codeproject app). However the voice shipped with this text file : VoiceDescriptions.txt which seems like variables that I can feed into the SAPI engine to help it detect this voice. So my question is : How do I use this voice metadata to generate speech with SAPI? I have all of the referenced files installed with the voice. I found the SpVoice Win API but it does not mention any way of loading metadata from text.
[LANG,British]
#=eng.tml
PHOTREE=eng.trx
PROSO=eng.oso
F0=eng.f0r
DICTIONARY=eng.bab.dca
LDI=eng.bab.ldi
BNF=eng.bnx
BNFNOTAG=eng.notag.bnx
POST=eng.pst
GRI=eng.gri
GRO=eng.gro
SPD=180
Language=British
Info=eng.nfo
[VOICE,Peter22k,British,British]
Base=Peter22k.nuul
Coeff=Peter22k.coef
Database=Peter22k.vco
Info=Peter22k.nfo
Pitch=110
Speed=100
Freq=22050
It looks like Acapela has a separate product that adds a SAPI interface layer.
If you want to roll it yourself, you could write a SAPI engine interface to the Acapela TTS engine, but that's a significant undertaking (probably 2-3 dev months to create).

Add words to DictationGrammar in C# Speech Recognition?

This is something that has bugged me for a while. I'm developing a C# application that uses voice control, and I was wondering if there is any possible way to load a DictationGrammar and then add words to it to improve accuracy. For instance: I'm trying to use it to search google and bing. It barely recognizes the word 'google' and has never recognized the word 'bing'. Is there any way to do this? DictationGrammar is not very accurate at all (it keeps adding words). Currently, I'm loading the grammar like this:
PACSREC.LoadGrammarAsync(new DictationGrammar());
You can add words to the user lexicon, and the DictationGrammar will implicitly add those words.
Unfortunately, the Lexicon APIs aren't exposed via the System.Speech.Recognition APIs; instead, you'll have to use the SpeechLib (automation-compatible) APIs to do so. See this question for examples.

Simple Grammar for Speech Recognition

I have a program with GrammarBuilders and Grammer that is used in a SpeechRecognitionEngine to recognize speech. Can I, rather than recognizing from audio, use the same grammar to recognize a typed command (in a string)? Something like commandGrammar.parse(commandString)?
You should be able to use SpeechRecognitionEngine.EmulateRecognize which takes a text input in place of audio for speech recognitions.
I am not sure of the intended use, but if this will be used for something like a chat bot that automatically interacts with text input via IM or SMS I think you will find grammars very cumbersome to maintain and restrictive. I would recommend something like Artificial Intelligence Markup Language (AIML) for handling text responses. It is easy to learn and very powerful. Instead of using concise grammars which ASR's require, this language allows you to use wildcards which are much more conducive to text input. There are even some C# open source projects that provide libraries to work with AIML and simplify creation of chat bots.

Online and automatic resource localization in C#

I have a c# winforms project with many forms, now I want to localize these forms to another language, is there any way or code that generates resource files for forms and translate them online?
Thanks
There are open source tools which allow to translate resx files. I haven't found a version which uses a online translation service such as google translate or the microsoft translator api or even the bablefish. But I think the Resx Translation Helper (open source project) should be very easy to modify. Note however, that the author explicitly discourage the usage of autogenerated translation:
It does NOT automatically translate because user-translation is currently still much better than automated translation.
if you will be able to generate resx file from your sources. maybe Crowdin.net will be suitable solution for online translations.
The Visual Localizer tool utilizes Google Translate, Microsoft Translator and MyMemory for this very purpose. It has also many other features regarding automatic localization in .NET.
You can use ReSharper plugin and/or RGreatEx - The ReSharper Great Extension
and U can easily Move strings to resource to translate them for specific language.

How to recognize text with SAPI?

How can I recognize text with SAPI, using C#?
Where can I find sample code?
Use the System.Speech.Recognition namespace. There's little point in battling the SAPI COM interfaces yourself, the SpeechRecognizer class lets you do anything you can do in SAPI. Point your browser to the MSDN Library topics for that namespace, you'll find plenty of examples.
they only thing I couldn't get system speech to do was to switch on/off a shared recognizer you can only get the state although in SAPI you can do this as the property isn't read only.
To get around this I use both SAPI (SpeechLib) and System.Speech.Recognition together. I noticed the shared recognizer follows the singleton design pattern which means that if it's already open you get a reference to the existing SAPI instance back rather then creating a new one.
This means that I could have a reference SAPI though the system.speech.recognition library and SpeechLib.dll.
(You get the best of both)
Kiran ;)

Categories