diff --git a/Scripts/speak-hindi.ps1 b/Scripts/speak-hindi.ps1 new file mode 100755 index 00000000..aaec0a3b --- /dev/null +++ b/Scripts/speak-hindi.ps1 @@ -0,0 +1,33 @@ +<# +.SYNOPSIS + Speaks text with a Hindi text-to-speech voice +.DESCRIPTION + This PowerShell script speaks the given text with a Hindi text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-hindi "नमस्ते" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Hindi text to speak" } + + $TTSVoice = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTSVoice.GetVoices()) { + if ($Voice.GetDescription() -like "*- Hindi*") { + $TTSVoice.Voice = $Voice + [void]$TTSVoice.Speak($text) + exit 0 # success + } + } + throw "No Hindi voice for text-to-speech (TTS) found - please install one" +} catch { + "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +}