### Install Sync SDK (Python) Source: https://github.com/rudrabha/wav2lip/blob/master/README.md Installs the Sync SDK for Python, which is necessary for interacting with the Sync.so API to perform lip-sync generations. This command is typically run in a terminal or command prompt. ```bash pip install syncsdk ``` -------------------------------- ### Install Sync SDK (TypeScript) Source: https://github.com/rudrabha/wav2lip/blob/master/README.md Installs the Sync.so SDK for TypeScript using npm, enabling interaction with the Sync API for lip-sync generation tasks within a Node.js or browser environment. ```bash npm i @sync.so/sdk ``` -------------------------------- ### Run TypeScript Script using tsx (Bash) Source: https://github.com/rudrabha/wav2lip/blob/master/README.md This bash command executes the TypeScript quickstart script. It uses `npx` to run the `tsx` command-line tool, which compiles and runs TypeScript code directly. The `-y` flag might be specific to the `tsx` environment for non-interactive execution. ```bash npx tsx quickstart.ts -y ``` -------------------------------- ### Python: Make First Lipsync Generation Source: https://github.com/rudrabha/wav2lip/blob/master/README.md Demonstrates how to make a lip-sync generation using the Sync SDK in Python. It includes setting up the API key, specifying input video and audio URLs, initiating the generation, and polling for job completion. Requires the syncsdk package. ```python # quickstart.py import time from sync import Sync from sync.common import Audio, GenerationOptions, Video from sync.core.api_error import ApiError # ---------- UPDATE API KEY ---------- # Replace with your Sync.so API key api_key = "YOUR_API_KEY_HERE" # ----------[OPTIONAL] UPDATE INPUT VIDEO AND AUDIO URL ---------- # URL to your source video video_url = "https://assets.sync.so/docs/example-video.mp4" # URL to your audio file audio_url = "https://assets.sync.so/docs/example-audio.wav" # ---------------------------------------- client = Sync( base_url="https://api.sync.so", api_key=api_key ).generations print("Starting lip sync generation job...") try: response = client.create( input=[Video(url=video_url),Audio(url=audio_url)], model="lipsync-2", options=GenerationOptions(sync_mode="cut_off"), outputFileName="quickstart" ) except ApiError as e: print(f'create generation request failed with status code {e.status_code} and error {e.body}') exit() job_id = response.id print(f"Generation submitted successfully, job id: {job_id}") generation = client.get(job_id) status = generation.status while status not in ['COMPLETED', 'FAILED']: print('polling status for generation', job_id) time.sleep(10) generation = client.get(job_id) status = generation.status if status == 'COMPLETED': print('generation', job_id, 'completed successfully, output url:', generation.output_url) else: print('generation', job_id, 'failed') ``` -------------------------------- ### Run Python Lipsync Script Source: https://github.com/rudrabha/wav2lip/blob/master/README.md Executes the Python script designed to perform a lip-sync generation using the Sync SDK. This command should be run after saving the Python code to a file (e.g., quickstart.py) and replacing the placeholder API key. ```bash python quickstart.py ``` -------------------------------- ### Create and Monitor Lip Sync Generation Job (TypeScript) Source: https://github.com/rudrabha/wav2lip/blob/master/README.md This TypeScript code snippet utilizes the Sync.so SDK to create a lip sync generation job. It requires an API key, input video and audio URLs, and polls the job status until completion or failure. Outputs the job ID and the final video URL upon success. ```typescript // quickstart.ts import { SyncClient, SyncError } from "@sync.so/sdk"; // ---------- UPDATE API KEY ---------- // Replace with your Sync.so API key const apiKey = "YOUR_API_KEY_HERE"; // ----------[OPTIONAL] UPDATE INPUT VIDEO AND AUDIO URL ---------- // URL to your source video const videoUrl = "https://assets.sync.so/docs/example-video.mp4"; // URL to your audio file const audioUrl = "https://assets.sync.so/docs/example-audio.wav"; // ---------------------------------------- const client = new SyncClient({ apiKey }); async function main() { console.log("Starting lip sync generation job..."); let jobId: string; try { const response = await client.generations.create({ input: [ { type: "video", url: videoUrl, }, { type: "audio", url: audioUrl, }, ], model: "lipsync-2", options: { sync_mode: "cut_off", }, outputFileName: "quickstart" }); jobId = response.id; console.log(`Generation submitted successfully, job id: ${jobId}`); } catch (err) { if (err instanceof SyncError) { console.error(`create generation request failed with status code ${err.statusCode} and error ${JSON.stringify(err.body)}`); } else { console.error('An unexpected error occurred:', err); } return; } let generation; let status; while (status !== 'COMPLETED' && status !== 'FAILED') { console.log(`polling status for generation ${jobId}...`); try { await new Promise(resolve => setTimeout(resolve, 10000)); generation = await client.generations.get(jobId); status = generation.status; } catch (err) { if (err instanceof SyncError) { console.error(`polling failed with status code ${err.statusCode} and error ${JSON.stringify(err.body)}`); } else { console.error('An unexpected error occurred during polling:', err); } status = 'FAILED'; } } if (status === 'COMPLETED') { console.log(`generation ${jobId} completed successfully, output url: ${generation?.outputUrl}`); } else { console.log(`generation ${jobId} failed`); } } main(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.