[Python] Use this to read and write wav files [wavio]

High resolution compatible wav files that have increased suddenly recently. This is a 24-bit bit rate, which is very annoying to handle with python. The module that solves such a problem is "wavio".

Introduction

pip install wavio

Read wav file

wavread.py


import wavio

wav = wavio.read(filename)

fs = wav.rate #Sampling frequency[Hz]
samplewidth = wav.sampwidth #Sample width[Byte]
bit = wav.sampwidth * 8 #Number of quantization bits[bit]
data = wav.data #Waveform data
ch = len(wav.data[0, :]) #Number of channels

Export wav file

wavwrite.py


wavio.write("filename.wav", data, fs, sampwidth = samplewidth)

At the end

What actually works behind the scenes is the standard python module wave, but well, it would be convenient to have something like this.

Recommended Posts

[Python] Use this to read and write wav files [wavio]
Read and use Python files from Python
Read and write JSON files in Python
Read and write files with Slackbot ~ Bot development with Python ~
How to use functions in separate files Perl and Python versions
How to install and use pandas_datareader [Python]
Bind to class to read and write YAML
Read Python csv and export to txt
python: How to use locals () and globals ()
How to use Python zip and enumerate
Compress python data and write to sqlite
How to use is and == in Python
[Python] How to read data from CIFAR-10 and CIFAR-100
[Python3] Read and write with datetime isoformat with json
[Python] How to use hash function and tuple.
Read wav files with only Python standard packages
[Python] [Django] How to use ChoiceField and how to add options
Include and use external Kv files in Python Kivy
It's not easy to write Python, it's easy to write numpy and scipy
Write tests in Python to profile and check coverage
[Python] How to split and modularize files (simple, example)
Read and write NFC tags in python using PaSoRi
Save lists, dictionaries and tuples to external files python
Easy to use Nifty Cloud API with botocore and python
Read and write csv file
python3: How to use bottle (2)
[Python] How to use list 1
[R] [Python] Memo to read multiple csv files in multiple zip files
Use Azure ML Python SDK 4: Write output to Blob storage-Part 2
[Introduction to Udemy Python 3 + Application] 36. How to use In and Not
Read and write a file
Tips for coding short and easy to read in Python
[Python] Summary of how to use split and join functions
Python: How to use pydub
Comparison of how to use higher-order functions in Python 2 and 3
[Python] How to use checkio
Write and read a file
How to write a metaclass that supports both python2 and python3
[Python] Try to analyze wav files (Ver without additional plugins)
Use Azure ML Python SDK 3: Write output to Blob storage-Part 1
[Python] How to use input ()
How to use Python lambda
[Python] How to use virtualenv
python3: How to use bottle (3)
python3: How to use bottle
How to use Python bytes
I made a library to easily read config files with Python
processing to use notMNIST data in Python (and tried to classify it)
Offline real-time how to write E11 ruby and python implementation example
How to import CSV and TSV files into SQLite with Python
How to use Serverless Framework & Python environment variables and manage stages
How to use the asterisk (*) in Python. Maybe this is all? ..
Read big endian binary in Python and convert it to ndarray
I want to use both key and value of Python iterator
How to play music (wav / mp3) files on Raspberry Pi python
Read, change, and write Excel files on GCP App Engine Storage
How to use Python with Jw_cad (Part 2 Command explanation and operation)
[Introduction to Python] How to use the Boolean operator (and ・ or ・ not)
How to write a Python class
Python: How to use async with
Python 3.6 on Windows ... and to Xamarin.