@mymusictaste/async-audiorecorder
Version:
node-audiorecorder with async/await & typescript support
61 lines (52 loc) • 1.54 kB
TypeScript
declare module "node-audiorecorder" {
import { EventEmitter } from "events";
import { SpawnOptions } from "child_process";
import { Readable } from "stream";
export type AudioRecorderOptions = {
program?: "rec" | "arecord" | "sox";
device?: string | null;
driver?: string | null;
bits?: number;
channels?: number;
encoding?: string;
format?: string;
rate?: number;
type?: string;
silence?: number;
thresholdStart?: number;
thresholdStop?: number;
keepSilence?: boolean;
};
export type Logger = Pick<Console, "log" | "warn" | "error">;
class AudioRecorder extends EventEmitter {
/**
* Constructor of AudioRecord class.
* @param {Object} options Object with optional options variables
* @param {Object} logger Object with log, warn, and error functions
* @returns {AudioRecorder} this
*/
constructor(options?: AudioRecorderOptions, logger?: Logger);
/**
* Creates and starts the audio recording process.
*/
start(): this;
/**
* Stops and removes the audio recording process.
*/
stop(): this;
/**
* Get the audio stream of the recording process.
*/
stream(): Readable | null;
readonly options: AudioRecorderOptions;
readonly logger?: Logger;
private _childProcess:
| import("child_process").ChildProcessWithoutNullStreams
| null;
private _command: {
arguments: string[];
options: SpawnOptions;
};
}
export default AudioRecorder;
}