rhubarb-lip-sync-wasm
Version:
WebAssembly port of Rhubarb Lip Sync - an advanced lip sync tool that automatically creates mouth animation from audio files. Perfect for AI agents, virtual characters, and interactive applications. Optimized for web applications with TypeScript support.
27 lines (26 loc) • 921 B
JavaScript
import { initWasmModule } from "./wasm-loader.js";
/**
* Main Rhubarb class for lip sync generation
*/
export class Rhubarb {
static async getModule() {
if (!this.wasmModule) {
this.wasmModule = initWasmModule();
}
return this.wasmModule;
}
/**
* Generate lip sync data from PCM audio data
* @param pcmData Buffer containing 16-bit PCM audio data at 16kHz mono
* @param options Optional parameters including dialog text
* @returns Promise resolving to lip sync result with mouth cues
*/
static async getLipSync(pcmData, options = {}) {
if (!Buffer.isBuffer(pcmData)) {
throw new Error('pcmData must be a Buffer containing 16-bit PCM audio data at 16kHz mono');
}
const module = await this.getModule();
return module.getLipSync(pcmData, options.dialogText || "");
}
}
Rhubarb.wasmModule = null;