mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-11 17:20:48 +01:00
Updated speak-checklist.ps1
This commit is contained in:
parent
db0169521b
commit
e74c9f1010
@ -3,31 +3,46 @@
|
||||
Speaks a checklist by text-to-speech
|
||||
.DESCRIPTION
|
||||
This PowerShell script speaks the given checklist by text-to-speech (TTS).
|
||||
.PARAMETER Name
|
||||
.PARAMETER name
|
||||
Specifies the name of the checklist
|
||||
.EXAMPLE
|
||||
PS> ./speak-checklist.ps1
|
||||
PS> ./speak-checklist.ps1 handwashing
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$Name = "")
|
||||
param([string]$name = "handwashing")
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
try {
|
||||
if ($Name -eq "") { $Name = Read-Host "Enter the name of the checklist" }
|
||||
|
||||
$Lines = Get-Content -path "$PSScriptRoot/../data/checklists/$Name.txt"
|
||||
clear-host
|
||||
$Step = 1
|
||||
foreach($Line in $Lines) {
|
||||
if ($Line -like "HEAD*") { & "$PSScriptRoot/write-big.ps1" "$($Line.substring(5))"; continue }
|
||||
if ($name -eq "") { $name = Read-Host "Enter the name of the checklist" }
|
||||
|
||||
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 }
|
||||
""
|
||||
& "$PSScriptRoot/speak-english.ps1" "$($Step). $Line"
|
||||
$Dummy = Read-Host " Say <Check> or press <Return> to continue"
|
||||
$Step++
|
||||
Write-Host "$($step). $line" -foregroundColor yellow
|
||||
& "$PSScriptRoot/speak-english.ps1" $line
|
||||
Write-Host " Say <CHECK> to continue..."
|
||||
Write-Host ""
|
||||
WaitForCheck
|
||||
$step++
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
Loading…
Reference in New Issue
Block a user