簡體   English   中英

如何使用本地自定義數據集訓練 Wav2vec2 XLSR

[英]How to Train Wav2vec2 XLSR With local Custom Dataset

我想用丹麥語用wav2vec2 xlsr (基於變壓器的模型)訓練語音到文本 model,作為推薦,許多人在數據集庫的幫助下使用普通語音訓練他們的 model,但在普通語音中,很少丹麥語的數據量,現在我想用我自己的自定義數據訓練 model,但我找不到任何明確的文檔,有人可以幫我解決這個問題,我該如何一步一步來?

我建議您使用自己的數據集擴展通用語音 (CV) 丹麥語子集。 首先分析數據集,使您的數據像 CV 語料庫一樣。 此時:數據擴展名(.wav、.mp3 ...)、類型(float32、int ...)、音頻長度,當然還有轉錄格式很重要。 不要讓你的語料庫稀疏。

將數據放入 CV 語料庫文件夾並加載數據集。 然后,您應該能夠使用現有代碼使用擴展數據微調模型。

如果您不是 wav2vec 專家,請不要創建全新的語料庫。

注意:您應該使用較少的數據獲得合理的結果。 您實現了什么 WER,您的目標是什么。 超參數調整可能是您尋找的第一件事而不是數據。

試試https://github.com/jonatasgrosman/huggingsound 這個工具可以很容易地使用本地自定義數據微調 wav2vec2 模型。

我已經構建了一個工具來幫助我使用自定義數據微調 wav2vec2 模型。 也許這也可以幫助你: https://github.com/jonatasgrosman/huggingsound

您可以使用以下方式安裝它: pip install huggingsound

要使用自定義數據集微調 XLSR model,您需要執行以下操作:

from huggingsound import TrainingArguments, ModelArguments, SpeechRecognitionModel, TokenSet

model = SpeechRecognitionModel("facebook/wav2vec2-large-xlsr-53")
output_dir = "my/finetuned/model/output/dir"

# first of all, you need to define your model's token set
# however, the token set is only needed for non-finetuned models
# if you pass a new token set for an already finetuned model, it'll be ignored during training
tokens = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "'"]
token_set = TokenSet(tokens)

# define your custom train data
train_data = [
    {"path": "/path/to/sagan.mp3", "transcription": "extraordinary claims require extraordinary evidence"},
    {"path": "/path/to/asimov.wav", "transcription": "violence is the last refuge of the incompetent"},
]

# and finally, fine-tune your model
model.finetune(
    output_dir, 
    train_data=train_data,
    token_set=token_set,
)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM