@surfmate.team/client-kit
v0.1.1
Published
Browser-side computation toolkit — domain-agnostic, zero-dependency. First module: audio (align/mix dialogue tracks, encode WAV, build silence) on the Web Audio engine. Data / calculation / action cleanly separated.
Maintainers
Readme
@surfmate.team/client-kit
Browser-side computation toolkit — domain-agnostic, zero-dependency. Pure calculations + thin Web Audio actions, layered the Grokking Simplicity way (data / calculation / action). First module: audio.
npm i @surfmate.team/client-kitaudio
import { buildDialogueTracks } from '@surfmate.team/client-kit/audio'
// Two single-person voices → three time-aligned WAV tracks for a
// two-person lip-sync dialogue (left speaks, 1s pause, right speaks).
const { left, right, full } = await buildDialogueTracks(leftBlob, rightBlob, { gapSec: 1 })
// left → audio_1 (drives the left person's mouth; speech at t=0, silence after)
// right → audio_2 (drives the right person; silence until the gap, then speech)
// full → the output soundtrack (both voices) + sets total length
// All three are the SAME length and aligned on one timeline.Lower-level pieces:
import { audioBufferToWav, buildSilenceWav, renderTimeline, timelineDuration } from '@surfmate.team/client-kit/audio'
buildSilenceWav(3) // 3s of silent mono 16 kHz WAV (calculation)
audioBufferToWav(audioBuffer) // AudioBuffer → 16-bit PCM WAV Blob (calculation)
renderTimeline(placements, total, sr) // place buffers on one track, render (action)Composes directly with @surfmate.team/digital-human-runninghub's
createRunningHubDialogueVideo — buildDialogueTracks produces exactly its
leftAudio / rightAudio / fullAudio inputs.
