import wave
from pyaudioimport PyAudio,paInt16
from PILimport ImageGrab
import numpyas np
import cv2
from moviepy.editorimport *
from moviepy.audio.fximport all
framerate=8000
NUM_SAMPLES=2000
channels=1
sampwidth=2
TIME=2
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=[]
p = ImageGrab.grab()# 获得当前屏幕
k =