New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-audio-stream

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-audio-stream

`react-audio-stream` is a React library providing a custom hook for capturing audio streams from a user's microphone and sending them as Blob chunks at specified time intervals.

latest
Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
38
245.45%
Maintainers
1
Weekly downloads
 
Created
Source

react-audio-stream

react-audio-stream is a React library providing a custom hook for capturing audio streams from a user's microphone and sending them as Blob chunks at specified time intervals.

Installation

You can install react-audio-stream via npm or yarn:

npm install react-audio-stream

or

yarn add react-audio-stream

Usage

import React from 'react'
import { useAudioStream } from 'react-audio-stream'

const App = () => {
  const sendBlob = (data: Blob) => {
    // write your stream logic here.
    console.log(data)
  }
  const { startStream, stopStream } = useAudioStream(sendBlob)
  return (
    <div>
      <button
        onClick={() => {
          startStream()
        }}
      >
        start stream
      </button>
      <button
        onClick={() => {
          stopStream()
        }}
      >
        stop stream
      </button>
    </div>
  )
}

export default App

API

useAudioStream(sendBlob: (blob: Blob) => void, timeSlice?: number)

A custom React hook for capturing audio streams from a user's microphone and sending them as Blob chunks at specified time intervals.

Parameters

  • sendBlob: A function that handles the received blob chunks.
  • timeSlice: Optional. Time interval in milliseconds at which to slice the audio data. Default is 500.

Returns

An object with the following methods:

  • startStream(): Starts capturing audio stream.
  • stopStream(): Stops capturing audio stream.

Example

You can find an example usage of useAudioStream in the example directory.

License

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

Keywords

react-audio-stream

FAQs

Package last updated on 24 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts