diff --git a/speech-recorder.py b/speech-recorder.py new file mode 100644 index 0000000..c4aed9e --- /dev/null +++ b/speech-recorder.py @@ -0,0 +1,49 @@ +import wave +from pyaudio import PyAudio,paInt16 + +framerate=16000 +NUM_SAMPLES=2000 +channels=1 +sampwidth=2 +TIME=10 +def save_wave_file(filename,data): + '''save the date to the wavfile''' + wf=wave.open(filename,'wb') + wf.setnchannels(channels) + wf.setsampwidth(sampwidth) + wf.setframerate(framerate) + wf.writeframes(b"".join(data)) + wf.close() + +def my_record(): + pa=PyAudio() + stream=pa.open(format = paInt16,channels=1, + rate=framerate,input=True, + frames_per_buffer=NUM_SAMPLES) + my_buf=[] + count=0 + while count