Skip to main content

Utilities

Helper functions and utilities for audio processing and module setup.

AudioConverter

Audio format conversion utilities for handling microphone input.

import { floatToPCM16, DEFAULT_RECORD_SAMPLE_RATE } from 'estuary-lens-studio-sdk';

floatToPCM16

Convert Float32Array audio samples to PCM16 bytes.

// Convert Float32Array to PCM16 bytes
const pcmBytes: Uint8Array = floatToPCM16(floatSamples);

Constants

const DEFAULT_RECORD_SAMPLE_RATE = 16000;   // STT sample rate
const DEFAULT_PLAYBACK_SAMPLE_RATE = 24000; // TTS sample rate

Module Functions

setInternetModule

Required for WebSocket connections in Lens Studio 5.9+. Must be called before creating any Estuary clients.

import { setInternetModule } from 'estuary-lens-studio-sdk';

// Call this in your component's onAwake
setInternetModule(internetModule);

Example:

@component
export class MyComponent extends BaseScriptComponent {
@input
internetModule: InternetModule;

onAwake() {
// MUST be called first
setInternetModule(this.internetModule);

// Now you can create clients
const client = new EstuaryClient();
}
}

getInternetModule

Retrieve the currently configured InternetModule.

import { getInternetModule } from 'estuary-lens-studio-sdk';

const module = getInternetModule();
if (module) {
// Module is configured
}

Type Exports

All types can be imported from the main module:

import {
// Core
EstuaryClient,
EstuaryConfig,
ConnectionState,
EventEmitter,

// Components
EstuaryManager,
EstuaryCharacter,
EstuaryCredentials,
EstuaryMicrophone,
IEstuaryCredentials,
IEstuaryMicrophoneController,
MicrophoneRecorder,

// Actions
EstuaryActionManager,
EstuaryActions,
ParsedAction,
RegisteredAction,

// Models
SessionInfo,
BotResponse,
BotVoice,
SttResponse,
InterruptData,

// Utilities
floatToPCM16,
setInternetModule,
getInternetModule,
} from 'estuary-lens-studio-sdk';