A powerful library for processing audio files and generating mouth shapes for lip-sync animations.
npm install lipsync-jsbash
npm install lipsync-js
`
Usage
Example Usage
`js
import processAudioFile from "lipsync-js";
// Accepts only WAV files
async function handleAudioFile(buffer) {
try {
// Call the processAudioFile with the WAV buffer
// and it will return the mouthCues
const mouthCues = await processAudioFile(buffer);
console.log(mouthCues);
} catch (err) {
console.error("Error processing audio file:", err);
}
}
`
The processAudioFile function returns an array of mouth cues with start and end times, and the corresponding mouth shape. This can be used to animate 3D avatars on the web.
Example Output:
`js
[
{ start: "0.00", end: "0.05", value: "closed mouth" },
{ start: "0.05", end: "0.27", value: "open mouth" },
{ start: "0.27", end: "0.31", value: "idle position" },
{ start: "0.31", end: "0.43", value: "idle position" },
{ start: "0.43", end: "0.47", value: "idle position" },
];
``