-
-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathspeak-french.ps1
More file actions
executable file
·35 lines (31 loc) · 844 Bytes
/
speak-french.ps1
File metadata and controls
executable file
·35 lines (31 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<#
.SYNOPSIS
Speaks text in French
.DESCRIPTION
This PowerShell script speaks the given text with a French text-to-speech (TTS) voice.
.PARAMETER text
Specifies the French text to speak
.EXAMPLE
PS> ./speak-french.ps1 Salut
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
#requires -version 5.1
param([string]$text = "")
try {
if ($text -eq "") { $text = Read-Host "Enter the French text to speak" }
$TTS = New-Object -ComObject SAPI.SPVoice
foreach ($voice in $TTS.GetVoices()) {
if ($voice.GetDescription() -like "*- French*") {
$TTS.Voice = $voice
[void]$TTS.Speak($text)
exit 0 # success
}
}
throw "No French text-to-speech voice found - please install one."
} catch {
"⚠️ ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
exit 1
}