mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-28 16:48:39 +01:00
Update give-reply.ps1 and tell-joke.ps1
This commit is contained in:
parent
3ccce3044a
commit
e40628bad2
@ -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
|
||||
}
|
||||
}
|
@ -23,4 +23,4 @@ try {
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user