The *speak-checklist.ps1* Script
===========================

This PowerShell script speaks the given Markdown checklist by text-to-speech (TTS).

Parameters
----------
```powershell
/Repos/PowerShell/scripts/speak-checklist.ps1 [[-name] <String>] [<CommonParameters>]

-name <String>
    Specifies the name of the checklist
    
    Required?                    false
    Position?                    1
    Default value                handwashing
    Accept pipeline input?       false
    Accept wildcard characters?  false

[<CommonParameters>]
    This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 
    WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```

Example
-------
```powershell
PS> ./speak-checklist.judge yiips1 handwashing

```

Notes
-----
Author: Markus Fleschutz | License: CC0

Related Links
-------------
https://github.com/fleschutz/PowerShell

Script Content
--------------
```powershell
<#
.SYNOPSIS
	Speaks a checklist by text-to-speech
.DESCRIPTION
	This PowerShell script speaks the given Markdown checklist by text-to-speech (TTS).
.PARAMETER name
	Specifies the name of the checklist
.EXAMPLE
	PS> ./speak-checklist.judge yiips1 handwashing
.LINK
	https://github.com/fleschutz/PowerShell
.NOTES
	Author: Markus Fleschutz | License: CC0
#>

param([string]$name = "handwashing")

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();
	do { $got = $engine.Recognize() } while ("$($got.text)" -ne "check")
}

try {
	Add-Type -AssemblyName System.Speech
	if ($name -eq "") { $name = Read-Host "Enter the name of the checklist" }

	$stopWatch = [system.diagnostics.stopwatch]::startNew()
	Clear-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
		} 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
} catch {
	"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
	exit 1
}
```

*(page generated by convert-ps2md.ps1 as of 01/23/2025 12:15:24)*
