-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFreeHearingTest.ps1
66 lines (55 loc) · 2.35 KB
/
FreeHearingTest.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Function to test hearing for a specified ear
function TestHearing {
param (
[string]$ear
)
# Define the hearing assessment thresholds in kHz
$goodHearingThreshold = 20
$averageHearingThreshold = 16
$hearingProblemsThreshold = 12
# Variable to store the highest frequency heard
$highestFrequencyHeard = 0
for ($i = 1; $i -lt 33; $i += 1) {
$frequency = $i * 1000 # Convert kHz to Hz
Read-Host "> Press Enter to beep at $i kHz ($frequency Hz) in your $ear ear"
[console]::beep($frequency, 1000)
$response = Read-Host "Could you hear the $i kHz beep in your $ear ear? (Y/N)"
if ($response -eq "Y" -or $response -eq "y") {
$highestFrequencyHeard = $i
clear
} else {
clear
break
}
}
# Provide feedback based on the highest frequency heard
if ($highestFrequencyHeard -ge $goodHearingThreshold) {
return "You have good hearing in your $ear ear. You heard up to $highestFrequencyHeard kHz."
} elseif ($highestFrequencyHeard -ge $averageHearingThreshold) {
return "You have average hearing in your $ear ear. You heard up to $highestFrequencyHeard kHz."
} elseif ($highestFrequencyHeard -ge $hearingProblemsThreshold) {
return "You might be starting to have hearing problems in your $ear ear. You heard up to $highestFrequencyHeard kHz."
} else {
return "You have significant hearing loss in your $ear ear. You heard up to $highestFrequencyHeard kHz."
}
}
# Instructions for the test
clear
Write-Host "Welcome to the Hearing Test."
Write-Host "You will be testing your hearing for both your left and right ears."
Write-Host "The test will play a series of beeps at different frequencies."
Write-Host "For each beep, indicate if you can hear it by typing 'Y' or 'N'."
Write-Host "Press Enter to begin the test."
# Start the test
Read-Host "> Press Enter to start with your left ear"
# Test for the left ear
$leftEarResult = TestHearing -ear "left"
Write-Host "Let's switch ears."
# Test for the right ear
Read-Host "> Press Enter to start with your right ear"
$rightEarResult = TestHearing -ear "right"
# Print the results at the end
clear
Write-Host "`nResults:"
Write-Host $leftEarResult
Write-Host $rightEarResult