Following is the way to make powershell to speak.
Add-Type -AssemblyName System.Speech
$synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$synthesizer.Speak('Hey, I can speak!')
Actually i would like to do opposite. If i speak , can powershell convert it into letters.
If i say in my sound recorder “Hey, I can speak”, will it convert into text?
If possible please guide me how to achieve it?
Looks like you can with
System.Speech.Recognition. Here is even example usage written in PowerShell:http://huddledmasses.org/control-your-pc-with-your-voice-and-powershell/
This link went 404 so I dug it out of the way back machine.
control your PC with your voice … and PowerShell
By Joel ‘Jaykul’ Bennett on 25-Jun-2009
Have you ever wanted to be able to ask your computer questions and have it answer you out loud?Have you ever wondered if your computer could be more like the ones running the Star Trek Enterprise, responding to voice queries and commands? Have you played with ZWave or X10 home automation and thought that voice control of your devices would be an obvious next step?
Well, ok … I’m not going to show you how to turn on lights or work with home automation — but that’s the main thing that keeps me thinking about this voice-recognition stuff. What geek doesn’t want to walk into the living room and say “Computer: Lights On” and have it work?
Instead, as a first step to all of that, let me show you how to use PowerShell to do simple voice command recognition scripts … which can fire off any PowerShell script you care to write! The code which follows is really a module, although you can just dot-source it as a script, and it really requires PowerShell 2.0 for the events, although it would be trivial to refactor it to work on PowerShell 1.0 using Oisin’s PSEventing library.
There’s basically just one function you need to worry about here: New-VoiceCommands. You pass it a hashtable which maps strings to scriptblocks, and if you use the -Listenswitch that’s all there is to it. You can also callStart-Listening manually, and of course, I’ve provided the Say function to make it easier to have the computer speak…
Once the computer is “listening” … you just say it’s name, followed by one of your commands. I like that because it ensures that I don’t run the scripts by accident, but you can remove the
${Env:ComputerName},string from the beginning of the GrammarBuilder if you think it’s not necessary, or you can hard code it to something other than your computer’s name, like say “Hal, please, I beg you … ” or “Computer, please ” or whatever?You can do a lot of things with this … anything, really … but to give you an example that you can easily understand, I’m going to do something very simple, and have my computer just answer a few basic questions by talking back to me, and then add a few commands to have it start an app or a web page.
You see how easy that is? You can use “Say” to speak any text (although sometext will get better results than others), and you can invoke any other powershell commands, including HttpRest commands to fetch web data, or WASP commands for windows automation, or PowerBoots commands to display output in large text, or cmdlets to control X10 or ZWave devices … you know, anything?