Hi,
I am trying to do some voice recognition via Powershell. - Just to play a bit. I have already found some information about this with help of google. But the most source code is in C#.
My Problem is the following. In C# the event handler is attached like the following:
1
2
speechRecognitionEngine.SpeechRecognized += Â Â ``newEventHandler(engine_SpeechRecognized);
How can I do this in Powershell? I’ve tried to do the following:
Perfect.
This was exactly what I was looking for
I didn’t know the cmdlet Register-ObjectEvent.
But how can I now decide what was recognized? In c# there is something like “object sender”.
I already tried with $sender or $this … but they are empty
To access an event’s arguments, use the $EventArgs.SourceArgs built-in variable. $Sender contains the object that generated the event, not it’s arguments. For more info on the built-in event variables, check out Get-Help about_Automatic_Variables.
As an example, say I wanted to access the SignalTime argument passed to the Elapsed event in a Timer object. I would so the following:
I’m guessing that you’re seeing the quotes in Write-Host print but not the objects themselves, right? If that’s what you’re running into, then you’re dealing with one of the quirks of PowerShell eventing. If you insist on calling Write-Host on an object, you have to call its ToString() method. To validate that $Event is actually being returned, save it to a global variable ($Global:Foo = $Event) and then access it.
I don’t understand what is the difference but it looks like there is one.
But not everything is recognized now…just the predefined Texts.
Is there no way to get what the computer understood? - The idea behind all this was to can say anything and get it as text… - similar to dictation.