From fbc4cee09f86c3af290369a207b20d955c64c75b Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sun, 6 Aug 2023 19:02:17 +0200 Subject: [PATCH] Add speak-finnish.ps1 --- Scripts/speak-finnish.ps1 | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Scripts/speak-finnish.ps1 diff --git a/Scripts/speak-finnish.ps1 b/Scripts/speak-finnish.ps1 new file mode 100644 index 00000000..e920580e --- /dev/null +++ b/Scripts/speak-finnish.ps1 @@ -0,0 +1,33 @@ +<# +.SYNOPSIS + Speaks text in Finnish +.DESCRIPTION + This PowerShell script speaks the given text with a Finnish text-to-speech (TTS) voice. +.PARAMETER text + Specifies the Finnish text to speak +.EXAMPLE + PS> ./speak-finnish.ps1 Hei +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = Read-Host "Enter the Finnish text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($voice in $TTS.GetVoices()) { + if ($voice.GetDescription() -like "*- Finnish*") { + $TTS.Voice = $voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Finnish text-to-speech voice found - please install one." +} catch { + "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +}