Add speak-ukrainian.ps1

This commit is contained in:
Markus Fleschutz 2022-09-05 19:17:06 +02:00
parent bace31a3fd
commit afd4f0a92b
13 changed files with 45 additions and 12 deletions

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No Danish text-to-speech voice found - please install one"
throw "No Danish voice for text-to-speech (TTS) found - please install one"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No Dutch text-to-speech voice found - please install one"
throw "No Dutch voice for text-to-speech (TTS) found - please install one"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No English text-to-speech voice found - please install one."
throw "No English voice for text-to-speech (TTS) found - please install one."
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No French text-to-speech voice found - please install one."
throw "No French voice for text-to-speech (TTS) found - please install one."
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No German text-to-speech voice found - please install one"
throw "No German voice for text-to-speech (TTS) found - please install one"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No Italian text-to-speech voice found - please install one."
throw "No Italian voice for text-to-speech (TTS) found - please install one."
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No Japanese text-to-speech voice found - please install one"
throw "No Japanese voice for text-to-speech (TTS) found - please install one"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No Latin text-to-speech voice found - please install one"
throw "No Latin voice for text-to-speech (TTS) found - please install one"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No Polish text-to-speech voice found - please install one"
throw "No Polish voice for text-to-speech (TTS) found - please install one"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No Portuguese text-to-speech voice found - please install one"
throw "No Portuguese voice for text-to-speech (TTS) found - please install one"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No Spanish text-to-speech voice found - please install one."
throw "No Spanish voice for text-to-speech (TTS) found - please install one"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -26,7 +26,7 @@ try {
exit 0 # success
}
}
throw "No Swedish text-to-speech voice found - please install one"
throw "No Swedish voice for text-to-speech (TTS) found - please install one"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

33
Scripts/speak-ukrainian.ps1 Executable file
View File

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