0.1.0 • Published 6 months ago

react-microphone-recorder1 v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

react-microphone-recorder

A convenient and powerful React hook and component for audio recording with customizable options and audio levels.

recorder-demo.gif

Live Demo

Deploy with Vercel

Table of Contents

Features

  1. useRecorder - A React hook that provides audio recording functionalities and exposes several useful properties.
  2. RecordAudio - A pre-built, beautifully designed React component for audio recording.
  3. Full TypeScript support.

Installation

Using npm:

npm install react-microphone-recorder

Or using yarn:

yarn add react-microphone-recorder

Usage

useRecorder

import { useRecorder } from 'react-microphone-recorder';

function MyComponent() {
  const { audioLevel, startRecording, pauseRecording, stopRecording, resetRecording, time, audioURL, recordingState, isRecording, audioFile } = useRecorder();

  // use these values in your component
}

Properties exposed by useRecorder:

  • audioLevel: A floating-point number that changes with the microphone audio recording levels as the user starts recording.
  • startRecording, pauseRecording, stopRecording, resetRecording, resumeRecording: Functions to control the recording.
  • timeElapsed: A number that represents the time elapsed since the recording started.
  • recordingState: A string that represents the current recording state. Can be one of "idle", "recording", "stopped", "paused".
  • isRecording: A boolean that indicates whether the recording is currently active.
  • audioURL: A string that holds the URL of the recorded audio. recordingState: A string that represents the current recording state. Can be one of "idle", "recording", "stopped", "paused".
  • isRecording: A boolean that indicates whether the recording is currently active.
  • audioFile: A File object that represents the recorded audio in "mp3" format.
  • audioBlob: A Blob object that represents the recorded audio in mp3 format. audioFile, audioURL are created from this blob.

RecordAudio

Simply import the RecordAudio component and all you need to do is pass the audioFile property to it. The component will take care of the rest.

import { RecordAudio } from 'react-microphone-recorder'

function MyComponent() {
  // ... get audioURL and audioFile ...
  const [audioFile, setAudioFile] = (useState < File) | (undefined > undefined)

  return <RecordAudio audioFile={audioFile} />
}

RecordAudio

Warning The RecordAudio component is styled using Tailwind CSS. It's important to note that the styles will only be correctly applied if your project is set up with Tailwind CSS. If your project does not use Tailwind CSS, the component will still function correctly, but it will not have the intended visual style. If you are not using Tailwind CSS and still want to use the RecordAudio component, you may need to manually adjust the styles to suit your project's styling solution. Alternatively, consider setting up Tailwind CSS in your project, which can be done following the instructions on the official Tailwind CSS documentation.

Note Use useRecorder if you want to build your own custom UI for audio recording.

Contributing

Contributions are welcome! Please open an issue or submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

ababacornacorn-globalsacorn-jsxacorn-walkagent-baseajvansi-escapesansi-regexansi-stylesanymatchargparsearia-queryarray-buffer-byte-lengtharray-includesarray-unionarray.prototype.flatmaparray.prototype.tosortedasynckitavailable-typed-arraysbabel-jestbabel-plugin-istanbulbabel-plugin-jest-hoistbabel-preset-current-node-syntaxbabel-preset-jestbalanced-matchbrace-expansionbracesbrowserslistbs-loggerbserbuffer-fromcall-bindcallsitescamelcasecaniuse-litechalkchar-regexci-infocjs-module-lexercliuicocollect-v8-coveragecolor-convertcolor-namecombined-streamconcat-mapconvert-source-mapcross-spawncss.escapecssfontparsercssomcssstylecsstypedata-urlsdebugdecimal.jsdedentdeep-equaldeep-isdeepmergedefine-propertiesdelayed-streamdetect-newlinediff-sequencesdir-globdoctrinedom-accessibility-apidomexceptionelectron-to-chromiumemitteryemoji-regexentitieserror-exes-abstractes-get-iteratores-set-tostringtages-shim-unscopableses-to-primitiveescaladeescape-string-regexpescodegeneslint-scopeeslint-visitor-keysespreeesprimaesqueryesrecurseestraverseesutilsexecaexitexpectfast-deep-equalfast-difffast-globfast-json-stable-stringifyfast-levenshteinfastqfb-watchmanfile-entry-cachefill-rangefind-upflat-cacheflattedfor-eachform-datafs.realpathfseventsfunction-bindfunction.prototype.namefunctions-have-namesgensyncget-caller-fileget-intrinsicget-package-typeget-streamget-symbol-descriptionglobglob-parentglobalsglobalthisglobbygopdgraceful-fsgrapheme-splitterhashas-bigintshas-flaghas-property-descriptorshas-protohas-symbolshas-tostringtaghtml-encoding-snifferhtml-escaperhttp-proxy-agenthttps-proxy-agenthuman-signalsiconv-liteignoreimport-freshimport-localimurmurhashindent-stringinflightinheritsinternal-slotis-argumentsis-array-bufferis-arrayishis-bigintis-boolean-objectis-callableis-core-moduleis-date-objectis-extglobis-fullwidth-code-pointis-generator-fnis-globis-mapis-negative-zerois-numberis-number-objectis-path-insideis-potential-custom-element-nameis-regexis-setis-shared-array-bufferis-streamis-stringis-symbolis-typed-arrayis-weakmapis-weakrefis-weaksetisarrayisexeistanbul-lib-coverageistanbul-lib-instrumentistanbul-lib-reportistanbul-lib-source-mapsistanbul-reportsjest-changed-filesjest-circusjest-clijest-configjest-diffjest-docblockjest-eachjest-environment-nodejest-get-typejest-haste-mapjest-leak-detectorjest-matcher-utilsjest-message-utiljest-mockjest-pnp-resolverjest-regex-utiljest-resolvejest-resolve-dependenciesjest-runnerjest-runtimejest-snapshotjest-utiljest-validatejest-watcherjest-workerjs-sdsljs-tokensjs-yamljsdomjsescjson-parse-even-better-errorsjson-schema-traversejson-stable-stringify-without-jsonifyjson5jsx-ast-utilskleurlevenlevnlines-and-columnslocate-pathlodashlodash.memoizelodash.mergeloose-envifylru-cachelz-stringmake-dirmake-errormakeerrormerge-streammerge2micromatchmime-dbmime-typesmimic-fnmin-indentminimatchmoo-colormsnatural-comparenatural-compare-litenode-int64node-releasesnormalize-pathnpm-run-pathnwsapiobject-assignobject-inspectobject-isobject-keysobject.assignobject.entriesobject.fromentriesobject.hasownobject.valuesonceonetimeoptionatorp-limitp-locatep-tryparent-moduleparse-jsonparse5path-existspath-is-absolutepath-keypath-parsepath-typepicocolorspicomatchpiratespkg-dirprelude-lsprettier-linter-helperspretty-formatpromptsprop-typespslpunycodepure-randquerystringifyqueue-microtaskreact-isredentregenerator-runtimeregexp.prototype.flagsrequire-directoryrequires-portresolveresolve-cwdresolve-fromresolve.exportsreusifyrimrafrun-parallelsafe-regex-testsafer-buffersaxesschedulersemvershebang-commandshebang-regexside-channelsignal-exitsisteransislashsource-mapsource-map-supportsprintf-jsstack-utilsstop-iteration-iteratorstring-lengthstring-widthstring.prototype.matchallstring.prototype.trimstring.prototype.trimendstring.prototype.trimstartstrip-ansistrip-bomstrip-final-newlinestrip-indentstrip-json-commentssupports-colorsupports-preserve-symlinks-flagsymbol-treetest-excludetext-tabletmplto-fast-propertiesto-regex-rangetough-cookietr46tsutilstype-checktype-detecttype-festtyped-array-lengthunbox-primitiveuniversalifyupdate-browserslist-dburi-jsurl-parsev8-to-istanbulw3c-xmlserializerwalkerwebidl-conversionswhatwg-encodingwhatwg-mimetypewhatwg-urlwhichwhich-boxed-primitivewhich-collectionwhich-typed-arrayword-wrapwrap-ansiwrappywrite-file-atomicwsxml-name-validatorxmlcharsy18nyallistyargsyargs-parseryocto-queue
0.1.0

6 months ago