Update give-reply.ps1 and repeat-last-reply.ps1

This commit is contained in:
Markus Fleschutz 2021-12-09 09:42:54 +01:00
parent dedaad01bf
commit f5edb4f370
2 changed files with 8 additions and 9 deletions

View File

@ -20,17 +20,16 @@ try {
"$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
[void]$TTSVoice.Speak($text)
break
if ($Voice.GetDescription() -like "*- English*") { $TTSVoice.Voice = $Voice }
}
[void]$TTSVoice.Speak($text)
}
# remember last reply:
"$text" > "$HOME/.last_reply.txt"
"$text" > "$env:TEMP/last_reply.txt"
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -11,9 +11,9 @@
https://github.com/fleschutz/PowerShell
#>
if (test-path "$HOME/.last_reply.txt" -pathType leaf) {
if (test-path "$env:TEMP/last_reply.txt" -pathType leaf) {
$Reply = "It was: "
$Reply += Get-Content "$HOME/.last_reply.txt"
$Reply += Get-Content "$env:TEMP/.last_reply.txt"
} else {
$Reply = "Sorry, I can't remember."
}