PowerShell/scripts/spell-word.ps1

33 lines
681 B
PowerShell
Raw Normal View History

2024-10-01 13:37:53 +02:00
<#
2021-10-27 13:13:36 +02:00
.SYNOPSIS
2021-12-11 12:32:03 +01:00
Spells a word
2021-10-27 13:13:36 +02:00
.DESCRIPTION
2022-01-30 10:49:30 +01:00
This PowerShell script spells the given word by text-to-speech (TTS).
2021-12-11 15:49:59 +01:00
.PARAMETER word
Specifies the word to spell
2021-10-27 13:13:36 +02:00
.EXAMPLE
2021-12-11 12:32:03 +01:00
PS> ./spell-word
2021-10-27 13:13:36 +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-10-27 13:13:36 +02:00
#>
2021-12-11 15:49:59 +01:00
param([string]$word = "")
2021-12-11 12:32:03 +01:00
2021-12-11 15:49:59 +01:00
try {
if ($word -eq "" ) { $word = read-host "Enter word to spell" }
[char[]]$ArrayOfChars = $word.ToUpper()
$Reply = ""
foreach($Char in $ArrayOfChars) {
$Reply += $Char
$Reply += " "
}
2022-11-18 16:49:17 +01:00
& "$PSScriptRoot/speak-english.ps1" "$Reply"
2021-12-11 15:49:59 +01:00
exit 0 # success
} catch {
2022-04-13 12:06:32 +02:00
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2021-12-11 15:49:59 +01:00
exit 1
2022-01-30 10:49:30 +01:00
}