Skip to content

Commit aa67a45

Browse files
committed
Add speak-croatian.ps1
1 parent aa388aa commit aa67a45

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Scripts/speak-croatian.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<#
2+
.SYNOPSIS
3+
Speaks text in Croatian
4+
.DESCRIPTION
5+
This PowerShell script speaks the given text with a Croatian text-to-speech (TTS) voice.
6+
.PARAMETER text
7+
Specifies the Croatian text to speak
8+
.EXAMPLE
9+
PS> ./speak-croatian.ps1 zdravo
10+
.LINK
11+
https://github.com/fleschutz/PowerShell
12+
.NOTES
13+
Author: Markus Fleschutz | License: CC0
14+
#>
15+
16+
param([string]$text = "")
17+
18+
try {
19+
if ($text -eq "") { $text = Read-Host "Enter the Croatian text to speak" }
20+
21+
$TTS = New-Object -ComObject SAPI.SPVoice
22+
foreach ($voice in $TTS.GetVoices()) {
23+
if ($voice.GetDescription() -like "*- Croatian*") {
24+
$TTS.Voice = $voice
25+
[void]$TTS.Speak($text)
26+
exit 0 # success
27+
}
28+
}
29+
throw "No Croatian text-to-speech voice found - please install one."
30+
} catch {
31+
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
32+
exit 1
33+
}

0 commit comments

Comments
 (0)