Ethan преди 3 години
родител
ревизия
5f7f9ae2c9
променени са 3 файла, в които са добавени 83 реда и са изтрити 0 реда
  1. 14
    0
      SpeakTime.ps1
  2. 33
    0
      SystemSoundsList.ps1
  3. 36
    0
      TTSGUI.ps1

+ 14
- 0
SpeakTime.ps1 Целия файл

@@ -0,0 +1,14 @@
1
+function Say-Time {
2
+    [CmdletBinding()]
3
+    param()
4
+
5
+    # Get the current time
6
+    $time = Get-Date -Format 'h:mm tt'
7
+
8
+    # Use the System.Speech.Synthesis.SpeechSynthesizer class to speak the time
9
+    Add-Type -AssemblyName System.Speech
10
+    $synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
11
+    $synthesizer.Speak($time)
12
+}
13
+
14
+Say-Time

+ 33
- 0
SystemSoundsList.ps1 Целия файл

@@ -0,0 +1,33 @@
1
+# Import the necessary assemblies
2
+Add-Type -AssemblyName System.Windows.Forms
3
+
4
+# Create the form
5
+$form = New-Object System.Windows.Forms.Form
6
+$form.Text = "System Sounds"
7
+$form.Size = New-Object System.Drawing.Size(400,300)
8
+
9
+# Create the list box
10
+$listBox = New-Object System.Windows.Forms.ListBox
11
+$listBox.Location = New-Object System.Drawing.Size(10,10)
12
+$listBox.Size = New-Object System.Drawing.Size(375,250)
13
+$form.Controls.Add($listBox)
14
+
15
+# Get the system sounds directory
16
+$systemSoundsDir = [System.Environment]::GetFolderPath("Windows") + "\Media"
17
+
18
+# Populate the list box with the system sounds
19
+Get-ChildItem -Path $systemSoundsDir | ForEach-Object {
20
+    $listBox.Items.Add($_.Name)
21
+}
22
+
23
+# Define the list box's selected index changed event
24
+$listBox.Add_SelectedIndexChanged({
25
+    # Get the selected sound file
26
+    $selectedSound = $listBox.SelectedItem
27
+
28
+    # Play the sound
29
+    (New-Object System.Media.SoundPlayer -ArgumentList "$systemSoundsDir\$selectedSound").Play()
30
+})
31
+
32
+# Show the form
33
+$form.ShowDialog()

+ 36
- 0
TTSGUI.ps1 Целия файл

@@ -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()

Powered by TurnKey Linux.