|
@@ -14,7 +14,7 @@ Add-Type -AssemblyName System.Windows.Forms
|
14
|
14
|
$form = New-Object System.Windows.Forms.Form
|
15
|
15
|
$form.Text = "EF Audio Tester"
|
16
|
16
|
$form.Width = 300
|
17
|
|
-$form.Height = 100
|
|
17
|
+$form.Height = 150
|
18
|
18
|
|
19
|
19
|
# Create the Record button
|
20
|
20
|
$recordButton = New-Object System.Windows.Forms.Button
|
|
@@ -23,39 +23,47 @@ $recordButton.Width = 75
|
23
|
23
|
$recordButton.Height = 25
|
24
|
24
|
$recordButton.Location = New-Object System.Drawing.Point(10,10)
|
25
|
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
|
29
|
$audioFile = "$env:userprofile\AudioTest.wav"
|
28
|
30
|
$audioFile = $audioFile.Replace("\\","\")
|
29
|
31
|
$audioFile = $audioFile.Replace("/","\")
|
30
|
32
|
$audioFile = [System.IO.Path]::GetFullPath($audioFile)
|
31
|
|
- $audioFile
|
32
|
33
|
$audioFile | Add-Member -MemberType NoteProperty -Name Attributes -Value ([System.IO.FileAttributes]::Hidden)
|
33
|
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
|
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
|
57
|
# Create the Playback button
|
52
|
58
|
$playbackButton = New-Object System.Windows.Forms.Button
|
53
|
59
|
$playbackButton.Text = "Playback"
|
54
|
60
|
$playbackButton.Width = 75
|
55
|
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
|
63
|
$playbackButton.Add_Click({
|
58
|
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
|
67
|
$audioFile = "$env:userprofile\AudioTest.wav"
|
60
|
68
|
$audioFile = $audioFile.Replace("\\","\")
|
61
|
69
|
$audioFile = $audioFile.Replace("/","\")
|
|
@@ -70,9 +78,11 @@ $cleanupButton = New-Object System.Windows.Forms.Button
|
70
|
78
|
$cleanupButton.Text = "Cleanup"
|
71
|
79
|
$cleanupButton.Width = 75
|
72
|
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
|
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
|
86
|
$audioFile = "$env:userprofile\AudioTest.wav"
|
77
|
87
|
$audioFile = $audioFile.Replace("\\","\")
|
78
|
88
|
$audioFile = $audioFile.Replace("/","\")
|