Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7542527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:11:27+00:00 2026-05-30T08:11:27+00:00

Following is the way to make powershell to speak. Add-Type -AssemblyName System.Speech $synthesizer =

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:11:28+00:00Added an answer on May 30, 2026 at 8:11 am

    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.

    $null = [Reflection.Assembly]::LoadWithPartialName("System.Speech")
    
    ## Create the two main objects we need for speech recognition and synthesis
    if (!$global:SpeechModuleListener) {
        ## For XP's sake, don't create them twice...
        $global:SpeechModuleSpeaker = New-Object System.Speech.Synthesis.SpeechSynthesizer
        $global:SpeechModuleListener = New-Object System.Speech.Recognition.SpeechRecognizer
    }
    
    $script:SpeechModuleMacros = @{}
    ## Add a way to turn it off
    $script:SpeechModuleMacros.Add("Stop Listening", {$script:listen = $false; Suspend-Listening})
    $script:SpeechModuleComputerName = ${env:ComputerName}
    
    function Update-SpeechCommands {
        #.Synopsis 
        #  Recreate the speech recognition grammar
        #.Description
        #  This parses out the speech module macros, 
        #  and recreates the speech recognition grammar and semantic results, 
        #  and then updates the SpeechRecognizer with the new grammar, 
        #  and makes sure that the ObjectEvent is registered.
        $choices = New-Object System.Speech.Recognition.Choices
        foreach ($choice in $script:SpeechModuleMacros.GetEnumerator()) {
            New-Object System.Speech.Recognition.SemanticResultValue $choice.Key, $choice.Value.ToString() |
                ForEach-Object { $choices.Add($_.ToGrammarBuilder()) }
        }
    
        if ($VerbosePreference -ne "SilentlyContinue") {
            $script:SpeechModuleMacros.Keys |
                ForEach-Object { Write-Host"$Computer, $_" -Fore Cyan }
        }
    
        $builder = New-Object System.Speech.Recognition.GrammarBuilder"$Computer, "
        $builder.Append((New-ObjectSystem.Speech.Recognition.SemanticResultKey"Commands", $choices.ToGrammarBuilder()))
        $grammar = New-Object System.Speech.Recognition.Grammar $builder
        $grammar.Name = "Power VoiceMacros"
    
        ## Take note of the events, but only once (make sure to remove the old one)
        Unregister-Event"SpeechModuleCommandRecognized" -ErrorAction SilentlyContinue
        $null = Register-ObjectEvent $grammar SpeechRecognized `
                    -SourceIdentifier"SpeechModuleCommandRecognized" `
                    -Action {iex $event.SourceEventArgs.Result.Semantics.Item("Commands").Value}
    
        $global:SpeechModuleListener.UnloadAllGrammars()
        $global:SpeechModuleListener.LoadGrammarAsync($grammar)
    }
    
    function Add-SpeechCommands {
        #.Synopsis
        #  Add one or more commands to the speech-recognition macros, and update the recognition
        #.Parameter CommandText
        #  The string key for the command to remove
        [CmdletBinding()]
        Param([hashtable]$VoiceMacros,[string]$Computer=$Script:SpeechModuleComputerName)
    
        ## Add the new macros
        $script:SpeechModuleMacros += $VoiceMacros 
        ## Update the default if they change it, so they only have to do that once.
        $script:SpeechModuleComputerName = $Computer 
        Update-SpeechCommands
    }
    
    function Remove-SpeechCommands {
        #.Synopsis
        #  Remove one or more command from the speech-recognition macros, and update the recognition
        #.Parameter CommandText
        #  The string key for the command to remove
        Param([string[]]$CommandText)
        foreach ($command in $CommandText) {
            $script:SpeechModuleMacros.Remove($Command)
        }
        Update-SpeechCommands
    }
    
    function Clear-SpeechCommands {
        #.Synopsis
        #  Removes all commands from the speech-recognition macros, and update the recognition
        #.Parameter CommandText
        #  The string key for the command to remove
        $script:SpeechModuleMacros = @{}
        ## Default value: A way to turn it off
        $script:SpeechModuleMacros.Add("Stop Listening", {Suspend-Listening})
        Update-SpeechCommands
    }
    
    function Start-Listening {
        #.Synopsis
        #  Sets the SpeechRecognizer to Enabled
        $global:SpeechModuleListener.Enabled = $true
        Say "Speech Macros are $($Global:SpeechModuleListener.State)"
        Write-Host "Speech Macros are $($Global:SpeechModuleListener.State)"
    }
    
    function Suspend-Listening {
        #.Synopsis
        #  Sets the SpeechRecognizer to Disabled
        $global:SpeechModuleListener.Enabled = $false
        Say "Speech Macros are disabled"
        Write-Host "Speech Macros are disabled"
    }
    
    function Out-Speech {
        #.Synopsis
        #  Speaks the input object
        #.Description
        #  Uses the default SpeechSynthesizer settings to speak the string representation of the InputObject
        #.Parameter InputObject
        #  The object to speak 
        #  NOTE: this should almost always be a pre-formatted string,
        #        most objects don't render to very speakable text.
        Param([Parameter(ValueFromPipeline=$true)][Alias("IO")]$InputObject)
        $null = $global:SpeechModuleSpeaker.SpeakAsync(($InputObject | Out-String))
    }
    
    function Remove-SpeechXP {
        #.Synopis
        #  Dispose of the SpeechModuleListener and SpeechModuleSpeaker
        $global:SpeechModuleListener.Dispose(); $global:SpeechModuleListener = $null
        $global:SpeechModuleSpeaker.Dispose();  $global:SpeechModuleSpeaker = $null
    }
    
    Set-Alias asc Add-SpeechCommands
    Set-Alias rsc Remove-SpeechCommands
    Set-Alias csc Clear-SpeechCommands
    Set-Alias say Out-Speech
    Set-Alias listen Start-Listener
    Export-ModuleMember -Function * -Alias * -VariableSpeechModuleListener, SpeechModuleSpeaker
    

    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.

    Add-SpeechCommands @{
       "What time is it?" = { Say "It is $(Get-Date -f "h:mm tt")" }
       "What day is it?"  = { Say $(Get-Date -f "dddd, MMMM dd") }
       "What's running?"  = {
          $proc = ps | sort ws -desc
          Say $("$($proc.Count) processes, including $($proc[0].name), which is using " +
                "$([int]($proc[0].ws/1mb)) megabytes of memory")
       }
    } -Computer "Laptop" -Verbose 
    
    Add-SpeechCommands @{
        "Run Notepad"= { & "C:\Programs\DevTools\Notepad++\notepad++.exe"}
    }
    Add-SpeechCommands @{
        "Check Gee Mail" = { Start-Process"https://mail.google.com" }
    }
    

    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?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a powershell script in which I do the following $somePSObjectHashtables = New-Object
I want to make the object of NSUrl in following way but Utilities is
I define a custom PowerShell type with New-Object. I would like a parameter to
Currently I'm checking it in the following way: if (Environment.UserInteractive) Application.Run(new ServiceControllerForm(service)); else ServiceBase.Run(windowsService);
I've been using ShowDialog() in following way for all my new Windows. SomeGui test
How do I make my Windows Service to work in the following way... 1.)
I want to create a helper object that will work the following way: It
We can create, for example, new array following way: values = Array.new(5) { rand(6)
I was looking for a way to make required parameters in powershell when I
Try to make a timer like following way: HTML: <div id=timer> <span id=minute class=dis>00</span>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.