UNPKG

react-native-live-audio-record

Version:
68 lines (60 loc) 1.93 kB
declare module "react-native-live-audio-record" { export type AudioEvent = "data" | "recordingState" | "error"; export type EventCallback<T> = (data: T) => void; export interface AudioEventDataMap { data: string; recordingState: { isRecording: boolean }; error: { error: string }; } export interface IAudioRecord { init: (options: Options) => void; start: () => Promise<string>; stop: () => Promise<string>; on: <T extends AudioEvent>(event: T, callback: EventCallback<T extends keyof AudioEventDataMap ? AudioEventDataMap[T] : any>) => void; addListener: <T extends AudioEvent>(event: T, callback: EventCallback<T extends keyof AudioEventDataMap ? AudioEventDataMap[T] : any>) => void; removeListener: (event: AudioEvent) => void; removeAllListeners: () => void; } export type AudioChannel = 1 | 2; export type AudioBitsPerSample = 8 | 16; export interface Options { /** * - `44100 | 22050 | 16000 | 11025` * Default: `44100` */ sampleRate: number; /** * - 1: AudioFormat.CHANNEL_IN_MONO * - 2: AudioFormat.CHANNEL_IN_STEREO * Default: `1` */ channels: AudioChannel; /** * - 8: AudioFormat.ENCODING_PCM_8BIT * - 16: AudioFormat.ENCODING_PCM_16BIT * Default: `16` */ bitsPerSample: AudioBitsPerSample; /** * - 6: VOICE_RECOGNITION */ audioSource?: number; wavFile: string; bufferSize?: number; /** * Title for the notification shown when recording in background */ notificationTitle?: string; /** * Content text for the notification shown when recording in background */ notificationContent?: string; /** * Icon for the notification shown when recording in background * Default: `ic_notification` */ notificationIcon?: string; } const AudioRecord: IAudioRecord; export default AudioRecord; }