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