-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupmic.py
71 lines (52 loc) · 1.78 KB
/
setupmic.py
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
67
68
69
70
71
import subprocess
# Check microphone
def check_microphone():
print("Checking microphone...")
# Record a short audio sample
subprocess.run(["arecord", "-d", "3", "-f", "S16_LE", "-r", "44100", "-c", "2", "test.wav"])
# Play back the audio sample
subprocess.run(["aplay", "test.wav"])
# Clean up
subprocess.run(["rm", "test.wav"])
# Check ALSA
def check_alsa():
print("Checking ALSA...")
# Check configuration file
subprocess.run(["cat", "/etc/asound.conf"])
# Test command
subprocess.run(["speaker-test", "-c", "2", "-r", "48000", "-D", "hw:0,0"])
# Check PulseAudio
def check_pulseaudio():
print("Checking PulseAudio...")
# Check configuration file
subprocess.run(["cat", "/etc/pulse/default.pa"])
# Test command
subprocess.run(["pactl", "load-module", "module-null-sink"])
# Check JACKD
def check_jackd():
print("Checking JACKD...")
# Check configuration file
subprocess.run(["cat", "/etc/jackdrc"])
# Test command
subprocess.run(["jackd", "-d", "alsa"])
# Set permissions for Sabia
def set_permissions():
print("Setting permissions for Sabia...")
# Add user to audio group
subprocess.run(["sudo", "usermod", "-a", "-G", "audio", "sabia_user"])
# Install necessary packages
def install_packages():
print("Installing necessary packages...")
# Check if packages are installed and install them if necessary
subprocess.run(["sudo", "apt", "install", "-y", "alsa-utils", "pulseaudio", "jackd", "python3-pyaudio"])
subprocess.run(["pip", "install", "numpy", "pyaudio", "SpeechRecognition", "gtts"])
# Main function
def main():
check_microphone()
check_alsa()
check_pulseaudio()
check_jackd()
set_permissions()
install_packages()
if __name__ == "__main__":
main()