開始使用免費開始

微調文字轉語音模型

你將使用 VCTK Corpus 來微調一個文字轉語音(text-to-speech)模型,以重現不同地區口音。這個資料集包含約 44 小時的語音資料,說話者為帶有各種英語口音的母語者。

dataset 已經載入並完成前處理,SpeechT5ForTextToSpeech 模組與 Seq2SeqTrainingArgumentsSeq2SeqTrainer 模組也都已載入。資料整理器(data_collator)已預先定義。

請不要在 trainer 設定上呼叫 .train() 方法,因為在此環境執行會導致逾時。

本練習屬於課程

使用 Hugging Face 的多模態模型

檢視課程

練習說明

  • 使用 SpeechT5ForTextToSpeech 載入 microsoft/speecht5_tts 的預訓練模型。
  • 建立 Seq2SeqTrainingArguments 實例,設定:gradient_accumulation_steps8learning_rate0.00001warmup_steps500max_steps4000
  • 使用新的訓練參數,並搭配提供的 model、資料與 processor,來設定 trainer。

動手互動練習

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

# Load the text-to-speech pretrained model
model = ____.____(____)

# Configure the required training arguments
training_args = ____(output_dir="speecht5_finetuned_vctk_test",
    gradient_accumulation_steps=____, learning_rate=____, warmup_steps=____, max_steps=4000, label_names=["labels"],
    push_to_hub=False)

# Configure the trainer
trainer = ____(args=training_args, model=model, data_collator=data_collator,
    train_dataset=dataset["train"], eval_dataset=dataset["test"], tokenizer=processor)
編輯並執行程式碼