Spoken Language Processing in Python Chapter3
Spoken Language Processing in Python Chapter3
PyDub
S P OK EN LAN GUAGE P ROCES S IN G IN P YTH ON
Daniel Bourke
Machine Learning Engineer/YouTube
Creator
Installing PyDub
$ pip install pydub
type(wav_file)
pydub.audio_segment.AudioSegment
1, 2
wav_file.frame_rate
480000
8488
3284
16000
Daniel Bourke
Machine Learning Engineer/YouTube
Creator
Turning it down to 11
# Import audio file
wav_file = AudioSegment.from_file("wav_file.wav")
# Minus 60 dB
quiet_wav_file = wav_file - 60
UnknownValueError:
# Try to recognize
recognizer.recognize_google(louder_wav_file)
[<pydub.audio_segment.AudioSegment, <pydub.audio_segment.AudioSegment>]
Daniel Bourke
Machine Learning Engineer/YouTube
Creator
Exporting audio les
from pydub import AudioSegment
# Increase by 10 decibels
louder_wav_file = wav_file + 10
<_io.BufferedRandom name='louder_wav_file.wav'>
print(f"Creating {out_file}")
Creating data/right_types/wav_file.wav
Creating data/right_types/flac_file.wav
Creating data/right_types/mp3_file.wav
print(f"Creating {out_file}")
Creating data/louder_no_static/speech-recognition-services.wav
Creating data/louder_no_static/order-issue.wav
Creating data/louder_no_static/help-with-acount.wav