Created
May 21, 2014 16:26
-
-
Save pklazy/39da58c8917f5821abaf to your computer and use it in GitHub Desktop.
만들어진 파일은 'aplay -r 44100 -f S16_LE -c 1 test.raw'로 재생.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import alsaaudio | |
f = open('test.raw', 'wb') | |
card = alsaaudio.cards()[1] | |
inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NONBLOCK, card) | |
inp.setchannels(1) | |
inp.setrate(44100) | |
inp.setformat(alsaaudio.PCM_FORMAT_S16_LE) | |
inp.setperiodsize(160) | |
for i in range(1000000): | |
l, data = inp.read() | |
if l: | |
f.write(data) | |
time.sleep(.001) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment