Added speak-file.ps1

This commit is contained in:
Markus Fleschutz 2020-12-08 15:11:01 +00:00
parent ec35a6cfb1
commit fc03bc6e29
3 changed files with 26 additions and 4 deletions

View File

@ -1,7 +1,7 @@
Collection of Useful PowerShell Scripts (CUPS)
==============================================
This repository contains 40 useful cross-platform PowerShell scripts - to be used on the command-line (CLI), by context menu, by voice control, or by automation software (e.g. Jenkins).
This repository contains 41 useful cross-platform PowerShell scripts - to be used on the command-line (CLI), by context menu, by voice control, or by automation software (e.g. Jenkins).
List of Scripts
---------------
@ -32,7 +32,8 @@ The following PowerShell scripts can be found in the `Scripts/` subfolder:
* [SHA1.ps1](Scripts/SHA1.ps1) - prints the SHA1 checksum of the given file
* [SHA256.ps1](Scripts/SHA256.ps1) - prints the SHA256 checksum of the given file
* [simulate-presence.ps1](Scripts/simulate-presence.ps1) - simulates the human presence against burglars
* [speak.ps1](Scripts/speak.ps1) - speaks the given text 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-text.ps1](Scripts/speak-text.ps1) - speaks the given text by text-to-speech (TTS)
* [switch-shelly1.ps1](Scripts/switch-shelly1.ps1) - switches a Shelly1 device in the local network
* [take-screenshot.ps1](Scripts/take-screenshot.ps1) - takes a single screenshot
* [take-screenshots.ps1](Scripts/take-screenshots.ps1) - takes multiple screenshots

21
Scripts/speak-file.ps1 Executable file
View File

@ -0,0 +1,21 @@
#!/snap/bin/powershell
# Syntax: ./speak-file.ps1 [<file>]
# Description: speaks the content of the given text file by text-to-speech (TTS)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$File)
if ($File -eq "") {
$File = read-host "Enter path to file"
}
try {
$Text = Get-Content $File
$voice = New-Object ComObject SAPI.SPVoice
$voice.Speak($Text);
exit 0
} catch { Write-Error $Error[0] }
exit 1

View File

@ -1,7 +1,7 @@
#!/snap/bin/powershell
# Syntax: ./speak.ps1 [<text>]
# Description: speaks the given text
# Syntax: ./speak-text.ps1 [<text>]
# Description: speaks the given text by text-to-speech (TTS)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0