MOCKINGBIRD進行訓練時,測試在aishell3語音檔結構下僅取用單一人語音進行訓練,須將訓練文檔進行修改

aishell3語音檔案結構:

DATA_root>
├─aishell3
│ └─train
│ └─wav
│ ├─SSB0005
│ ├─...
 
在wav目錄下,每個目錄為以個人做區分的錄音檔集合
在train目錄中,content.txt是錄音檔檔案名稱及對應的語音內容拼音標註
label_train-set.txt是拼音和斷句標示,以"|"進行區分
因此,我們可以將wav目錄下僅留下欲使用的單人語音目錄,例如:SSB0005
則以string為SSB0005
製作如下抽取程序 EXTRACT.PS1 執行方式為 ./extract.ps1 path\filname string               

param(
    [Parameter(Mandatory=$true, HelpMessage="The name of the input file.")]
    [string]$FILENAME,

    [Parameter(Mandatory=$true, HelpMessage="The string to match at the beginning of lines.")]
    [string]$STRING
)

# 檢查參數是否為有效值
if (-not (Test-Path $FILENAME)) {
    Write-Host "ERROR: The specified file '$FILENAME' does not exist."
    exit
}

try {
    $lines = Get-Content -Path $FILENAME -Encoding UTF8 | Where-Object {
        # 排除空白行、以 '#' 開頭、以指定字串開頭的行
        ($_ -notmatch '^\s*$') -and ($_ -notmatch '^#') -and ($_ -like "$STRING*")
    }

    if ($lines.Count -eq 0) {
        Write-Host "No lines matching the specified criteria were found in '$FILENAME'."
    } else {
        $FILENAME2 = $FILENAME.Replace(".", "_2.")
        $lines | Out-File -FilePath $FILENAME2 -Encoding UTF8
        Write-Host "Matching lines have been saved to '$FILENAME2'."
    }
}
catch {
    Write-Host "An error occurred while processing the file: $_"
    exit
}

 

創作者介紹
創作者 Working Notes-My Work Diary 的頭像
laizhucheng

Working Notes-My Work Diary

laizhucheng 發表在 痞客邦 留言(0) 人氣( 3 )