| 123456789101112131415161718192021222324252627282930313233343536 |
- # Import the necessary assemblies
- Add-Type -AssemblyName System.Windows.Forms
- Add-Type -AssemblyName System.Speech
-
- # Create the form
- $form = New-Object System.Windows.Forms.Form
- $form.Text = "Text-to-Speech"
- $form.Size = New-Object System.Drawing.Size(400,300)
-
- # Create the input field
- $inputField = New-Object System.Windows.Forms.TextBox
- $inputField.Location = New-Object System.Drawing.Size(10,10)
- $inputField.Size = New-Object System.Drawing.Size(375,20)
- $form.Controls.Add($inputField)
-
- # Create the "Speak" button
- $speakButton = New-Object System.Windows.Forms.Button
- $speakButton.Location = New-Object System.Drawing.Size(10,40)
- $speakButton.Size = New-Object System.Drawing.Size(375,20)
- $speakButton.Text = "Speak"
- $form.Controls.Add($speakButton)
-
- # Define the button's click event
- $speakButton.Add_Click({
- # Get the input text
- $inputText = $inputField.Text
-
- # Create a new speech synthesizer
- $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
-
- # Speak the input text
- $synth.Speak($inputText)
- })
-
- # Show the form
- $form.ShowDialog()
|