-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy path25_3.ps1
More file actions
27 lines (27 loc) · 697 Bytes
/
25_3.ps1
File metadata and controls
27 lines (27 loc) · 697 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
function Invoke-Speech {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true)]
[string[]]$Text,
[switch]$Asynchronous
)
BEGIN {
Add-Type -AssemblyName System.Speech
$speech = New-Object -TypeName
å System.Speech.Synthesis.SpeechSynthesizer
}
PROCESS {
foreach ($phrase in $text) {
if ($Asynchronous) {
$null = $speech.SpeakAsync($phrase) #A
} else {
$speech.speak($phrase)
}
}
}
END {}
}
1..10 | Invoke-Speech -Asynchronous
Write-Host "This appears"
#A $null to the left to surpress the output