mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-08 20:54:38 +02:00
Added speak-date.ps1
This commit is contained in:
22
Scripts/speak-date.ps1
Normal file
22
Scripts/speak-date.ps1
Normal file
@ -0,0 +1,22 @@
|
||||
#!/snap/bin/powershell
|
||||
<#
|
||||
.SYNTAX ./speak-date.ps1
|
||||
.DESCRIPTION speaks the current date by text-to-speech (TTS)
|
||||
.LINK https://github.com/fleschutz/PowerShell
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
function Speak([string]$Text) {
|
||||
write-progress "$Text"
|
||||
$Voice = new-object -ComObject SAPI.SPVoice
|
||||
[void]$Voice.Speak($Text)
|
||||
write-progress -complete "$Text"
|
||||
}
|
||||
|
||||
try {
|
||||
Speak("Today is $((Get-Date).ToShortDateString())")
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
@ -6,10 +6,15 @@
|
||||
.NOTES Author: Markus Fleschutz / License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
function Speak([string]$Text) {
|
||||
write-progress "$Text"
|
||||
$Voice = new-object -ComObject SAPI.SPVoice
|
||||
$Text = "The current time is $((Get-Date).ToShortTimeString())"
|
||||
$Result = $Voice.Speak($Text)
|
||||
[void]$Voice.Speak($Text)
|
||||
write-progress -complete "$Text"
|
||||
}
|
||||
|
||||
try {
|
||||
Speak("It's now $((Get-Date).ToShortTimeString())")
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Reference in New Issue
Block a user