python 调用麦克风;摄像头;截屏;
# -*- coding: utf-8 -*- """ Created on Mon Jun 24 14:47:35 2019 @author: erio """ from PIL import Image,ImageGrab import cv2 import pyaudio import wave ''' #录音 input_filename = "record.wav" # 麦克风采集的语音输入 input_filepath = "E:" # 输入文件的path in_pathrec = input_filepath + input_filename #通俗解释就是wav文件路径 def get_audio(filepath): CHUNK = 256 #定义数据流块 FORMAT = pyaudio.paInt16 #量化位数(音量级划分) CHANNELS = 1 # 声道数;声道数:可以是单声道或者是双声道 RATE = 8000 # 采样率;采样率:一秒内对声音信号的采集次数,常用的有8kHz, 16kHz, 32kHz, 48kHz, 11.025kHz, 22.05kHz, 44.1kHz RECORD_SECONDS = 10 #录音秒数 WAVE_OUTPUT_FILENAME = filepath #wav文件路径 p = pyaudio.PyAudio()