一、所需库安装
pip install PyAudio
pip install SpeechRecognition
pip install baidu-aip
pip install Wave
pip install Wheel
pip install Pyinstaller
二、百度官网申请服务
三、源代码分享
import pyaudio
import wave
from aip import AipSpeech
import time
# 用Pyaudio库录制音频
# out_file:输出音频文件名
# rec_time:音频录制时间(秒)
def audio_record(out_file, rec_time):
CHUNK = 1024
FORMAT = pyaudio.paInt16 # 16bit编码格式
CHANNELS = 1 # 单声道
RATE = 16000 # 16000采样频率
p = pyaudio.PyAudio()