当前位置:网站首页>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
边栏推荐
- A/B测试助力游戏业务增长
- Postman assertion
- Memo mode - game archiving
- Leetcode (135) - distribute candy
- 基于SSM的物料管理系统(源码+文档+数据库)
- Mr. Hu Bo, CIO of weiduomei, a scientific innovator: digitalization is a bloodless revolution, and the correct answer lies in the field of business
- Open function
- Does the developer want to change to software testing?
- Two fellow countrymen from Hunan have jointly launched a 10 billion yuan IPO
- Tool composition in JMeter
猜你喜欢

Background of master data construction

伯克利、MIT、剑桥、DeepMind等业内大佬线上讲座:迈向安全可靠可控的AI

After idea installs these plug-ins, the code can be written to heaven. My little sister also has to arrange it

云计算发展的 4 个阶段,终于有人讲明白了

Two fellow countrymen from Hunan have jointly launched a 10 billion yuan IPO

Create a multithreaded thread class
![[performance tuning basics] performance tuning strategy](/img/83/be41a6a0c5c186d3fb3a120043c53f.jpg)
[performance tuning basics] performance tuning strategy

The four stages of cloud computing development have finally been clarified

The Network Security Review Office launched a network security review on HowNet, saying that it "has a large amount of important data and sensitive information"

Bean lifecycle flowchart
随机推荐
Comprehensive comparison of the most popular packet capturing tools in the whole network
When querying the database with Gorm, reflect: reflect flag. mustBeAssignable using unaddressable value
Nifi quick installation (stand-alone / cluster)
开放可编程基础设施(OPI)项目,重新定义DPU/IPU
Background operation retry gave up; KeeperErrorCode = ConnectionLoss
Postman assertion
别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
[performance tuning basics] performance tuning strategy
[multi thread performance tuning] multi thread lock optimization (Part 1): optimization method of synchronized synchronization lock
IDEA Dashboard
伯克利、MIT、劍橋、DeepMind等業內大佬線上講座:邁向安全可靠可控的AI
Smooth live broadcast | analysis of key technologies for live broadcast pain points
Stackoverflow annual report 2022: what are developers' favorite databases?
Hongxiang Yunteng is compatible with dragon lizard operating system, and the product runs stably
Enjoy yuan mode -- a large number of flying dragons
Leetcode (455) - distribute cookies
Haitai Advanced Technology | application of privacy computing technology in medical data protection
Set up your own website (14)
主数据建设的背景