PowerShell/docs/speak-checklist.md

99 lines
2.6 KiB
Markdown
Raw Normal View History

2024-11-08 12:38:20 +01:00
The *speak-checklist.ps1* Script
===========================
2021-11-08 21:36:42 +01:00
2025-01-17 08:31:53 +01:00
This PowerShell script speaks the given Markdown checklist by text-to-speech (TTS).
2021-11-08 21:36:42 +01:00
2023-07-29 10:04:38 +02:00
Parameters
----------
2021-11-08 21:36:42 +01:00
```powershell
2025-01-17 08:31:53 +01:00
/Repos/PowerShell/scripts/speak-checklist.ps1 [[-name] <String>] [<CommonParameters>]
2021-11-08 21:36:42 +01:00
2025-01-17 08:31:53 +01:00
-name <String>
2021-11-08 21:36:42 +01:00
Specifies the name of the checklist
Required? false
Position? 1
2025-01-17 08:31:53 +01:00
Default value handwashing
2021-11-08 21:36:42 +01:00
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.
```
2023-07-29 10:04:38 +02:00
Example
-------
2021-11-08 21:36:42 +01:00
```powershell
2025-01-17 08:31:53 +01:00
PS> ./speak-checklist.judge yiips1 handwashing
2021-11-08 21:36:42 +01:00
```
2023-07-29 10:04:38 +02:00
Notes
-----
2022-11-17 19:46:02 +01:00
Author: Markus Fleschutz | License: CC0
2021-11-08 21:36:42 +01:00
2023-07-29 10:04:38 +02:00
Related Links
-------------
2021-11-08 21:36:42 +01:00
https://github.com/fleschutz/PowerShell
2023-07-29 10:04:38 +02:00
Script Content
--------------
2022-11-17 20:05:34 +01:00
```powershell
2022-11-17 20:02:26 +01:00
<#
.SYNOPSIS
Speaks a checklist by text-to-speech
.DESCRIPTION
2025-01-17 08:31:53 +01:00
This PowerShell script speaks the given Markdown checklist by text-to-speech (TTS).
.PARAMETER name
2022-11-17 20:02:26 +01:00
Specifies the name of the checklist
.EXAMPLE
2025-01-17 08:31:53 +01:00
PS> ./speak-checklist.judge yiips1 handwashing
2022-11-17 20:02:26 +01:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
2025-01-17 08:31:53 +01:00
param([string]$name = "handwashing")
2022-11-17 20:02:26 +01:00
2025-01-17 08:31:53 +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();
do { $got = $engine.Recognize() } while ("$($got.text)" -ne "check")
}
2022-11-17 20:02:26 +01:00
2025-01-17 08:31:53 +01:00
try {
Add-Type -AssemblyName System.Speech
if ($name -eq "") { $name = Read-Host "Enter the name of the checklist" }
2022-11-17 20:02:26 +01:00
2025-01-17 08:31:53 +01:00
$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
}
2022-11-17 20:02:26 +01:00
}
2025-01-17 08:31:53 +01:00
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
Write-Host "`n✅ Checklist completed in $($elapsed)s."
& "$PSScriptRoot/speak-english.ps1" "You're done."
2022-11-17 20:02:26 +01:00
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
2022-11-17 20:05:34 +01:00
```
2022-11-17 20:02:26 +01:00
2025-01-17 08:37:30 +01:00
*(page generated by convert-ps2md.ps1 as of 01/17/2025 08:37:12)*