Skip to content

Commit

Permalink
Add audio_util.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bwookieeeee committed Sep 6, 2018
1 parent 00f3fcc commit 85da9e3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions audio_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import subprocess
import re

def getAudioDeviceByName(name):

text = subprocess.check_output(['aplay', '-l'])
lines = text.splitlines()
for line in lines:
if name in line:
print line
result = re.match("card (.*?):", line)
print result.group(0)
print result.group(1)
return int(result.group(1))

if __name__ == "__main__":
print "as a test, checking for Yeti mic"
print getAudioDeviceByName("Yeti")

0 comments on commit 85da9e3

Please sign in to comment.