Initial lip-sync service with command backend

This commit is contained in:
cat-shark
2026-06-20 17:16:11 +08:00
commit 8c6a222c38
25 changed files with 1226 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
param(
[int]$Port = 7860,
[string]$HostName = "0.0.0.0",
[ValidateSet("ffmpeg_mux", "command", "copy_video")]
[string]$Backend = "ffmpeg_mux",
[switch]$Install
)
$ErrorActionPreference = "Stop"
$Root = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
Set-Location $Root
$Uv = Get-Command uv -ErrorAction SilentlyContinue
if (-not $Uv) {
throw "uv is required. Install it first: https://docs.astral.sh/uv/getting-started/installation/"
}
if ($Install) {
& $Uv.Source sync
}
$env:LIPSYNC_HOST = $HostName
$env:LIPSYNC_PORT = "$Port"
$env:LIPSYNC_BACKEND = $Backend
$env:PYTHONPATH = (Join-Path $Root "src")
& $Uv.Source run python -m digital_human_lipsync_service
+35
View File
@@ -0,0 +1,35 @@
param(
[string]$ApiUrl = "http://127.0.0.1:7860/",
[Parameter(Mandatory = $true)]
[string]$Audio,
[Parameter(Mandatory = $true)]
[string]$Video
)
$ErrorActionPreference = "Stop"
$Root = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
$Python = Join-Path $Root ".venv\Scripts\python.exe"
if (!(Test-Path -LiteralPath $Python)) {
$Python = "py"
}
$code = @"
import json
import sys
from gradio_client import Client, handle_file
api_url, audio, video = sys.argv[1:4]
client = Client(api_url)
result = client.predict(
audio_file=handle_file(audio),
video_file={"video": handle_file(video)},
api_name="/process_single",
)
print(json.dumps(result, ensure_ascii=False, indent=2))
"@
if ($Python -eq "py") {
py -3 -c $code $ApiUrl $Audio $Video
} else {
& $Python -c $code $ApiUrl $Audio $Video
}