自動音声認識
この演習では、AI を使って音声を自動でテキストに書き起こします。再び VCTK Corpus を使います。これは、さまざまなアクセントを持つ英語話者による約 44 時間分の音声を収録したデータセットです。OpenAI の Whisper tiny モデル(パラメータ数はわずか 37M)を使って、VCTK の音声データを前処理し、対応するテキストを生成します。
音声前処理器(processor)と WhisperForConditionalGeneration モジュールは読み込まれています。サンプルの音声データポイント(sample)もすでに用意されています。
この演習はコースの一部です
Hugging Face で学ぶマルチモーダルモデル
演習の手順
openai/whisper-tinyチェックポイントでWhisperForConditionalGenerationの事前学習済みモデルを読み込みます。16000のサンプリングレートでsampleデータポイントを前処理します。- 前処理済み入力の
.input_features属性を使って、モデルからトークンを生成します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# 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)