mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-16 19:50:45 +01:00
28 lines
688 B
PowerShell
Executable File
28 lines
688 B
PowerShell
Executable File
<#
|
|
.SYNOPSIS
|
|
Tells a joke by text-to-speech
|
|
.DESCRIPTION
|
|
This script selects a random Chuck Norris joke in Data/jokes.csv and speaks it by text-to-speech (TTS).
|
|
.EXAMPLE
|
|
PS> ./tell-joke
|
|
.NOTES
|
|
Author: Markus Fleschutz · License: CC0
|
|
.LINK
|
|
https://github.com/fleschutz/PowerShell
|
|
#>
|
|
|
|
try {
|
|
$Table = import-csv "$PSScriptRoot/../Data/jokes.csv"
|
|
|
|
$Generator = New-Object System.Random
|
|
$Index = [int]$Generator.next(0, $Table.Count - 1)
|
|
$Answer = $Table[$Index].Joke
|
|
|
|
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
|
write-output "$Answer"
|
|
exit 0 # success
|
|
} catch {
|
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
|
exit 1
|
|
}
|