Added close-calculator.ps1

This commit is contained in:
Markus Fleschutz
2021-01-09 15:59:37 +01:00
parent e0d576d662
commit 891548f6b4
4 changed files with 15 additions and 2 deletions

View File

@ -11,7 +11,7 @@ $PathToRepo = "$PSScriptRoot/.."
try {
write-output "Init speech recognition engine..."
$null = [Reflection.Assembly]::LoadWithPartialName("System.Speech")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Speech")
$speechRecogEng = [System.Speech.Recognition.SpeechRecognitionEngine]::new()
#$speechRecogEng.InitialSilenceTimeout = 15
$speechRecogEng.SetInputToDefaultAudioDevice()
@ -33,6 +33,8 @@ try {
$grammar2.Append("exit")
$speechRecogEng.LoadGrammar($grammar2)
write-output "NOTE: make sure the microphone volume is not too silent or too loud!"
write-output "Listening now ($Count voice commands)..."
while ($true) {
$recognized = $speechRecogEng.Recognize()