From e40628bad2645e13998d110de11fcb1a5f0a002d Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sat, 5 Nov 2022 16:29:55 +0100 Subject: [PATCH] Update give-reply.ps1 and tell-joke.ps1 --- Scripts/give-reply.ps1 | 21 ++++++++------------- Scripts/tell-joke.ps1 | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Scripts/give-reply.ps1 b/Scripts/give-reply.ps1 index 11866213..187d2769 100755 --- a/Scripts/give-reply.ps1 +++ b/Scripts/give-reply.ps1 @@ -23,22 +23,17 @@ function GetTempDir { } try { - # print reply on the console: - " ← $text" - - # speak by text-to-speech (TTS): - if (!$IsLinux) { - $TTSVoice = New-Object -ComObject SAPI.SPVoice - foreach ($Voice in $TTSVoice.GetVoices()) { - if ($Voice.GetDescription() -like "*- English*") { $TTSVoice.Voice = $Voice } + Write-Host '“'$text' ”' # to write the reply on the console + if (!$IsLinux) { + $TTS = New-Object -ComObject SAPI.SPVoice + foreach($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- English*") { $TTS.Voice = $Voice } } - [void]$TTSVoice.Speak($text) + [void]$TTS.Speak($text) } - - # remember last reply: - "$text" > "$(GetTempDir)/last_reply_given.txt" + "$text" > "$(GetTempDir)/last_reply_given.txt" # to remember last reply exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" exit 1 -} +} \ No newline at end of file diff --git a/Scripts/tell-joke.ps1 b/Scripts/tell-joke.ps1 index 49efbde8..356a3238 100755 --- a/Scripts/tell-joke.ps1 +++ b/Scripts/tell-joke.ps1 @@ -23,4 +23,4 @@ try { } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" exit 1 -} +} \ No newline at end of file