diff --git a/Scripts/bye-bye.ps1 b/Scripts/bye-bye.ps1 index e489406c..54225f34 100644 --- a/Scripts/bye-bye.ps1 +++ b/Scripts/bye-bye.ps1 @@ -13,6 +13,6 @@ $Answer = "Good bye.", "See you.", "Bye bye." | Get-Random -write-output "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer" +write-output "$Answer" exit 0 # success diff --git a/Scripts/good-bye.ps1 b/Scripts/good-bye.ps1 index df714cb1..6506b045 100644 --- a/Scripts/good-bye.ps1 +++ b/Scripts/good-bye.ps1 @@ -13,6 +13,6 @@ $Answer = "Good bye.", "See you.", "Bye bye." | Get-Random -write-output "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer" +write-output "$Answer" exit 0 # success diff --git a/Scripts/good-evening.ps1 b/Scripts/good-evening.ps1 index 00c99ce5..12d90520 100644 --- a/Scripts/good-evening.ps1 +++ b/Scripts/good-evening.ps1 @@ -13,6 +13,6 @@ $Answer = "And a special good evening to you too." -write-output "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer" +write-output "$Answer" exit 0 # success diff --git a/Scripts/good-morning.ps1 b/Scripts/good-morning.ps1 index a992f734..6d8b08ae 100755 --- a/Scripts/good-morning.ps1 +++ b/Scripts/good-morning.ps1 @@ -13,6 +13,6 @@ $Answer = "Good morning.", "Good morning to you too.", "Well, good morning to you too.", "Good morning! How are you?", "Morning." | Get-Random -write-output "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer" +write-output "$Answer" exit 0 # success diff --git a/Scripts/good-night.ps1 b/Scripts/good-night.ps1 index 41f3524c..73b555ae 100644 --- a/Scripts/good-night.ps1 +++ b/Scripts/good-night.ps1 @@ -13,6 +13,6 @@ $Answer = "Good night to you, too.", "Good night to you, my friend.", "Have a good night. Sleep well.", "Good night and sweet dreams." | Get-Random -write-output "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer" +write-output "$Answer" exit 0 # success diff --git a/Scripts/how-are-you.ps1 b/Scripts/how-are-you.ps1 index 0e439b69..fd6b4a86 100755 --- a/Scripts/how-are-you.ps1 +++ b/Scripts/how-are-you.ps1 @@ -11,10 +11,8 @@ https://github.com/fleschutz/PowerShell #> -try { - & "$PSScriptRoot/speak-english.ps1" "I'm fine, thanks." - exit 0 # success -} catch { - "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" - exit 1 -} +$Answer = "I'm fine, thanks." + +& "$PSScriptRoot/speak-english.ps1" "$Answer" +write-output "$Answer" +exit 0 # success diff --git a/Scripts/i-will-be-back.ps1 b/Scripts/i-will-be-back.ps1 index 2c86ad81..10cc9c4c 100755 --- a/Scripts/i-will-be-back.ps1 +++ b/Scripts/i-will-be-back.ps1 @@ -11,5 +11,8 @@ https://github.com/fleschutz/PowerShell #> -& "$PSScriptRoot/speak-english.ps1" "Hasta la vista, baby." +$Answer = "Hasta la vista, baby." + +& "$PSScriptRoot/speak-english.ps1" "$Answer" +write-output "$Answer" exit 0 # success diff --git a/Scripts/say-date.ps1 b/Scripts/say-date.ps1 index 35313247..cf99e401 100755 --- a/Scripts/say-date.ps1 +++ b/Scripts/say-date.ps1 @@ -16,7 +16,9 @@ try { [system.threading.thread]::currentthread.currentculture=[system.globalization.cultureinfo]"en-US" $Weekday = (Get-Date -format "dddd") $CurrentDate = (Get-Date).ToShortDateString() - & "$PSScriptRoot/speak-english.ps1" "It's $Weekday, $CurrentDate" + $Answer = "It's $Weekday, $CurrentDate" + & "$PSScriptRoot/speak-english.ps1" "$Answer" + write-output "$Answer" exit 0 # success } catch { "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" diff --git a/Scripts/say-time.ps1 b/Scripts/say-time.ps1 index d2dd699f..1f643a87 100755 --- a/Scripts/say-time.ps1 +++ b/Scripts/say-time.ps1 @@ -15,7 +15,9 @@ try { [system.threading.thread]::currentThread.currentCulture=[system.globalization.cultureInfo]"en-US" $CurrentTime = $((Get-Date).ToShortTimeString()) - & "$PSScriptRoot/speak-english.ps1" "It's $CurrentTime" + $Answer = "It's $CurrentTime" + & "$PSScriptRoot/speak-english.ps1" "$Answer" + write-output "$Answer" exit 0 # success } catch { "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" diff --git a/Scripts/speak-english.ps1 b/Scripts/speak-english.ps1 index 4f269e66..c6b15e47 100755 --- a/Scripts/speak-english.ps1 +++ b/Scripts/speak-english.ps1 @@ -3,7 +3,6 @@ Speaks text with an English text-to-speech voice .DESCRIPTION This scripts speaks the given text with an English text-to-speech (TTS) voice. - Requires that an English TTS voice is installed. .PARAMETER text Specifies the text to speak .EXAMPLE @@ -19,12 +18,11 @@ param([string]$text = "") try { if ("$text" -eq "") { $text = read-host "Enter the English text to speak" } - $CurrentVoice = New-Object -ComObject SAPI.SPVoice - $Voices = $CurrentVoice.GetVoices() - foreach ($Voice in $Voices) { + $TTSVoice = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTSVoice.GetVoices()) { if ($Voice.GetDescription() -notlike "*- English*") { continue } - $CurrentVoice.Voice = $Voice - [void]$CurrentVoice.Speak($text) + $TTSVoice.Voice = $Voice + [void]$TTSVoice.Speak($text) exit 0 # success } throw "No English text-to-speech voice found - please install one" diff --git a/Scripts/tell-joke.ps1 b/Scripts/tell-joke.ps1 index 4bddfb18..8020fd76 100755 --- a/Scripts/tell-joke.ps1 +++ b/Scripts/tell-joke.ps1 @@ -16,9 +16,10 @@ try { $Generator = New-Object System.Random $Index = [int]$Generator.next(0, $Table.Count - 1) - $Joke = $Table[$Index].Joke + $Answer = $Table[$Index].Joke - & "$PSScriptRoot/speak-english.ps1" "$Joke" + & "$PSScriptRoot/speak-english.ps1" "$Answer" + write-output "$Answer" exit 0 # success } catch { "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" diff --git a/Scripts/tell-operating-system.ps1 b/Scripts/tell-operating-system.ps1 index 21ec7a4c..ae8e6398 100755 --- a/Scripts/tell-operating-system.ps1 +++ b/Scripts/tell-operating-system.ps1 @@ -13,15 +13,16 @@ try { if ($IsLinux) { - $details = (uname -sr) + $Answer = (uname -sr) } else { $OS = Get-WmiObject -class Win32_OperatingSystem $OSname = $OS.Caption $OSarchitecture = $OS.OSArchitecture $OSversion = $OS.Version - $details = "$OSname for $OSarchitecture version $OSversion" + $Answer = "$OSname for $OSarchitecture version $OSversion" } - & "$PSScriptRoot/speak-english.ps1" "$details" + & "$PSScriptRoot/speak-english.ps1" "$Answer" + write-output "$Answer" exit 0 # success } catch { "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" diff --git a/Scripts/tell-quote.ps1 b/Scripts/tell-quote.ps1 index da674f48..4b873bc1 100755 --- a/Scripts/tell-quote.ps1 +++ b/Scripts/tell-quote.ps1 @@ -18,8 +18,10 @@ try { $Index = [int]$Generator.next(0, $Table.Count - 1) $Quote = $Table[$Index].Quote $Author = $Table[$Index].Author + $Answer = "$Quote (by $Author)" - & "$PSScriptRoot/speak-english.ps1" "$Quote (by $Author)" + & "$PSScriptRoot/speak-english.ps1" "$Answer" + write-output "$Answer" exit 0 # success } catch { "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" diff --git a/Scripts/tell-uptime.ps1 b/Scripts/tell-uptime.ps1 index 9cc767b0..e8c4f82f 100755 --- a/Scripts/tell-uptime.ps1 +++ b/Scripts/tell-uptime.ps1 @@ -22,8 +22,8 @@ try { $Answer = "I'm up for $($Uptime.Days) days, $($Uptime.Hours) hours and $($Uptime.Minutes) minutes." - write-output "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer" + write-output "$Answer" exit 0 # success } catch { "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" diff --git a/Scripts/thank-you.ps1 b/Scripts/thank-you.ps1 index 59c1520a..73988d10 100755 --- a/Scripts/thank-you.ps1 +++ b/Scripts/thank-you.ps1 @@ -13,6 +13,6 @@ $Answer = "It's a pleasure.", "Never mind." | Get-Random -write-output "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer" +write-output "$Answer" exit 0 # success