Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@speechly/react-client

Package Overview
Dependencies
Maintainers
6
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@speechly/react-client

React client for Speechly Streaming API

  • 2.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
526
decreased by-14.61%
Maintainers
6
Weekly downloads
 
Created
Source

speechly-logo-duo-black

Website  ·  Docs  ·  Support  ·  Blog  ·  Login


Speechly React Client

build npm license

With the Speechly React client you can add voice features to any React project. It handles authentication, audio capture, network streaming and connection management with the Speechly Streaming API.

Check out the react client example for an example app built using this client.

Before you start

Make sure you have created and deployed a Speechly application. Take note of the App ID, you'll need it shortly.

You'll also need a React app. Use your existing app, or create a new one using:

npx create-react-app my-app

Installation

Install Speechly React client:

npm install @speechly/react-client

Import SpeechProvider and wrap the app with it, passing the App ID of your Speechly application:

// index.js
import { SpeechProvider } from '@speechly/react-client';

<React.StrictMode>
  <SpeechProvider appId="YOUR_APP_ID">
    <App />
  </SpeechProvider>
</React.StrictMode>

See SpeechProviderProps for all available properties.

Usage

Import the useSpeechContext hook, create a button to initialize the microphone, another button for toggling the microphone and then display the transcript:

// App.js
import { useSpeechContext } from '@speechly/react-client';

function App() {
  const { segment, listening, attachMicrophone, start, stop } = useSpeechContext();

  return (
    <div className="App">
      <button onClick={attachMicrophone}>Initialize microphone</button>
      <button onPointerDown={start} onPointerUp={stop}>
        {listening ? 'Listening…' : 'Push to talk'}
      </button>
      <p>
        {segment && segment.words.map(word => word.value).join(' ')}
      </p>
    </div>
  );
}

Start the development server:

npm run start

Navigate to http://localhost:3000 to see your app running!

Documentation

Contributing

See contribution guide in CONTRIBUTING.md.

Keywords

FAQs

Package last updated on 31 Jan 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc