What is the difference between Prompt() and SpeakAsync(String) - c#

I have read the documentation but fail to understand what the underlying difference is between using:
Prompt prompt = new Prompt("What are you doing?");
speaker.SpeakAsync(prompt);
VS:
speaker.SpeakAsync("What are you doing?");
The reason I am asking this is because I am trying to get a response from the user and it's not just a statement, I am expecting a specific answer to a question that the speaker asks.
For example, I want speaker to say "What are you doing?" and if the user speaks into the microphone, "I'm trying to read, leave me alone.", then the voice recognition should stay quiet.
I am trying to determine how to best handle Question/Answer-based scenarios. How should I handle this, when my app is expecting a specific type of answer so that it can act on it.

There's no reason to use Prompt if it is just a simple string.
But more elaborate phrases can be built with PromptBuilder, switching voice and volume, inserting pauses and audio snippets, using Ssml markup, specifying style and pronunciation, marking paragraphs and sentences. With some further likelihood that you want to preserve that if you repeat the phrase. You'll need to use the Prompt class for that.

A Prompt object can contain plain text, text formatted with markup language, or audio files.
SpeakAsync is of type prompt.
I had to check a tts app I did a while back.

Related

How can i set my c# program as default-browser which accepts http/https links?

I want my program to listen for links, which were send by other applications as default browser.
I tried out some searchings but i only found this article:
https://learn.microsoft.com/de-de/windows/desktop/shell/default-programs#becoming-the-default-browser
and i also cannot find an example, which shows up a way to solve this.
I hope for answers and would like to say "Thank you" to all answers.
Greetings
Penc
Originally it was just possible for your programm to set any file or protcoll asocaition. What happens was the predictable: Every other programmer abused that.
So it had to be take away and moved into the Default Programms UI. Now you can only tell windows your programms is avalible for that format.
But you can not become the default anymore without user action or maybe some Admin Level Operations/Registery editing. Maybe there is a odd allowances (for the common Browsers for example), but those will be on a case by case basis.

Fuzzy EmulateRecognize on Windows Speech Recognition

Microsoft C# API provide a SpeechRecognitionEngine to recognize Audio stream. One way to test recogition is to call method SpeechRecognizer.EmulateRecognize
According to documentation:
recognizers ignore case and character width when applying
grammar rules to the input phrase
I'd like to know if there is a way to handle more fuzzy string because confidence is very low even for mispelled text ! Far from real life...
With Audio I could say Hello, Helo, Helllo with a good confidence
With Text the engine is very strict
EDIT: For what purpose ?
My speech engine is working fine, but I also want to trigger it from text input.
Let's say your on mobile phone and use HTML5 SpeechRecognition. I'd like to send the recognized text to engine to get the same behavior as speech
Ok I found the answer !
I should better read the documentation !
SpeechRecognizer.EmulateRecognize
Is really straightforward and test the given string but
SpeechRecognizer.SimulateRecognize
Will try to build a an ‘idealized’ audio representation of the input phrase (based on the engine's lexicon and acoustic model)
And so it works very well !
When you send audio to the recognizer, the SR engine does a lot of work to create a set of phonemes (via acoustic modeling) and then a set of strings (via phoneme modeling). During that process, much of the ambiguity gets eliminated. EmulateRecognize doesn't generate audio that gets processed via the SR engine; it skips all the modeling and just does a string match.
There's no way to work around this that doesn't involve a lot of work (e.g., implementing a SAPI-compatible SR engine that only does EmulateRecognize).
Enter your string in the SpeechSynthesizer.Speak() and use that as input to SpeechRecognitionEngine?

How to handle incoming control characters in a custom terminal?

For my project I needed to create a custom terminal-like window and connect to a Cisco router through console port. So I inherited a TextBox and created a custom control in WPF. And I thought it would be enough; just to add some code to implement extra features I wanted. I'm sending one character at a time and wait for responses. But then I saw that my custom terminal does not handle special characters, those basic like \n sure are recognized but all the others not. I have written responses to a text file and I see i got quite a lot of those special ones but I don't know how should I react.
Maybe someone knows or have found some links with info about how to react for a specific control character? I have only found what characters are send here , but nothing else about it. I understand that for a "BS" I will delete one character before carriage but what should I do when I get "ACK" or "DC1" ? Maybe I should just skip them ? Any ideas?
Edit:
Apart from sending one character at a time I'll get response only when I send enter or characters like ? or TAB. Then when I receive a response it's mixed with special chars to format the text like in 80x25 terminal window. And I would like just to display it like it wants, but that means I need to know how to react when I get special chars I don't need to display them, just to format normal text based on the special ones I'm also receiving. When I get BS i need to clear the character before carriage, when I get DEL I need to clear the character after carriage. And I would like to know what I need to do when I'm getting other special chars. I know I can do it the hard way and just send those to a working terminal and see what it will do but it will take a while so I wonder if someone maybe knows the answer.
Ok, I played the hard way with terminal and now I know that the only special character I need to handle is BS (of course I only tried this with Cisco routers but I just need to work on them), the only problem is that you need to create your own code to get it work and move caret on the right place based on the BS count. And better create your own variable to store caret index because TextBox CaretIndex just didn't want to work as I expected. The rest of special characters can be, as far as I know, omitted. And it works great as I wanted.

Can you access standard Windows strings like 'Cancel'?

I am building a Windows dialog box that has the standard 'OK' and 'Cancel' buttons. Given that Windows uses the same button text in its own dialogs is there a way for me to grab the correct strings to use on the buttons?
This way my application will have the correct strings no matter which language is being used, without me needing to localize it for lots of different languages myself. I am using C# but can happily use platform invoke to access an OS method if needed.
NOTE: Yes, I can easily localize the resources but I do not want to find and have to enter the zillion different language strings when it must be present within windows already. Please do not answer by saying localize the app!
In Visual Studio: File + Open + File, type c:\windows\system32\user32.dll. Open the String Table node and double click String Table. Scroll down to 800.
Microsoft takes a pretty no-nonsense stance against relying on these resource IDs. Given the number of programmers who've done what you're contemplating, it is however unlikely they can ever change these numbers. You'll need to P/Invoke LoadLibrary() and LoadString().
However, your ultimate downfall on this plan is Vista/Win7 Ultimate with MUI language packs. Which allows the user to switch between languages without updating the resource strings in the DLLs. Such an edition will always have English strings.
see MB_GetString which claims to do exactly this:
https://msdn.microsoft.com/en-us/library/windows/desktop/dn910915(v=vs.85).aspx
however, it seems to require runtime linkage:
http://undoc.airesoft.co.uk/user32.dll/MB_GetString.php
Well, if you use the standard MessageBox.Show() function and pass it approriate parameters it will automatically localize the yes/no/okay/cancel buttons for you.
What is more interesting is how you localize the message text.
No, there is no standard, supported way to do this. Yes, Windows does store these strings and it's (with some effort) possible to obtain them, but there is no guarantee that they'll remain in the same location and under the same identifier from version to version.
While you might not want this to be the answer, the answer is, indeed, to localize your application. If you're localizing everything else (as you'd have to, unless you just wanted OK and Cancel to be localized), I'm not sure why it would be any great effort to include localized values for OK and Cancel as well.

How do you get speech dictated without adding it to a grammar list?

I'm new to Speech Recognition, and I'm working on a project that will receive a command from a recognizable list.
For example, I would say "Play song". The computer would ask the song title, and I can say it. It will then compare my answer to my music library and find it.
I know how to add recognizable grammar to the SpeechRecognizer object, how to make the computer speak, and how to play a song in iTunes. I cannot, however, figure out how to get it to dictate or listen and interpret something that isn't in the grammar list. Is there a method I'm missing? Or not yet been simplified by Microsoft? I have no code to show for this, as I am not even sure how to search for this particular idea.
Of course, I could have the program read my entire library, but that's not an optimal solution considering I have tens of thousands of songs. Thanks in advance!
Speech recognition works by comparing the signal to grammars, so there really isn't a good way to get a result without a grammar. Why not use the music library to generate the grammar list? I'm sure the result will be much more satisfactory. A really general grammar won't enable you to tell whether the user said "Madonna," "My Donna," or "Mad on a" with any sort of reliability. You might want to narrow the grammars further by letting the user choose to say an artist, title or album before they say it.

Categories

Resources