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

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