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

react-audio-streamer

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-audio-streamer

A React package for bidirectional audio streaming with WebSockets using a control button.

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
0
-100%
Maintainers
0
Weekly downloads
 
Created
Source

react-audio-streamer

Table of Contents

  • How to Use

How to Use

  • AudioStreamerButton

    • The AudioStreamerButton component is used for audio recording and streaming.

    • It is clickable and toggles the recording state.

    • This component connects to a WebSocket server to stream real-time audio.

    • Parameters

      • ParameterTypeDescriptionDefault
        wsEndpointstringWebSocket URL for audio stream (required)-
        onTogglefunctionCallback function triggered when the button is clicked. It receives true when recording starts and false when it stops.-
        sampleRatenumberSample rate for audio recording (optional)24000
        bufferSizenumberBuffer size for audio recording (optional)4800
    • React Example

      • Use the component in a React app as shown below:

        import { AudioStreamerButton } from 'react-audio-streamer';
        import { useState } from 'react';
        
        const App = () => {
          const [isRecording, setIsRecording] = useState(false);
        
          const handleSetRecording = (isRecording) => {
            console.log('Recording state:', isRecording);
            setIsRecording(isRecording);
          };
        
          return (
            <button
              style={{
                position: 'relative', // needs to be set relative
                backgroundColor: isRecording ? 'red' : 'gray',
                color: 'white',
                padding: '10px 20px',
                border: 'none',
                borderRadius: '5px',
                cursor: 'pointer',
              }}
            >
              <AudioStreamerButton
                wsEndpoint="ws://localhost:8766/realtime"
                onToggle={handleSetRecording}
                sampleRate={25000}
              />
              {'microphone'}
            </button>
          );
        };
        
        export default App;
        
    • Caveats

      • The AudioStreamerButton should always be inside a button with the position: relative style.
      • This ensures proper layout and functionality.

Keywords

react

FAQs

Package last updated on 20 Jan 2025

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