mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 05:04:39 +02:00
Add give-reply.ps1
This commit is contained in:
33
Scripts/give-reply.ps1
Normal file
33
Scripts/give-reply.ps1
Normal file
@ -0,0 +1,33 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gives a reply
|
||||
.DESCRIPTION
|
||||
This script gives a reply in English by text-to-speech (TTS).
|
||||
.PARAMETER text
|
||||
Specifies the text to speak
|
||||
.EXAMPLE
|
||||
PS> ./give-reply "Hello World"
|
||||
.NOTES
|
||||
Author: Markus Fleschutz · License: CC0
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
#>
|
||||
|
||||
param([string]$text = "")
|
||||
|
||||
try {
|
||||
"📣$text"
|
||||
|
||||
$TTSVoice = New-Object -ComObject SAPI.SPVoice
|
||||
foreach ($Voice in $TTSVoice.GetVoices()) {
|
||||
if ($Voice.GetDescription() -like "*- English*") {
|
||||
$TTSVoice.Voice = $Voice
|
||||
[void]$TTSVoice.Speak($text)
|
||||
exit 0 # success
|
||||
}
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
}
|
20
Scripts/say-hello.ps1
Normal file
20
Scripts/say-hello.ps1
Normal file
@ -0,0 +1,20 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Replies to "Say hello"
|
||||
.DESCRIPTION
|
||||
This script replies to "Say hello" by text-to-speech (TTS).
|
||||
.EXAMPLE
|
||||
PS> ./say-hello
|
||||
.NOTES
|
||||
Author: Markus Fleschutz · License: CC0
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
#>
|
||||
|
||||
try {
|
||||
& "$PSScriptRoot/give-reply.ps1" "Hello, everyone."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
}
|
Reference in New Issue
Block a user