Added speak-date.ps1

This commit is contained in:
Markus Fleschutz 2021-01-09 16:14:22 +01:00
parent 891548f6b4
commit 3dc9fd05ba
4 changed files with 32 additions and 3 deletions

View File

@ -65,6 +65,7 @@ SHA1.ps1, prints the SHA1 checksum of the given file
SHA256.ps1, prints the SHA256 checksum of the given file
simulate-matrix.ps1, simulates the Matrix (fun)
simulate-presence.ps1, simulates the human presence against burglars
speak-date.ps1, speaks the current date by text-to-speech (TTS)
speak-file.ps1, speaks the content of the given text file by text-to-speech (TTS)
speak-test.ps1, performs a speak test by text-to-speech (TTS)
speak-text.ps1, speaks the given text by text-to-speech (TTS)

1 Filename Description
65 SHA256.ps1 prints the SHA256 checksum of the given file
66 simulate-matrix.ps1 simulates the Matrix (fun)
67 simulate-presence.ps1 simulates the human presence against burglars
68 speak-date.ps1 speaks the current date by text-to-speech (TTS)
69 speak-file.ps1 speaks the content of the given text file by text-to-speech (TTS)
70 speak-test.ps1 performs a speak test by text-to-speech (TTS)
71 speak-text.ps1 speaks the given text by text-to-speech (TTS)

View File

@ -73,6 +73,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
* [SHA256.ps1](Scripts/SHA256.ps1) - prints the SHA256 checksum of the given file
* [simulate-matrix.ps1](Scripts/simulate-matrix.ps1) - simulates the Matrix (fun)
* [simulate-presence.ps1](Scripts/simulate-presence.ps1) - simulates the human presence against burglars
* [speak-date.ps1](Scripts/speak-date.ps1) - speaks the current date by text-to-speech (TTS)
* [speak-file.ps1](Scripts/speak-file.ps1) - speaks the content of the given text file by text-to-speech (TTS)
* [speak-test.ps1](Scripts/speak-test.ps1) - performs a speak test by text-to-speech (TTS)
* [speak-text.ps1](Scripts/speak-text.ps1) - speaks the given text by text-to-speech (TTS)

22
Scripts/speak-date.ps1 Normal file
View 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
}

View File

@ -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])"