Spoken Language Processing in Python
Daniel Bourke
Machine Learning Engineer/YouTube Creator
# Importeer audiobestand
wav_file = AudioSegment.from_file("wav_file.wav")
# Min 60 dB
quiet_wav_file = wav_file - 60
# Probeer stille audio te herkennen
recognizer.recognize_google(quiet_wav_file)
UnknownValueError:
# Verhoog het volume met 10 dB
louder_wav_file = wav_file + 10
# Probeer te herkennen
recognizer.recognize_google(louder_wav_file)
this is a wav file
# Importeer AudioSegment en normaliseer
from pydub import AudioSegment
from pydub.effects import normalize
from pydub.playback import play
# Importeer audio met wisselend volume
loud_quiet = AudioSegment.from_file("loud_quiet.wav")
# Normaliseer het volumeniveau
normalized_loud_quiet = normalize(loud_quiet)
# Luister
play(normalized_loud_quiet)
# Importeer audio met ruis aan het begin
static_at_start = AudioSegment.from_file("static_at_start.wav")
# Verwijder de ruis via slicing
no_static_at_start = static_at_start[5000:]
# Luister
play(no_static_at_start)
# Importeer twee audiobestanden
wav_file_1 = AudioSegment.from_file("wav_file_1.wav")
wav_file_2 = AudioSegment.from_file("wav_file_2.wav")
# Combineer de twee audiobestanden
wav_file_3 = wav_file_1 + wav_file_2
# Luister
play(wav_file_3)
# Combineer twee wav-bestanden en maak het resultaat harder
louder_wav_file_3 = wav_file_1 + wav_file_2 + 10
# Importeer telefoongesprek-audio
phone_call = AudioSegment.from_file("phone_call.wav")
# Aantal kanalen opvragen
phone_call.channels
2
# Splits stereo naar mono
phone_call_channels = phone_call.split_to_mono()
phone_call_channels
[<pydub.audio_segment.AudioSegment, <pydub.audio_segment.AudioSegment>]
# Aantal kanalen van het eerste item
phone_call_channels[0].channels
1
# Herken het eerste kanaal
recognizer.recognize_google(phone_call_channel_1)
the pydub library is really useful
Spoken Language Processing in Python