GPT-SoVITS/.github/test.ps1
XXXXRT666 ec8e9f388e WIP
2025-05-21 15:57:34 +03:00

99 lines
3.3 KiB
PowerShell

$ErrorActionPreference = "Stop"
Write-Host "Current location: $(Get-Location)"
$cuda = $env:TORCH_CUDA
if (-not $cuda) {
Write-Error "Missing TORCH_CUDA env (cu124 or cu128)"
exit 1
}
$date = $env:DATE_SUFFIX
if ([string]::IsNullOrWhiteSpace($date)) {
$date = Get-Date -Format "MMdd"
}
$pkgName = "GPT-SoVITS-$date"
$tmpDir = "tmp"
$srcDir = $PWD
$suffix = $env:PKG_SUFFIX
if (-not [string]::IsNullOrWhiteSpace($suffix)) {
$pkgName = "$pkgName$suffix"
}
$pkgName = "$pkgName-$cuda"
Write-Host "[INFO] Cleaning .git..."
Remove-Item "$srcDir\.git" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "[INFO] Creating tmp dir..."
New-Item -ItemType Directory -Force -Path $tmpDir
Write-Host "[INFO] System Python version:"
python --version
python -m site
Write-Host "[INFO] Preparing final directory $pkgName ..."
$items = @(Get-ChildItem -Filter "*.sh") +
@(Get-ChildItem -Filter "*.ipynb") +
@("$tmpDir", ".github", "Docker", "docs", ".gitignore", ".dockerignore", "README.md")
Remove-Item $items -Force -Recurse -ErrorAction SilentlyContinue
$curr = Get-Location
Set-Location ../
Get-ChildItem .
Copy-Item -Path $curr -Destination $pkgName -Recurse
$7zPath = "$pkgName.7z"
$start = Get-Date
Write-Host "Compress Starting at $start"
& "C:\Program Files\7-Zip\7z.exe" a -t7z "$7zPath" "$pkgName" -m0=lzma2 -mx=5 -md=256m -ms=on -mmt=on -bsp1
$end = Get-Date
Write-Host "Elapsed time: $($end - $start)"
Invoke-WebRequest -Uri "https://www.7-zip.org/a/lzma2409.7z" -OutFile "lzma2409.7z"
& "C:\Program Files\7-Zip\7z.exe" x "lzma2409.7z"
$config = @"
;!@Install@!UTF-8!
Title="GPT-SoVITS Installation"
BeginPrompt="MIT, , 使 / This software is open-sourced under the MIT license. The author has no control over it. Users and distributors of the generated voices are solely responsible."
ExtractPath="."
;!@InstallEnd@!
"@
Set-Content -Path "config.txt" -Value $config -Encoding UTF8
Get-Content config.txt
$SfxModule = "./lzma2409/bin/7zSD.sfx"
$SfxExePath = "$pkgName.exe"
Write-Host "[INFO] Creating self-extracting archive: $SfxExePath"
Get-ChildItem .
$cmd = 'copy /b "{0}" + "config.txt" + "{1}" "{2}"' -f $SfxModule, $7zPath, $SfxExePath
Write-Host "[INFO] Running CMD: $cmd"
cmd /c $cmd
python -m pip install --upgrade pip
python -m pip install "modelscope" "huggingface_hub[hf_transfer]" --no-warn-script-location
Write-Host "[INFO] Uploading to ModelScope..."
$msUser = $env:MODELSCOPE_USERNAME
$msToken = $env:MODELSCOPE_TOKEN
if (-not $msUser -or -not $msToken) {
Write-Error "Missing MODELSCOPE_USERNAME or MODELSCOPE_TOKEN"
exit 1
}
modelscope upload "$msUser/GPT-SoVITS-Packages" "$SfxExePath" "$SfxExePath" --repo-type model --token $msToken
Write-Host "[SUCCESS] Uploaded: $SfxExePath to ModelScope"
Write-Host "[INFO] Uploading to HuggingFace..."
$hfUser = $env:HUGGINGFACE_USERNAME
$hfToken = $env:HUGGINGFACE_TOKEN
if (-not $hfUser -or -not $hfToken) {
Write-Error "Missing HUGGINGFACE_USERNAME or HUGGINGFACE_TOKEN"
exit 1
}
$env:HF_HUB_ENABLE_HF_TRANSFER = "1"
huggingface-cli upload "$hfUser/GPT-SoVITS-Packages" "$SfxExePath" "$SfxExePath" --repo-type model --token $hfToken
Write-Host "[SUCCESS] Uploaded: $SfxExePath to HuggingFace"