当前位置:网站首页>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
边栏推荐
- Background operation retry gave up; KeeperErrorCode = ConnectionLoss
- 顺序栈1.0版本
- Analysis of errors in JSON conversion using objectmapper
- Rename and delete files
- Comprehensive comparison of the most popular packet capturing tools in the whole network
- Basic properties and ergodicity of binary tree
- Enjoy yuan mode -- a large number of flying dragons
- 大一女生废话编程爆火!懂不懂编程的看完都拴Q了
- 伯克利、MIT、剑桥、DeepMind等业内大佬线上讲座:迈向安全可靠可控的AI
- Where is 5g really powerful? What is the difference with 4G?
猜你喜欢

Basic properties and ergodicity of binary tree

Otaku can't save yuan universe

Variable setting in postman

A/b test helps the growth of game business

伯克利、MIT、剑桥、DeepMind等业内大佬线上讲座:迈向安全可靠可控的AI
浅谈MySql update会锁定哪些范围的数据

How to apply agile development ideas to other work

Visitor model -- generation gap between young and middle-aged people

虚拟化是什么意思?包含哪些技术?与私有云有什么区别?

网络安全审查办公室对知网启动网络安全审查
随机推荐
Leetcode(455)——分发饼干
JMeter installation plug-in, adding [email protected] -Perfmon metric collector listener steps
得物多活架构设计之路由服务设计
Two fellow countrymen from Hunan have jointly launched a 10 billion yuan IPO
大一女生废话编程爆火!懂不懂编程的看完都拴Q了
C langage pour le déminage (version simplifiée)
Basic concepts and definitions of Graphs
Otaku can't save yuan universe
Undo log and redo log must be clear this time
[performance tuning basics] performance tuning strategy
After 5 months' test, it took 15K to come for an interview. When I asked, it was not worth even 5K. It was really
Memo mode - game archiving
微信小程序自定义tabBar
顺序栈遍历二叉树
浅谈MySql update会锁定哪些范围的数据
[普通物理] 光栅衍射
Leetcode (135) - distribute candy
Berkeley, MIT, Cambridge, deepmind et d'autres grandes conférences en ligne: vers une IA sûre, fiable et contrôlable
DX12引擎开发课程进度-这个课程到底讲到哪里了
海泰前沿技术|隐私计算技术在医疗数据保护中的应用