PowerShell/scripts/tell-quote.ps1

27 lines
706 B
PowerShell
Raw Normal View History

2023-10-31 13:03:45 +01:00
<#
.SYNOPSIS
Tells a random quote by text-to-speech
2021-10-04 21:29:23 +02:00
.DESCRIPTION
2023-08-09 17:18:53 +02:00
This PowerShell script selects a random quote from Data/quotes.csv and speaks it by text-to-speech (TTS).
.EXAMPLE
2023-08-09 17:18:53 +02:00
PS> ./tell-quote.ps1
(listen and enjoy)
.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
#>
try {
2023-10-31 11:25:11 +01:00
$table = Import-CSV "$PSScriptRoot/../data/quotes.csv"
2023-08-09 17:18:53 +02:00
$randomNumberGenerator = New-Object System.Random
$row = [int]$randomNumberGenerator.next(0, $table.Count - 1)
2023-08-10 11:35:46 +02:00
& "$PSScriptRoot/speak-english.ps1" "$($table[$row].QUOTE). By $($table[$row].AUTHOR)."
2021-09-27 10:09:45 +02:00
exit 0 # success
} catch {
2022-04-13 12:06:32 +02:00
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}