mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-01 03:36:28 +02:00
Improved voice-control.ps1
This commit is contained in:
parent
1be2c719e6
commit
0609414148
@ -9,10 +9,12 @@
|
|||||||
[double]$MinConfidence = 0.05
|
[double]$MinConfidence = 0.05
|
||||||
$PathToRepo = "$PSScriptRoot/.."
|
$PathToRepo = "$PSScriptRoot/.."
|
||||||
|
|
||||||
|
try {
|
||||||
write-output "Initializing the speech recognition engine..."
|
write-output "Initializing the speech recognition engine..."
|
||||||
$speechRecogEng = [System.Speech.Recognition.SpeechRecognitionEngine]::new();
|
$null = [Reflection.Assembly]::LoadWithPartialName("System.Speech")
|
||||||
|
$speechRecogEng = [System.Speech.Recognition.SpeechRecognitionEngine]::new()
|
||||||
#$speechRecogEng.InitialSilenceTimeout = 15
|
#$speechRecogEng.InitialSilenceTimeout = 15
|
||||||
$speechRecogEng.SetInputToDefaultAudioDevice();
|
$speechRecogEng.SetInputToDefaultAudioDevice()
|
||||||
|
|
||||||
write-output "Loading the grammar..."
|
write-output "Loading the grammar..."
|
||||||
$Items = get-childItem -path "$PathToRepo/Scripts/"
|
$Items = get-childItem -path "$PathToRepo/Scripts/"
|
||||||
@ -26,9 +28,9 @@ foreach ($Item in $Items) {
|
|||||||
$Count++
|
$Count++
|
||||||
}
|
}
|
||||||
|
|
||||||
$grammar2 = [System.Speech.Recognition.GrammarBuilder]::new();
|
$grammar2 = [System.Speech.Recognition.GrammarBuilder]::new()
|
||||||
$grammar2.Append("exit");
|
$grammar2.Append("exit")
|
||||||
$speechRecogEng.LoadGrammar($grammar2);
|
$speechRecogEng.LoadGrammar($grammar2)
|
||||||
|
|
||||||
write-output "Got $Count voice commands, listening now..."
|
write-output "Got $Count voice commands, listening now..."
|
||||||
$done = $false
|
$done = $false
|
||||||
@ -48,5 +50,8 @@ do {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
} until ($done)
|
} until ($done)
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
} catch {
|
||||||
|
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user