Browse Source

Update 'ChatGPT-AudioTester.ps1'

Ethan 2 years ago
parent
commit
b84e28305c
1 changed files with 30 additions and 20 deletions
  1. 30
    20
      ChatGPT-AudioTester.ps1

+ 30
- 20
ChatGPT-AudioTester.ps1 View File

14
 $form = New-Object System.Windows.Forms.Form
14
 $form = New-Object System.Windows.Forms.Form
15
 $form.Text = "EF Audio Tester"
15
 $form.Text = "EF Audio Tester"
16
 $form.Width = 300
16
 $form.Width = 300
17
-$form.Height = 100
17
+$form.Height = 150
18
 
18
 
19
 # Create the Record button
19
 # Create the Record button
20
 $recordButton = New-Object System.Windows.Forms.Button
20
 $recordButton = New-Object System.Windows.Forms.Button
23
 $recordButton.Height = 25
23
 $recordButton.Height = 25
24
 $recordButton.Location = New-Object System.Drawing.Point(10,10)
24
 $recordButton.Location = New-Object System.Drawing.Point(10,10)
25
 $recordButton.Add_Click({
25
 $recordButton.Add_Click({
26
-    # Code to run when the Record button is clicked
26
+# Code to run when the Record button is clicked
27
+    # Play a 400hz beep sound
28
+    (New-Object Media.SoundPlayer -ArgumentList "C:\Windows\Media\Windows Notify.wav").PlaySync()
27
     $audioFile = "$env:userprofile\AudioTest.wav"
29
     $audioFile = "$env:userprofile\AudioTest.wav"
28
     $audioFile = $audioFile.Replace("\\","\")
30
     $audioFile = $audioFile.Replace("\\","\")
29
     $audioFile = $audioFile.Replace("/","\")
31
     $audioFile = $audioFile.Replace("/","\")
30
     $audioFile = [System.IO.Path]::GetFullPath($audioFile)
32
     $audioFile = [System.IO.Path]::GetFullPath($audioFile)
31
-    $audioFile
32
     $audioFile | Add-Member -MemberType NoteProperty -Name Attributes -Value ([System.IO.FileAttributes]::Hidden)
33
     $audioFile | Add-Member -MemberType NoteProperty -Name Attributes -Value ([System.IO.FileAttributes]::Hidden)
33
     # Record audio from the default audio recording device into the temporary file
34
     # Record audio from the default audio recording device into the temporary file
34
-    Start-Process -FilePath "ms-settings:sound" -ArgumentList "-microphone"
35
-    Start-Sleep -s 5
36
-    $rec = New-Object -ComObject SAPI.SpVoice
37
-    $rec.Voice = $rec.GetVoices().Item(0)
38
-    $rec.speak("Recording started.")
39
-    $rec.AudioOutputStream = (New-Object -ComObject SAPI.SpFileStream)
40
-    $rec.AudioOutputStream.Open($audioFile,3)
41
-    $rec.Speak("Recording.")
42
-    Start-Sleep -s 10
43
-    $rec.speak("Recording stopped.")
44
-    $rec.AudioOutputStream.Close()
45
-    $rec.AudioOutputStream = $null
46
-    $rec = $null
47
-    $rec.speak("Recording has been saved.")
35
+    $rec = New-Object System.Media.SoundPlayer
36
+    $rec.SoundLocation = $audioFile
37
+    $rec.Open()
38
+    $rec.Play()
48
 })
39
 })
49
 $form.Controls.Add($recordButton)
40
 $form.Controls.Add($recordButton)
50
 
41
 
42
+# Create the Stop Recording button
43
+$stopButton = New-Object System.Windows.Forms.Button
44
+$stopButton.Text = "Stop Recording"
45
+$stopButton.Width = 75
46
+$stopButton.Height = 25
47
+$stopButton.Location = New-Object System.Drawing.Point(100,10)
48
+$stopButton.Add_Click({
49
+    # Code to run when the Stop Recording button is clicked
50
+    # Play a 400hz beep sound
51
+    (New-Object Media.SoundPlayer -ArgumentList "C:\Windows\Media\Windows Notify.wav").PlaySync()
52
+    $rec.Stop()
53
+    $rec.Dispose()
54
+})
55
+$form.Controls.Add($stopButton)
56
+
51
 # Create the Playback button
57
 # Create the Playback button
52
 $playbackButton = New-Object System.Windows.Forms.Button
58
 $playbackButton = New-Object System.Windows.Forms.Button
53
 $playbackButton.Text = "Playback"
59
 $playbackButton.Text = "Playback"
54
 $playbackButton.Width = 75
60
 $playbackButton.Width = 75
55
 $playbackButton.Height = 25
61
 $playbackButton.Height = 25
56
-$playbackButton.Location = New-Object System.Drawing.Point(100,10)
62
+$playbackButton.Location = New-Object System.Drawing.Point(190,10)
57
 $playbackButton.Add_Click({
63
 $playbackButton.Add_Click({
58
     # Code to run when the Playback button is clicked
64
     # Code to run when the Playback button is clicked
65
+    # Play a 400hz beep sound
66
+    (New-Object Media.SoundPlayer -ArgumentList "C:\Windows\Media\Windows Notify.wav").PlaySync()
59
     $audioFile = "$env:userprofile\AudioTest.wav"
67
     $audioFile = "$env:userprofile\AudioTest.wav"
60
     $audioFile = $audioFile.Replace("\\","\")
68
     $audioFile = $audioFile.Replace("\\","\")
61
     $audioFile = $audioFile.Replace("/","\")
69
     $audioFile = $audioFile.Replace("/","\")
70
 $cleanupButton.Text = "Cleanup"
78
 $cleanupButton.Text = "Cleanup"
71
 $cleanupButton.Width = 75
79
 $cleanupButton.Width = 75
72
 $cleanupButton.Height = 25
80
 $cleanupButton.Height = 25
73
-$cleanupButton.Location = New-Object System.Drawing.Point(190,10)
81
+$cleanupButton.Location = New-Object System.Drawing.Point(10,50)
74
 $cleanupButton.Add_Click({
82
 $cleanupButton.Add_Click({
75
-    # Code to run when the Cleanup button is clicked
83
+# Code to run when the Cleanup button is clicked
84
+    # Play a 400hz beep sound
85
+    (New-Object Media.SoundPlayer -ArgumentList "C:\Windows\Media\Windows Notify.wav").PlaySync()
76
     $audioFile = "$env:userprofile\AudioTest.wav"
86
     $audioFile = "$env:userprofile\AudioTest.wav"
77
     $audioFile = $audioFile.Replace("\\","\")
87
     $audioFile = $audioFile.Replace("\\","\")
78
     $audioFile = $audioFile.Replace("/","\")
88
     $audioFile = $audioFile.Replace("/","\")

Powered by TurnKey Linux.