Conversia byte-urilor undei sonore în numere întregi

Procesarea limbajului vorbit în Python

Daniel Bourke

Machine Learning Engineer/YouTube Creator

Conversia byte-urilor în numere întregi

  • Nu poți folosi byte-uri
  • Convertește byte-urile în numere întregi folosind 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)
Procesarea limbajului vorbit în Python

Găsirea frecvenței de eșantionare

  • Frecvența de eșantionare (Hz) = lungimea array-ului obiectului wave/durata fișierului audio (secunde)
# Get the frame rate
framerate_gm = good_morning.getframerate()

# Show the frame rate framerate_gm
48,000
  • Durata fișierului audio (secunde) = lungimea array-ului obiectului wave/frecvența de eșantionare (Hz)
Procesarea limbajului vorbit în Python

Găsirea marcajelor de timp ale undei sonore

# Return evenly spaced values between start and stop
np.linspace(start=1, stop=10, num=10)
array([ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9., 10.])
# Get the timestamps of the good morning sound wave
time_gm = np.linspace(start=0, 
                      stop=len(soundwave_gm)/framerate_gm,
                      num=len(soundwave_gm))
Procesarea limbajului vorbit în Python

Găsirea marcajelor de timp ale undei sonore

# View first 10 time stamps of good morning sound wave
time_gm[:10]
array([0.00000000e+00, 2.08334167e-05, 4.16668333e-05, 6.25002500e-05,
       8.33336667e-05, 1.04167083e-04, 1.25000500e-04, 1.45833917e-04,
       1.66667333e-04, 1.87500750e-04])
Procesarea limbajului vorbit în Python

Hai să exersăm!

Procesarea limbajului vorbit în Python

Preparing Video For Download...