mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-08 20:54:38 +02:00
Added close-calculator.ps1
This commit is contained in:
9
Scripts/close-calculator.ps1
Normal file
9
Scripts/close-calculator.ps1
Normal file
@ -0,0 +1,9 @@
|
||||
#!/snap/bin/powershell
|
||||
<#
|
||||
.SYNTAX ./close-calculator.ps1
|
||||
.DESCRIPTION closes the calculator program gracefully
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
./close-program "calc" "Calculator"
|
@ -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()
|
||||
|
Reference in New Issue
Block a user