File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <#
2+ . SYNOPSIS
3+ Speaks text with an Arabic text-to-speech voice
4+ . DESCRIPTION
5+ This PowerShell script speaks the given text with an Arabic text-to-speech (TTS) voice.
6+ . PARAMETER text
7+ Specifies the text to speak
8+ . EXAMPLE
9+ PS> ./speak-arabic "أهلاً"
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 Arabic text to speak" }
20+
21+ $TTSVoice = New-Object - ComObject SAPI.SPVoice
22+ foreach ($Voice in $TTSVoice.GetVoices ()) {
23+ if ($Voice.GetDescription () -like " *- Arabic*" ) {
24+ $TTSVoice.Voice = $Voice
25+ [void ]$TTSVoice.Speak ($text )
26+ exit 0 # success
27+ }
28+ }
29+ throw " No Arabic voice for text-to-speech (TTS) found - please install one"
30+ } catch {
31+ " ⚠️ Error in line $ ( $_.InvocationInfo.ScriptLineNumber ) : $ ( $Error [0 ]) "
32+ exit 1
33+ }
You can’t perform that action at this time.
0 commit comments