Add speak-latin.ps1, speak-portuguese.ps1, and speak-swedish.ps1

This commit is contained in:
Markus Fleschutz 2022-03-28 15:08:41 +02:00
parent 485bcbfe65
commit ca23af14bf
10 changed files with 109 additions and 10 deletions

View File

@ -1,6 +1,6 @@
<#
.SYNOPSIS
Speaks text with a Danish text-to-speech voice
Speaks text in Danish
.DESCRIPTION
This PowerShell script speaks the given text with a Danish text-to-speech (TTS) voice.
.PARAMETER text

View File

@ -1,12 +1,12 @@
<#
.SYNOPSIS
Speaks text with an English text-to-speech voice
Speaks text in English
.DESCRIPTION
This PowerShell scripts speaks the given text with an English text-to-speech (TTS) voice.
.PARAMETER text
Specifies the text to speak
.EXAMPLE
PS> ./speak-english "Hello World"
PS> ./speak-english Hello
.LINK
https://github.com/fleschutz/PowerShell
.NOTES

View File

@ -1,6 +1,6 @@
<#
.SYNOPSIS
Speaks text with a French text-to-speech voice
Speaks text in French
.DESCRIPTION
This PowerShell script speaks the given text with a French text-to-speech (TTS) voice.
.PARAMETER text

View File

@ -1,6 +1,6 @@
<#
.SYNOPSIS
Speaks text with a German text-to-speech voice
Speaks text in German
.DESCRIPTION
This PowerShell script speaks the given text with a German text-to-speech (TTS) voice.
.PARAMETER text

View File

@ -1,6 +1,6 @@
<#
.SYNOPSIS
Speaks text with an Italian text-to-speech voice
Speaks text in Italian
.DESCRIPTION
This PowerShell script speaks the given text with an Italian text-to-speech (TTS) voice.
.PARAMETER text
@ -30,4 +30,4 @@ try {
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}
}

33
Scripts/speak-latin.ps1 Normal file
View File

@ -0,0 +1,33 @@
<#
.SYNOPSIS
Speaks text with a Latin text-to-speech voice
.DESCRIPTION
This PowerShell script speaks the given text with a Latin text-to-speech (TTS) voice.
.PARAMETER text
Specifies the text to speak
.EXAMPLE
PS> ./speak-latin Salve
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
#>
param([string]$text = "")
try {
if ($text -eq "") { $text = read-host "Enter the Latin text to speak" }
$TTSVoice = New-Object -ComObject SAPI.SPVoice
foreach ($Voice in $TTSVoice.GetVoices()) {
if ($Voice.GetDescription() -like "*- Latin*") {
$TTSVoice.Voice = $Voice
[void]$TTSVoice.Speak($text)
exit 0 # success
}
}
throw "No Latin text-to-speech voice found - please install one"
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}

View File

@ -1,6 +1,6 @@
<#
.SYNOPSIS
Speaks text with a Polish text-to-speech voice
Speaks text in Polish
.DESCRIPTION
This PowerShell script speaks the given text with a Polish text-to-speech (TTS) voice.
.PARAMETER text

View File

@ -0,0 +1,33 @@
<#
.SYNOPSIS
Speaks text in Portuguese
.DESCRIPTION
This PowerShell script speaks the given text with a Portuguese text-to-speech (TTS) voice.
.PARAMETER text
Specifies the text to speak
.EXAMPLE
PS> ./speak-portuguese Olá
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
#>
param([string]$text = "")
try {
if ($text -eq "") { $text = read-host "Enter the Portuguese text to speak" }
$TTSVoice = New-Object -ComObject SAPI.SPVoice
foreach ($Voice in $TTSVoice.GetVoices()) {
if ($Voice.GetDescription() -like "*- Portuguese*") {
$TTSVoice.Voice = $Voice
[void]$TTSVoice.Speak($text)
exit 0 # success
}
}
throw "No Portuguese text-to-speech voice found - please install one"
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}

View File

@ -1,6 +1,6 @@
<#
.SYNOPSIS
Speaks text with a Spanish text-to-speech voice
Speaks text in Spanish
.DESCRIPTION
This PowerShell script speaks the given text with a Spanish text-to-speech (TTS) voice.
.PARAMETER text
@ -30,4 +30,4 @@ try {
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}
}

33
Scripts/speak-swedish.ps1 Normal file
View File

@ -0,0 +1,33 @@
<#
.SYNOPSIS
Speaks text in Swedish
.DESCRIPTION
This PowerShell script speaks the given text with a Swedish text-to-speech (TTS) voice.
.PARAMETER text
Specifies the text to speak
.EXAMPLE
PS> ./speak-swedish Hallå
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz / License: CC0
#>
param([string]$text = "")
try {
if ($text -eq "") { $text = read-host "Enter the Swedish text to speak" }
$TTSVoice = New-Object -ComObject SAPI.SPVoice
foreach ($Voice in $TTSVoice.GetVoices()) {
if ($Voice.GetDescription() -like "*- Swedish*") {
$TTSVoice.Voice = $Voice
[void]$TTSVoice.Speak($text)
exit 0 # success
}
}
throw "No Swedish text-to-speech voice found - please install one"
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}