当前位置:网站首页>Pyaudio audio recording
Pyaudio audio recording
2022-06-24 21:03:00 【CrazyManhhh】
pyaudio Module calls microphone for audio recording
// An highlighted block
import wave
from pyaudio import PyAudio,paInt16
framerate=16000
NUM_SAMPLES=2000
channels=1
sampwidth=2
TIME=3
def save_wave_file(data):
'''save the date to the wavfile'''
filename = "./static/yuyin/record.wav"
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<TIME*10:# Control recording time
string_audio_data = stream.read(NUM_SAMPLES)
my_buf.append(string_audio_data)
count+=1
save_wave_file(my_buf)
stream.close()
pip install pyaudio Installation Library
边栏推荐
- Apple doesn't need money, but it has no confidence in its content
- 刚购买了一个MYSQL数据库,提示已有实例,控制台登录实例要提供数据库账号,我如何知道数据库账号。
- 传统的IO存在什么问题?为什么引入零拷贝的?
- Nifi quick installation (stand-alone / cluster)
- Simulation lottery and probability statistics experiment of the top 16 Champions League
- 使用gorm查询数据库时reflect: reflect.flag.mustBeAssignable using unaddressable value
- 得物多活架构设计之路由服务设计
- Leetcode (135) - distribute candy
- The difference between RPC and restful
- 红象云腾完成与龙蜥操作系统兼容适配,产品运行稳定
猜你喜欢

Builder mode -- Master asked me to refine pills

主数据建设的背景

After a few years in the testing industry, do you still know a little?

Bean lifecycle flowchart

顺序栈1.0版本

Set up your own website (14)

Material management system based on SSM (source code + document + database)
![[普通物理] 光栅衍射](/img/f3/965ff7cd3bb76b4f71b69b9d12ece3.png)
[普通物理] 光栅衍射

Responsibility chain mode -- through interview

The difference between RPC and restful
随机推荐
Background of master data construction
The latest simulated question bank and answers of the eight members (Electrical constructors) of Sichuan architecture in 2022
JUnit unit test
Variable setting in postman
Steps of JMeter performance test
The first public available pytorch version alphafold2 is reproduced, and Columbia University is open source openfold, with more than 1000 stars
More than ten years' work experience is recommended at the bottom of the box: how much does it cost to find a job? See here! Brothers and sisters are recommended to collect and pay attention
Intermediary model -- collaboration among departments
全上链哈希游戏dapp系统定制(方案设计)
CVPR 2022 remembers Sun Jian! Tongji and Ali won the best student thesis award, and hekaiming was shortlisted
Format method and parse method of dateformat class
Batch capitalization of MySQL table names
Grating diffraction
使用gorm查询数据库时reflect: reflect.flag.mustBeAssignable using unaddressable value
Rename and delete files
Leetcode (146) - LRU cache
C语言实现扫雷(简易版)
Implement the redis simple client customized based on socket
Analysis of errors in JSON conversion using objectmapper
Dongyuhui is not enough to bring goods to "rescue" live broadcast