baseline: initial working version

This commit is contained in:
2026-03-30 18:18:41 +01:00
commit 27cfe2a3f5
19 changed files with 3878 additions and 0 deletions

127
run-auto-dub.ps1 Normal file
View File

@@ -0,0 +1,127 @@
param(
[string]$DefaultVideoUrl = "https://youtu.be/EExM3dueOeM",
[string]$DefaultOutputLanguage = "es",
[string]$DefaultInputLanguage = "",
[string]$DefaultLmStudioBaseUrl = "http://127.0.0.1:1234/v1",
[string]$DefaultLmStudioApiKey = "lm-studio",
[string]$DefaultLmStudioModel = "gemma-3-4b-it"
)
$ErrorActionPreference = "Stop"
function Read-Value {
param(
[Parameter(Mandatory = $true)]
[string]$Prompt,
[string]$DefaultValue = "",
[switch]$Required
)
if ($DefaultValue) {
$value = Read-Host "$Prompt [$DefaultValue]"
if ([string]::IsNullOrWhiteSpace($value)) {
$value = $DefaultValue
}
}
else {
$value = Read-Host $Prompt
}
if ($Required -and [string]::IsNullOrWhiteSpace($value)) {
throw "A value is required for: $Prompt"
}
return $value.Trim()
}
$repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$pythonExe = Join-Path $repoRoot ".venv\Scripts\python.exe"
$mainPy = Join-Path $repoRoot "main.py"
$logsDir = Join-Path $repoRoot "logs"
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$logFile = Join-Path $logsDir "auto-dub-$timestamp.log"
if (-not (Test-Path $pythonExe)) {
throw "Python executable not found at $pythonExe. Create the UV environment first."
}
if (-not (Test-Path $mainPy)) {
throw "main.py not found at $mainPy."
}
New-Item -ItemType Directory -Force -Path $logsDir | Out-Null
Write-Host ""
Write-Host "YouTube Auto Dub Launcher" -ForegroundColor Cyan
Write-Host "Repo: $repoRoot"
Write-Host "Log file: $logFile"
Write-Host ""
Write-Host "Leave input language blank to let Whisper auto-detect it." -ForegroundColor Yellow
Write-Host ""
$videoUrl = Read-Value -Prompt "Video URL" -DefaultValue $DefaultVideoUrl -Required
$outputLanguage = Read-Value -Prompt "Output language code" -DefaultValue $DefaultOutputLanguage -Required
$inputLanguage = Read-Value -Prompt "Input language code (optional)" -DefaultValue $DefaultInputLanguage
$lmStudioBaseUrl = Read-Value -Prompt "LM Studio base URL" -DefaultValue $DefaultLmStudioBaseUrl -Required
$lmStudioApiKey = Read-Value -Prompt "LM Studio API key" -DefaultValue $DefaultLmStudioApiKey -Required
$lmStudioModel = Read-Value -Prompt "LM Studio model" -DefaultValue $DefaultLmStudioModel -Required
$env:LM_STUDIO_BASE_URL = $lmStudioBaseUrl
$env:LM_STUDIO_API_KEY = $lmStudioApiKey
$env:LM_STUDIO_MODEL = $lmStudioModel
$commandArgs = @(
$mainPy,
$videoUrl,
"--lang",
$outputLanguage
)
if (-not [string]::IsNullOrWhiteSpace($inputLanguage)) {
$env:SOURCE_LANGUAGE_HINT = $inputLanguage
Write-Host "Using input language hint: $inputLanguage" -ForegroundColor Yellow
}
else {
Remove-Item Env:SOURCE_LANGUAGE_HINT -ErrorAction SilentlyContinue
}
Write-Host ""
Write-Host "Running with:" -ForegroundColor Cyan
Write-Host " Video URL: $videoUrl"
Write-Host " Output language: $outputLanguage"
Write-Host " LM Studio URL: $lmStudioBaseUrl"
Write-Host " LM Studio model: $lmStudioModel"
if ($inputLanguage) {
Write-Host " Input language hint: $inputLanguage"
}
else {
Write-Host " Input language hint: auto-detect"
}
Write-Host ""
Push-Location $repoRoot
try {
$commandLine = @($pythonExe) + $commandArgs
"[$(Get-Date -Format s)] Starting run" | Tee-Object -FilePath $logFile -Append | Out-Null
"[$(Get-Date -Format s)] Command: $($commandLine -join ' ')" | Tee-Object -FilePath $logFile -Append | Out-Null
"[$(Get-Date -Format s)] LM_STUDIO_BASE_URL=$lmStudioBaseUrl" | Tee-Object -FilePath $logFile -Append | Out-Null
"[$(Get-Date -Format s)] LM_STUDIO_MODEL=$lmStudioModel" | Tee-Object -FilePath $logFile -Append | Out-Null
if ($inputLanguage) {
"[$(Get-Date -Format s)] SOURCE_LANGUAGE_HINT=$inputLanguage" | Tee-Object -FilePath $logFile -Append | Out-Null
}
& $pythonExe @commandArgs 2>&1 | Tee-Object -FilePath $logFile -Append
}
catch {
Write-Host ""
Write-Host "The run failed." -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor Red
"[$(Get-Date -Format s)] Launcher error: $($_.Exception.Message)" | Tee-Object -FilePath $logFile -Append | Out-Null
}
finally {
Pop-Location
Write-Host ""
Write-Host "Run log saved to: $logFile" -ForegroundColor Cyan
Read-Host "Press Enter to close"
}