mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-30 20:03:36 +01:00
28 lines
686 B
PowerShell
Executable File
28 lines
686 B
PowerShell
Executable File
<#
|
|
.SYNOPSIS
|
|
Say a random Chuck Norris joke by text-to-speech
|
|
.DESCRIPTION
|
|
This script selects a random joke in Data/jokes.csv and tells it by text-to-speech (TTS).
|
|
.EXAMPLE
|
|
PS> ./say-joke
|
|
(listen and have fun)
|
|
.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)
|
|
$Joke = $Table[$Index].Joke
|
|
|
|
& "$PSScriptRoot/speak-english.ps1" "$Joke"
|
|
exit 0 # success
|
|
} catch {
|
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
|
exit 1
|
|
}
|