Python ile Konuşma Dili İşleme
Daniel Bourke
Machine Learning Engineer/YouTube Creator
from pydub import AudioSegment # Ses dosyasını içe aktar wav_file = AudioSegment.from_file("wav_file.wav")# 10 desibel artır louder_wav_file = wav_file + 10# Daha yüksek sesli dosyayı dışa aktar louder_wav_file.export(out_f="louder_wav_file.wav", format="wav")
<_io.BufferedRandom name='louder_wav_file.wav'>
def make_wav(wrong_folder_path, right_folder_path):# Hatalı biçimli dosyalar arasında dolaş for file in os.scandir(wrong_folder_path):# Sadece düzeltilecek ses uzantılı dosyalarla çalış if file.path.endswith(".mp3") or file.path.endswith(".flac"):# Yeni .wav dosya adını oluştur out_file = right_folder_path + os.path.splitext( os.path.basename(file.path))[0] + ".wav"# Ses dosyasını oku ve wav biçiminde dışa aktar AudioSegment.from_file(file.path).export(out_file, format="wav")print(f"Creating {out_file}")
# Yeni fonksiyonu çağır
make_wav("data/wrong_formats/", "data/right_format/")
Creating data/right_types/wav_file.wav
Creating data/right_types/flac_file.wav
Creating data/right_types/mp3_file.wav
def make_no_static_louder(static_quiet, louder_no_static): # Parazitli ve sessiz dosyalar üzerinde dolaş (zaten wav biçiminde) for file in os.scandir(static_quiet_folder_path):# Yeni dosya yolunu oluştur out_file = louder_no_static + os.path.splitext(os.path.basename(file.path))[0] + ".wav"# Ses dosyasını oku audio_file = AudioSegment.from_file(file.path)# İlk üç saniyeyi kaldır, 10 desibel ekle ve dışa aktar audio_file = (audio_file[3100:] + 10).export(out_file, format="wav") print(f"Creating {out_file}")
# Paraziti kaldır ve sesi artır
make_no_static_louder("data/static_quiet/", "data/louder_no_static/")
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
Python ile Konuşma Dili İşleme