Giter VIP home page Giter VIP logo

ringcentral-softphone-js's Introduction

RingCentral Softphone SDK for JavaScript

What are the differences between ringcentral-web-phone and this project?

ringcentral-web-phone is designed for client side and only works with browsers.

This project was originally designed for server and desktop. It doesn't require a browser to run. It could run in browser too.

Supported features:

  • Answer inbound call
  • Make outbound call
  • Speak and listen, two way communication
  • Call control features
    • Redirect inbound call to voicemail
    • Ignore inbound call

Demos

Install

yarn add ringcentral-softphone @rc-ex/core

For node.js you also need to:

yarn add ws wrtc

Usage

  • for node.js, check here
  • for browser, check here

Get realtime inbound audio

import { nonstandard } from 'wrtc'

softphone.once('track', e => {
  const audioSink = new nonstandard.RTCAudioSink(e.track)
  audioSink.ondata = data => {
    // here you have the `data`
  }
  softphone.once('BYE', () => {
    audioSink.stop()
  })
})

The data you got via audioSink.ondata is of the following structure:

{
  samples: Int16Array [ ... ],
  bitsPerSample: 16,
  sampleRate: 48000,
  channelCount: 1,
  numberOfFrames: 480,
  type: 'data'
}

Please note that, you may get different numbers, for example, sampleRate you get might be 16000 instead of 48000.

Official demos

Setup

yarn install
cp .env.sample .env

Edit .env file to specify credentials.

  • CALLEE_FOR_TESTING is a phone number to receive testing phone calls. You don't need to specify it if you do not make outbound calls.
  • If you have WEB_SOCKET_DEBUGGING=true, then all WebSocket traffic will be printed to console.

Run

  • for node.js yarn server
  • for browser yarn browser

Test

Make a phone call to the phone number you configured in .env file. The demo app will answer the call and you can speak and listen.

Interesting Use cases

Call supervision

Let's say there is a phone call ongoing between a customer and the call agent. You can use this library to supervise this phone call to get live audio stream. You can analyze the audio stream using some AI algorithm and provide tips to the call agent in real time.

Live transcription

Use this library to supervise an existing phone call to get live audio stream. Translate the audio stream into text by invoking some speech-to-text service. Show the text to the caller and/or callee so they can see live transcription.

Play recorded audio

You can create a program to make a phone call or answer a phone call and play recorded audio. This is good for announcement purpose. This is also good for quick voicemail drop. Or you can use text-to-speech service to read text to the callee.

Todo

  • How to create a publish message
  • How to forward a call

ringcentral-softphone-js's People

Contributors

tylerlong avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.