調整音訊參數
在進行探索式資料分析時,你可能會發現有些音訊檔的參數彼此不同,或與語音辨識 API 不相容。
別擔心,PyDub 內建了多種功能,可以讓你變更各種屬性。
例如,你可以在 AudioSegment 實例上呼叫 set_frame_rate(),並傳入以赫茲為單位的整數,來設定音訊檔的取樣率(frame rate)。
在這個練習中,我們要實作調整幾個音訊屬性。
本練習屬於課程
Python 的口語語言處理
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import audio file
wav_file = AudioSegment.from_file(file="wav_file.wav")
# Create a new wav file with adjusted frame rate
wav_file_16k = wav_file.____(____)
# Check the frame rate of the new wav file
print(wav_file_16k.____)