Chapter 1
Chapter 1
data in Python
SPOKEN LANGUAGE PROCESSING IN PYTHON
Daniel Bourke
Machine Learning Engineer/YouTube
Creator
Dealing with audio files in Python
Different kinds all of audio files
mp3
wav
m4a
flac
import wave
b'\xfd\xff\xfb\xff\xf8\xff\xf8\xff\xf7\...
Daniel Bourke
Machine Learning Engineer/YouTube
Creator
Converting bytes to integers
Can't use bytes
Convert bytes to integers using numpy
import numpy as np
# Convert soundwave_gm from bytes to integers
signal_gm = np.frombuffer(soundwave_gm, dtype='int16')
# Show the first 10 items
signal_gm[:10]
array([ -3, -5, -8, -8, -9, -13, -8, -10, -9, -11], dtype=int16)
48,000
array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
Daniel Bourke
Machine Learning Engineer/YouTube
Creator
Adding another sound wave
New audio file: good_afternoon.wav
Both are 48 kHz