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
|
2024-11-27 16:08:58 +01:00
|
|
|
|
This PowerShell script speaks the given Markdown 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-27 16:08:58 +01:00
|
|
|
|
PS> ./speak-checklist.judge yiips1 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 {
|
|
|
|
|
$engine = New-Object -typeName System.Speech.Recognition.SpeechRecognitionEngine
|
|
|
|
|
$grammar = New-Object -typeName System.Speech.Recognition.GrammarBuilder
|
|
|
|
|
$grammar.Append("check");
|
|
|
|
|
$engine.LoadGrammar($grammar);
|
|
|
|
|
$engine.SetInputToDefaultAudioDevice();
|
2024-11-27 16:08:58 +01:00
|
|
|
|
do { $got = $engine.Recognize() } while ("$($got.text)" -ne "check")
|
2024-11-24 21:00:34 +01:00
|
|
|
|
}
|
2021-07-15 15:51:22 +02:00
|
|
|
|
|
2024-11-24 21:00:34 +01:00
|
|
|
|
try {
|
2024-11-27 16:08:58 +01:00
|
|
|
|
Add-Type -AssemblyName System.Speech
|
2024-11-24 21:00:34 +01:00
|
|
|
|
if ($name -eq "") { $name = Read-Host "Enter the name of the checklist" }
|
2021-05-22 15:34:47 +02:00
|
|
|
|
|
2024-11-27 16:08:58 +01:00
|
|
|
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
2024-11-24 21:00:34 +01:00
|
|
|
|
Clear-Host
|
2024-11-27 16:08:58 +01:00
|
|
|
|
Write-Host ""
|
|
|
|
|
$lines = Get-Content -path "$PSScriptRoot/../data/checklists/$name.md"
|
|
|
|
|
$headline = ""
|
2024-11-24 21:00:34 +01:00
|
|
|
|
foreach($line in $lines) {
|
2024-11-27 16:08:58 +01:00
|
|
|
|
if ($line -match "- \[ \].*") {
|
|
|
|
|
Write-Host "`n✅ $($line.Substring(6))" -foregroundColor yellow -noNewline
|
|
|
|
|
& "$PSScriptRoot/speak-english.ps1" $($line.Substring(6))
|
|
|
|
|
Write-Host " Say 'CHECK'..."
|
|
|
|
|
WaitForCheck
|
|
|
|
|
} else {
|
|
|
|
|
Write-Host $line
|
|
|
|
|
}
|
2021-05-22 15:11:15 +02:00
|
|
|
|
}
|
2024-11-27 16:08:58 +01:00
|
|
|
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
|
|
|
|
Write-Host "`n✅ Checklist completed in $($elapsed)s."
|
|
|
|
|
& "$PSScriptRoot/speak-english.ps1" "You're done."
|
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
|
|
|
|
|
}
|