|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+# Import the necessary assemblies
|
|
|
2
|
+Add-Type -AssemblyName System.Windows.Forms
|
|
|
3
|
+Add-Type -AssemblyName System.Speech
|
|
|
4
|
+
|
|
|
5
|
+# Create the form
|
|
|
6
|
+$form = New-Object System.Windows.Forms.Form
|
|
|
7
|
+$form.Text = "Text-to-Speech"
|
|
|
8
|
+$form.Size = New-Object System.Drawing.Size(400,300)
|
|
|
9
|
+
|
|
|
10
|
+# Create the input field
|
|
|
11
|
+$inputField = New-Object System.Windows.Forms.TextBox
|
|
|
12
|
+$inputField.Location = New-Object System.Drawing.Size(10,10)
|
|
|
13
|
+$inputField.Size = New-Object System.Drawing.Size(375,20)
|
|
|
14
|
+$form.Controls.Add($inputField)
|
|
|
15
|
+
|
|
|
16
|
+# Create the "Speak" button
|
|
|
17
|
+$speakButton = New-Object System.Windows.Forms.Button
|
|
|
18
|
+$speakButton.Location = New-Object System.Drawing.Size(10,40)
|
|
|
19
|
+$speakButton.Size = New-Object System.Drawing.Size(375,20)
|
|
|
20
|
+$speakButton.Text = "Speak"
|
|
|
21
|
+$form.Controls.Add($speakButton)
|
|
|
22
|
+
|
|
|
23
|
+# Define the button's click event
|
|
|
24
|
+$speakButton.Add_Click({
|
|
|
25
|
+ # Get the input text
|
|
|
26
|
+ $inputText = $inputField.Text
|
|
|
27
|
+
|
|
|
28
|
+ # Create a new speech synthesizer
|
|
|
29
|
+ $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
|
|
|
30
|
+
|
|
|
31
|
+ # Speak the input text
|
|
|
32
|
+ $synth.Speak($inputText)
|
|
|
33
|
+})
|
|
|
34
|
+
|
|
|
35
|
+# Show the form
|
|
|
36
|
+$form.ShowDialog()
|