mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-12 09:40:45 +01:00
Updated speak-checklist.ps1
This commit is contained in:
parent
c70b993747
commit
de90e60b2e
7
data/checklists/handwashing.md
Normal file
7
data/checklists/handwashing.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
The Handwashing Checklist
|
||||||
|
=========================
|
||||||
|
- [ ] Wet your hands with clean, running water (warm or cold), turn off the tap, and apply soap.
|
||||||
|
- [ ] Lather your hands by rubbing them together with the soap. Lather the backs of your hands, between your fingers, and under your nails.
|
||||||
|
- [ ] Scrub your hands for at least 20 seconds.
|
||||||
|
- [ ] Rinse your hands well under clean, running water.
|
||||||
|
- [ ] Dry your hands using a clean towel or air dry them.
|
@ -1,6 +0,0 @@
|
|||||||
HEAD Handwashing
|
|
||||||
Wet your hands with clean, running water (warm or cold), turn off the tap, and apply soap.
|
|
||||||
Lather your hands by rubbing them together with the soap. Lather the backs of your hands, between your fingers, and under your nails.
|
|
||||||
Scrub your hands for at least 20 seconds.
|
|
||||||
Rinse your hands well under clean, running water.
|
|
||||||
Dry your hands using a clean towel or air dry them.
|
|
@ -2,11 +2,11 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Speaks a checklist by text-to-speech
|
Speaks a checklist by text-to-speech
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script speaks the given checklist by text-to-speech (TTS).
|
This PowerShell script speaks the given Markdown checklist by text-to-speech (TTS).
|
||||||
.PARAMETER name
|
.PARAMETER name
|
||||||
Specifies the name of the checklist
|
Specifies the name of the checklist
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./speak-checklist.ps1 handwashing
|
PS> ./speak-checklist.judge yiips1 handwashing
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -16,34 +16,36 @@
|
|||||||
param([string]$name = "handwashing")
|
param([string]$name = "handwashing")
|
||||||
|
|
||||||
function WaitForCheck {
|
function WaitForCheck {
|
||||||
Add-Type -AssemblyName System.Speech
|
|
||||||
$engine = New-Object -typeName System.Speech.Recognition.SpeechRecognitionEngine
|
$engine = New-Object -typeName System.Speech.Recognition.SpeechRecognitionEngine
|
||||||
$grammar = New-Object -typeName System.Speech.Recognition.GrammarBuilder
|
$grammar = New-Object -typeName System.Speech.Recognition.GrammarBuilder
|
||||||
$grammar.Append("check");
|
$grammar.Append("check");
|
||||||
$engine.LoadGrammar($grammar);
|
$engine.LoadGrammar($grammar);
|
||||||
$engine.InitialSilenceTimeout = 5
|
|
||||||
$engine.SetInputToDefaultAudioDevice();
|
$engine.SetInputToDefaultAudioDevice();
|
||||||
do {
|
do { $got = $engine.Recognize() } while ("$($got.text)" -ne "check")
|
||||||
$recognized = $engine.Recognize();
|
|
||||||
} while ("$($recognized.text)" -ne "check")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Add-Type -AssemblyName System.Speech
|
||||||
if ($name -eq "") { $name = Read-Host "Enter the name of the checklist" }
|
if ($name -eq "") { $name = Read-Host "Enter the name of the checklist" }
|
||||||
|
|
||||||
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
Clear-Host
|
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 }
|
|
||||||
""
|
|
||||||
Write-Host "$($step). $line" -foregroundColor yellow
|
|
||||||
& "$PSScriptRoot/speak-english.ps1" $line
|
|
||||||
Write-Host " Say <CHECK> to continue..."
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
$lines = Get-Content -path "$PSScriptRoot/../data/checklists/$name.md"
|
||||||
|
$headline = ""
|
||||||
|
foreach($line in $lines) {
|
||||||
|
if ($line -match "- \[ \].*") {
|
||||||
|
Write-Host "`n✅ $($line.Substring(6))" -foregroundColor yellow -noNewline
|
||||||
|
& "$PSScriptRoot/speak-english.ps1" $($line.Substring(6))
|
||||||
|
Write-Host " Say 'CHECK'..."
|
||||||
WaitForCheck
|
WaitForCheck
|
||||||
$step++
|
} else {
|
||||||
|
Write-Host $line
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||||
|
Write-Host "`n✅ Checklist completed in $($elapsed)s."
|
||||||
|
& "$PSScriptRoot/speak-english.ps1" "You're done."
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user