Package detail

adaptive-speech-recognizer

nfreear128MIT2.2.0

Adaptive dictation-mode speech recognizer ponyfill compatible with WebChat that gives the user time to think and stutter/stammer.

microsoft, cognitiveservices, cognitive services, speech

readme

Test status NPM Version PAS 901:2025

adaptive-speech-recognizer

An adaptive dictation-mode speech recognizer ponyfill compatible with WebChat that gives the user time to think and stutter (stammer)!

Mastering 'endSilenceTimeoutMs' in Microsoft Speech SDK dictation mode!

(08-Oct-2020)

Basic usage

import 'ms-cognitive-speech-sdk';
import createAdaptiveRecognizerPonyfill from 'adaptive-speech-recognizer';

const ponyfill = createAdaptiveRecognizerPonyfill({
  subscriptionKey,
  region,
  endSilenceTimeoutMs
});

const recognizer = new ponyfill.SpeechRecognition();
recognizer.start();

Ponyfill

See Integrating with Cognitive Services Speech Services.

import { createAdaptiveRecognizerPonyfill } from 'adaptive-speech-recognizer';

const asrPonyfill = await createAdaptiveRecognizerPonyfill({ region, key });

// ... Combine speech synthesis from default
// 'createCognitiveServicesSpeechServicesPonyfillFactory()' ...

renderWebChat(
  {
    directLine: createDirectLine({ ... }),
    // ...
    webSpeechPonyfillFactory: await createCustomHybridPonyfill({ ... })
  },
  document.getElementById('webchat')
);

Dictation mode

The key lines in createCognitiveRecognizer to force dictation mode, and enable the setting of initialSilenceTimeoutMs and endSilenceTimeoutMs:

const initialSilenceTimeoutMs = 5 * 1000;
const endSilenceTimeoutMs = 5 * 1000;
// Scroll to right! → →
const url = `wss://${region}.stt.speech.microsoft.com/speech/recognition/dictation/cognitiveservices/v1?initialSilenceTimeoutMs=${initialSilenceTimeoutMs || ''}&endSilenceTimeoutMs=${endSilenceTimeoutMs}&`;
const urlObj = new URL(url);

const speechConfig = SpeechConfig.fromEndpoint(urlObj, subscriptionKey);

speechConfig.enableDictation();

// ...

const recognizer = new SpeechRecognizer(speechConfig, audioConfig);

Usage

npm install
npm start
npm test

Useful links

Credit

Developed in IET at The Open University for the ADMINS project, funded by Microsoft.


"ADMINS in IET: Assistants to the Disclosure and Management of Information about Needs and Support"

"Microsoft 'AI for Accessibility' projects, including ADMINS"

"PAS 901:2025 Vocal accessibility in system design. Code of practice"

"DOI: 10.3403/30458829"

"'createCognitiveRecognizer()' function, lines 527-540"

"Minimum/Maximum values for InitialSilence and EndSilence timeouts for java SDK (#502) (2020)"

changelog

Release Notes

Unreleased

  • (Date: ~ February-2021)
  • Adaptive recognition - personalize the endSilenceTimeoutMs mid-session enhancement (#13)
  • Fix: upgrade from speech SDK v1.13.1 to v1.15.1 (#14)

Version 2.0.0-Beta

  • Date: 23-November-2020.
  • Adaptive recognition — optionally, set a dictionary of "stop phrases" via a DOM event (#3)
  • Adaptive recognition — optionally, set an initial dictionary of "stop phrases" (#3)

Version 1.1.0-Beta

  • Date: 21-November-2020.
  • Fix support for Safari — getAudioConfig (#10)
  • Fix. Downgrade / use Speech SDK v1.13.1 — bug in 1.14.0 (#8)
  • Fix text normalization — remove full-stop (#11)

Version 1.0.0-Beta

Dictation-based speech recognizer ponyfill, compatible with WebChat.js

  • Date: 23-October-2020.
  • Version 1.0.0-Beta, as integrated in 'ADMINS-Bot' (23-October-2020)
  • Re-factor, influenced by compulim/web-speech-cognitive-services ~ createSpeechRecognitionPonyfill (#2),
  • Align DictationRecognizer class with Web API SpeechRecognition class (#1).