UNPKG

tauri-plugin-mic-recorder-api

Version:

Supports recording audio using a microphone and saving the recorded data as a file.

40 lines (37 loc) 898 B
import { invoke } from '@tauri-apps/api/core'; const COMMAND = { START_RECORDING: "plugin:mic-recorder|start_recording", STOP_RECORDING: "plugin:mic-recorder|stop_recording", }; /** * Starts recording audio. * * @example * ``` * import { startRecording } from 'tauri-plugin-mic-recorder-api'; * * startRecording().then(() => { * console.log("Recording started"); * }); * ``` */ const startRecording = () => { return invoke(COMMAND.START_RECORDING); }; /** * Stops recording audio. * * @returns Returns the path where the recording file is stored. * * @example * ``` * import { stopRecording } from 'tauri-plugin-mic-recorder-api'; * * const savePath = await stopRecording(); * console.log("Recording saved at:", savePath); * ``` */ const stopRecording = () => { return invoke(COMMAND.STOP_RECORDING); }; export { COMMAND, startRecording, stopRecording };