mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-15 20:44:17 +01:00
28 lines
695 B
PowerShell
Executable File
28 lines
695 B
PowerShell
Executable File
<#
|
|
.SYNOPSIS
|
|
Speaks a random Chuck Norris joke by text-to-speech
|
|
.DESCRIPTION
|
|
This script selects a random joke in Data/jokes.csv and uses text-to-speech (TTS) for output.
|
|
.EXAMPLE
|
|
PS> ./speak-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
|
|
}
|