की तरह आप System.Speech.Recognition
साथ कर सकते हैं लगता है।
http://huddledmasses.org/control-your-pc-with-your-voice-and-powershell/
यह लिंक 404 तो चला गया मैं इसे जिस तरह से वापस मशीन से बाहर खोदा: यहाँ भी उदाहरण उपयोग PowerShell में लिखा है।
नियंत्रण अपनी आवाज के साथ अपने पीसी ... और PowerShell
25 जून 2009 को जोएल 'Jaykul' बेनेट द्वारा
आपको कभी अपने कंप्यूटर सवाल पूछने के लिए सक्षम होने के लिए यह चाहा है और यह आप का जवाब है ज़ोर से बाहर? क्या आपने कभी सोचा है कि क्या आपका कंप्यूटर स्टार ट्रेक एंटरप्राइज़ चलाने वाले लोगों की तरह हो सकता है, वॉयस प्रश्नों और कमांड का जवाब दे रहा है? क्या आपने जेडवेव या एक्स 10 होम ऑटोमेशन के साथ खेला है और सोचा है कि आपके डिवाइस का वॉयस कंट्रोल एक स्पष्ट होगा अगला कदम?
ठीक है, ठीक है ... मैं तुम्हें दिखाता कैसे लाइट चालू या घर स्वचालन के साथ काम करने के लिए नहीं जा रहा हूँ - लेकिन यह है कि मुख्य बात यह है कि मुझे इस आवाज मान्यता सामान के बारे में सोच रखता है। क्या गीक लिविंग रूम में नहीं चलना चाहता और "कंप्यूटर: लाइट्स ऑन" कहता है और यह काम करता है?
इसके बजाय, उन सभी के लिए पहला कदम के रूप में, मैं आपको दिखाता हूं कि पावरशेल का उपयोग सरल वॉइस कमांड मान्यता स्क्रिप्ट करने के लिए कैसे करें ... जो किसी भी पावरशेल स्क्रिप्ट को लिखने की आपकी देखभाल कर सकता है! जो कोड निम्नानुसार है वह वास्तव में एक मॉड्यूल है, हालांकि आप इसे स्क्रिप्ट के रूप में डॉट-स्रोत कर सकते हैं, और इसे वास्तव में ईवेंट के लिए PowerShell 2.0 की आवश्यकता होती है, हालांकि ओसीन की PSEventing लाइब्रेरी का उपयोग करके PowerShell 1.0 पर काम करने के लिए इसे पुन: सक्रिय करना मुश्किल होगा।
$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-objectSystem.Speech.Synthesis.SpeechSynthesizer
$Global:SpeechModuleListener =new-objectSystem.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-objectSystem.Speech.Recognition.Choices
foreach($choice in$Script:SpeechModuleMacros.GetEnumerator()){
New-ObjectSystem.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-ObjectSystem.Speech.Recognition.GrammarBuilder"$Computer, "
$builder.Append((New-ObjectSystem.Speech.Recognition.SemanticResultKey"Commands",
$choices.ToGrammarBuilder()))
$grammar = new-objectSystem.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
मूल रूप से केवल एक कार्य है जिसके बारे में आपको चिंता करने की आवश्यकता है: न्यू-वॉयस कमांड। आप इसे एक हैशटेबल पास करते हैं जो स्क्रिप्टब्लॉक पर तारों को मानचित्र करता है, और यदि आप -लिस्टेंसविच का उपयोग करते हैं तो यह सब कुछ है। आप मैन्युअल रूप से कॉलस्टार्ट-कॉलिंग भी कॉल कर सकते हैं, और निश्चित रूप से, मैंने कंप्यूटर फ़ंक्शन को आसान बनाना आसान बनाने के लिए कहें फ़ंक्शन प्रदान किया है ...
एक बार कंप्यूटर "सुन रहा है" ... आप बस इसका नाम कहें, आपके आदेशों में से एक द्वारा। मुझे पसंद है कि क्योंकि यह सुनिश्चित करता है कि मैं दुर्घटना से स्क्रिप्ट नहीं चला है, लेकिन आप GrammarBuilder की शुरुआत से ${Env:ComputerName},
स्ट्रिंग को हटा सकते हैं अगर आपको लगता है कि यह आवश्यक नहीं है, या आप कठिन अपने कंप्यूटर के नाम के अलावा कुछ करने के लिए यह कोड कर सकते हैं , जैसे कि "हैल, कृपया, मैं आपसे विनती करता हूं ..." या "कंप्यूटर, कृपया" या जो कुछ भी कहें।
आप इसके साथ बहुत सी चीजें कर सकते हैं ... कुछ भी, वास्तव में ... लेकिन आपको एक उदाहरण देने के लिए जो आप आसानी से समझ सकते हैं, मैं कुछ सरल करने जा रहा हूं, और मेरा कंप्यूटर बस कुछ बुनियादी जवाब दे रहा है मेरे साथ बात करके प्रश्न, और फिर कुछ आदेश जोड़ें ताकि इसे ऐप या वेब पेज शुरू किया जा सके।
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" } }
आप कितना आसान है कि देखते हैं? आप किसी भी पाठ को बोलने के लिए "कहें" का उपयोग कर सकते हैं (हालांकि कभी-कभी दूसरों के मुकाबले बेहतर परिणाम मिलेंगे), और आप वेब डेटा लाने के लिए एचटीपीआरएएस कमांड सहित, या ऑटोमेशन के लिए डब्ल्यूएएसपी कमांड, या पावरबूट्स कमांड प्रदर्शित करने के लिए किसी भी अन्य पावरहेल कमांड का आह्वान कर सकते हैं X10 या ZWave उपकरणों को नियंत्रित करने के लिए बड़े टेक्स्ट, या cmdlets में आउटपुट ... आप जानते हैं, कुछ भी 
यह सुनिश्चित नहीं है कि यह सुन सकता है, लेकिन यह दिखाने के लिए धन्यवाद कि यह कैसे बोल सकता है, –
ऊपर उल्लिखित नोट करें कि उन दोनों को अलग-अलग समस्याएं छोड़ दी गई हैं। – Joey