音訊前處理
在這個練習中,你會學到如何調整音訊資料的取樣率,以及如何使用自動前處理器。你將使用 VCTK Corpus,其中包含約 44 小時、由 110 位帶有各種口音的英語說話者所錄製的語音資料。
dataset 已經載入完成。
本練習屬於課程
使用 Hugging Face 的多模態模型
練習說明
- 使用
.cast_column()方法,將資料集中的音訊重取樣為 16,000 Hz。 - 以預訓練的
openai/whisper-small模型載入音訊處理器。 - 以前述相同的取樣率並設定
padding=True,對第一筆資料的音訊進行前處理。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Resample the audio to a frequency of 16,000 Hz
dataset = dataset.____("____", ____(sampling_rate=____))
# Load the audio processor
processor = ____
# Preprocess the audio data of the 0th dataset element
audio_pp = ____(dataset[0]["audio"]["array"], sampling_rate=____, padding=True, return_tensors="pt")
make_spectrogram(audio_pp["input_features"][0])