開始使用免費開始

自動語音辨識

在這個練習中,你會用 AI 自動將語音轉成文字!你會再次使用 VCTK Corpus,這個資料集包含約 44 小時、由不同口音的英語使用者所錄製的語音。你將使用 OpenAI 的 Whisper tiny 模型(只有 37M 參數)來前處理 VCTK 的音訊資料,並產生對應的文字。

音訊前處理器(processor)以及 WhisperForConditionalGeneration 模組都已載入。單一音訊樣本資料點(sample)也已經就緒。

本練習屬於課程

使用 Hugging Face 的多模態模型

檢視課程

練習說明

  • 使用 openai/whisper-tiny checkpoint 載入 WhisperForConditionalGeneration 的預訓練模型。
  • 以需求的取樣率 16000sample 資料點進行前處理。
  • 使用前處理輸入的 .input_features 屬性,從模型產生語彙標記(tokens)。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Load the pretrained model
model = ____
model.config.forced_decoder_ids=None

# Preprocess the sample audio
input_preprocessed = ____(____, sampling_rate=____, return_tensors="pt", return_attention_mask=True)

# Generate the IDs of the recognized tokens
predicted_ids = ____
transcription = processor.decode(predicted_ids[0], skip_special_tokens=True)
print(transcription)
編輯並執行程式碼