2024-10-01 15:24:16 +02:00
|
|
|
|
<#
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.SYNOPSIS
|
2021-10-16 16:50:10 +02:00
|
|
|
|
Speaks a checklist by text-to-speech
|
2021-10-04 21:29:23 +02:00
|
|
|
|
.DESCRIPTION
|
2022-01-30 10:49:30 +01:00
|
|
|
|
This PowerShell script speaks the given checklist by text-to-speech (TTS).
|
2024-11-24 21:00:34 +01:00
|
|
|
|
.PARAMETER name
|
2021-10-16 16:50:10 +02:00
|
|
|
|
Specifies the name of the checklist
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.EXAMPLE
|
2024-11-24 21:00:34 +01:00
|
|
|
|
PS> ./speak-checklist.ps1 handwashing
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
2022-01-30 10:49:30 +01:00
|
|
|
|
.NOTES
|
2022-09-06 21:42:04 +02:00
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
2021-05-22 15:11:15 +02:00
|
|
|
|
#>
|
|
|
|
|
|
2024-11-24 21:00:34 +01:00
|
|
|
|
param([string]$name = "handwashing")
|
2021-05-22 15:11:15 +02:00
|
|
|
|
|
2024-11-24 21:00:34 +01:00
|
|
|
|
function WaitForCheck {
|
|
|
|
|
Add-Type -AssemblyName System.Speech
|
|
|
|
|
$engine = New-Object -typeName System.Speech.Recognition.SpeechRecognitionEngine
|
|
|
|
|
$grammar = New-Object -typeName System.Speech.Recognition.GrammarBuilder
|
|
|
|
|
$grammar.Append("check");
|
|
|
|
|
$engine.LoadGrammar($grammar);
|
|
|
|
|
$engine.InitialSilenceTimeout = 5
|
|
|
|
|
$engine.SetInputToDefaultAudioDevice();
|
|
|
|
|
do {
|
|
|
|
|
$recognized = $engine.Recognize();
|
|
|
|
|
} while ("$($recognized.text)" -ne "check")
|
|
|
|
|
}
|
2021-07-15 15:51:22 +02:00
|
|
|
|
|
2024-11-24 21:00:34 +01:00
|
|
|
|
try {
|
|
|
|
|
if ($name -eq "") { $name = Read-Host "Enter the name of the checklist" }
|
2021-05-22 15:34:47 +02:00
|
|
|
|
|
2024-11-24 21:00:34 +01:00
|
|
|
|
Clear-Host
|
|
|
|
|
$lines = Get-Content -path "$PSScriptRoot/../data/checklists/$name.txt"
|
|
|
|
|
$step = 1
|
|
|
|
|
foreach($line in $lines) {
|
|
|
|
|
if ($line -like "HEAD*") { & "$PSScriptRoot/write-big.ps1" "$($line.substring(5))"; continue }
|
2021-05-22 15:34:47 +02:00
|
|
|
|
""
|
2024-11-24 21:00:34 +01:00
|
|
|
|
Write-Host "$($step). $line" -foregroundColor yellow
|
|
|
|
|
& "$PSScriptRoot/speak-english.ps1" $line
|
|
|
|
|
Write-Host " Say <CHECK> to continue..."
|
|
|
|
|
Write-Host ""
|
|
|
|
|
WaitForCheck
|
|
|
|
|
$step++
|
2021-05-22 15:11:15 +02:00
|
|
|
|
}
|
2021-09-27 10:09:45 +02:00
|
|
|
|
exit 0 # success
|
2021-05-22 15:11:15 +02:00
|
|
|
|
} catch {
|
2022-04-13 12:06:32 +02:00
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2021-05-22 15:11:15 +02:00
|
|
|
|
exit 1
|
|
|
|
|
}
|