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