Giter Club home page Giter Club logo

bingspeech-api-client's Introduction

bingspeech-api-client

A Microsoft Bing Speech API client written in node.js.

Official documentation for Bing Speech API service.

To work with Bing Speech API, you must have a subscription key. If you don't have a subscription key already, get one here: Subscriptions.

Usage

Install bingspeech-api-client in your node project with npm.

npm install -save bingspeech-api-client

See example below on how to require and use for Speech to text (STT) and text to speech (TTS).

Examples

Following example code is assuming you are using typescript. If you are, skip this section and go straight to the examples. But if you are using node ES6 and want to use the example code read on.

At present node does not support import. As mentioned on MDN

Note: This feature[import] is only beginning to be implemented in browsers natively at this time. It is implemented in many transpilers, such as the Traceur Compiler, Babel, Rollup or Webpack.

To get the example code working change the first line to:

const { BingSpeechClient, VoiceRecognitionResponse } = require('bingspeech-api-client');

Usage with streams

STT usage example (recognize)

import { BingSpeechClient, VoiceRecognitionResponse } from 'bingspeech-api-client';

let audioStream = fs.createReadStream(myFileName); // create audio stream from any source

// Bing Speech Key (https://www.microsoft.com/cognitive-services/en-us/subscriptions)
let subscriptionKey = 'your_private_subscription_key';

let client = new BingSpeechClient(subscriptionKey);
client.recognizeStream(audioStream).then(response => console.log(response.results[0].name));

TTS usage example (synthesize)

import { BingSpeechClient, VoiceVoiceSynthesisResponse } from 'bingspeech-api-client';

// Bing Speech Key (https://www.microsoft.com/cognitive-services/en-us/subscriptions)
let subscriptionKey = 'your_private_subscription_key';

let client = new BingSpeechClient(subscriptionKey);
client.synthesizeStream('I have a dream').then(audioStream => /* ... */);

Usage with buffers (deprecated, will be removed in 2.x)

STT usage example (recognize)

import { BingSpeechClient, VoiceRecognitionResponse } from 'bingspeech-api-client';

// audio input in a Buffer
let wav = fs.readFileSync('myaudiofile.wav');

// Bing Speech Key (https://www.microsoft.com/cognitive-services/en-us/subscriptions)
let subscriptionKey = 'your_private_subscription_key';

let client = new BingSpeechClient(subscriptionKey);
client.recognize(wav).then(response => console.log(response.results[0].name));

TTS usage example (synthesize)

import { BingSpeechClient, VoiceVoiceSynthesisResponse } from 'bingspeech-api-client';

// Bing Speech Key (https://www.microsoft.com/cognitive-services/en-us/subscriptions)
let subscriptionKey = 'your_private_subscription_key';

let client = new BingSpeechClient(subscriptionKey);
client.synthesize('I have a dream').then(response => { /* audio is a Buffer in response.wave */ });

bingspeech-api-client's People

Contributors

carlousf avatar jantielens avatar marcbachmann avatar morphet81 avatar palmerabollo avatar pietrop avatar

Watchers

 avatar  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.