UNPKG

@coze/uniapp-api

Version:

Official Coze UniApp SDK for seamless AI integration into your applications | 扣子官方 UniApp SDK,助您轻松集成 AI 能力到应用中

100 lines (99 loc) 2.32 kB
/** * PcmRecorder for WeChat Mini Program * Records audio using the uni.getRecorderManager API and provides PCM data */ /** * Recording status types */ export declare enum RecordingStatus { IDLE = "idle", RECORDING = "recording", PAUSED = "paused" } /** * Configuration options for PcmRecorder */ export interface PcmRecorderConfig { /** * Sample rate for audio recording (default: 16000) */ sampleRate?: number; /** * Enable debug logging */ debug?: boolean; } /** * PcmRecorder class for WeChat Mini Program * Simplified version without AI denoising and other advanced features */ export declare class PcmRecorder { /** * The recorder manager instance from uni API */ private recorderManager; /** * Current recording status */ private status; /** * Callback function for PCM audio data */ private pcmAudioCallback; /** * Configuration for the recorder */ private config; /** * Creates a new PcmRecorder instance * @param {PcmRecorderConfig} config - Configuration options */ constructor(config?: PcmRecorderConfig); /** * Set up event listeners for the recorder manager * @private */ private setupEventListeners; /** * Start recording audio */ start(): void; /** * Start recording and register callbacks * @param {object} params - Parameters containing callbacks * @param {function} params.pcmAudioCallback - Callback for PCM audio data */ record({ pcmAudioCallback, }?: { pcmAudioCallback?: (data: { raw: ArrayBuffer; }) => void; }): void; /** * Pause recording temporarily */ pause(): void; /** * Resume recording after pause */ resume(): void; /** * Stop recording and clean up resources */ destroy(): void; /** * Get current recording status * @returns {string} - Current status: 'idle', 'recording', or 'paused' */ getStatus(): string; /** * Get current sample rate * @returns {number} - Sample rate in Hz */ getSampleRate(): number; /** * Log messages when debug is enabled * @private */ private log; } export default PcmRecorder;