def kayurecord(woodname, duration):
""" Record audio and save to wav file
"""
filename = time_now() + "_" + woodname + ".wav"
container = pyaudio.PyAudio()
stream = container.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)
print("* start recording...")
data = []
frames = []
for i in range(0, int(RATE / CHUNK * duration)):
data = stream.read(CHUNK)
frames.append(data)
stream.stop_stream()
stream.close()
container.terminate()
print("* done recording!")
kayurecord_save(filename, frames, container)
return filename
评论列表
文章目录