/** * TensorFlow.js integration for neural network-based pitch detection * Handles model loading, inference, and tensor management */ import * as tf from '@tensorflow/tfjs'; /** * Model loading options */ export interface ModelLoadOptions { modelUrl?: string; backend?: 'cpu' | 'webgl' | 'wasm'; warmup?: boolean; } /** * Inference result with predictions and confidence */ export interface InferenceResult { predictions: Float32Array; confidence: number; activations?: tf.Tensor; } /** * TensorFlow.js model manager */ export declare class TFJSModelManager { private model; private backend; private isInitialized; /** * Initialize TensorFlow.js with specified backend */ initialize(backend?: 'cpu' | 'webgl' | 'wasm'): Promise; /** * Load a model from URL */ loadModel(modelUrl: string, options?: ModelLoadOptions): Promise; /** * Run inference on input data */ predict(input: Float32Array | tf.Tensor): Promise; /** * Run inference and return Float32Array */ predictArray(input: Float32Array, shape?: number[]): Promise; /** * Batch prediction for multiple inputs */ predictBatch(inputs: Float32Array[]): Promise; /** * Get model input shape */ getInputShape(): number[] | null; /** * Get model output shape */ getOutputShape(): number[] | null; /** * Warmup model with dummy input */ private warmup; /** * Get memory info */ getMemoryInfo(): tf.MemoryInfo; /** * Dispose model and free memory */ dispose(): void; /** * Check if model is loaded */ isLoaded(): boolean; /** * Get current backend */ getBackend(): string; } /** * Tensor utilities for preprocessing and postprocessing */ export declare class TensorUtils { /** * Normalize audio to [-1, 1] range as tensor */ static normalizeTensor(tensor: tf.Tensor): tf.Tensor; /** * Apply mean normalization to tensor */ static meanNormalize(tensor: tf.Tensor): tf.Tensor; /** * Convert Float32Array to batched tensor */ static toBatchedTensor(data: Float32Array, batchSize?: number): tf.Tensor; /** * Apply softmax to get probability distribution */ static softmax(tensor: tf.Tensor): tf.Tensor; /** * Get argmax (index of maximum value) */ static argmax(tensor: tf.Tensor): Promise; /** * Get top-k indices and values */ static topK(tensor: tf.Tensor, k?: number): Promise<{ indices: number[]; values: number[]; }>; /** * Dispose multiple tensors */ static disposeTensors(...tensors: (tf.Tensor | null | undefined)[]): void; } /** * Helper: Create model manager with auto-initialization */ export declare function createModelManager(modelUrl: string, options?: ModelLoadOptions): Promise; /** * Export TensorFlow.js for direct access if needed */ export { tf };