Giter Site home page Giter Site logo

nfreear / dictation Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 203 KB

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

License: MIT License

HTML 6.87% JavaScript 86.63% CSS 2.34% TypeScript 4.16%
speech sdk webchat recognition web-api stammer stutter adaptive asr

dictation's Introduction

Test status

@nfreear/speech-dictation

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)

Ponyfill

See Integrating with Cognitive Services Speech Services.

import { createDictationRecognizerPonyfill } from './createDictationRecognizerPonyfill.js';

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

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

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

Dictation mode

The key lines in createDictationRecognizerPonyfill 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.


dictation's People

Contributors

nfreear avatar

Watchers

 avatar  avatar  avatar

dictation's Issues

Open-source the project / repo.

Hi,

Here are the steps which I think need to be taken to open-source this project / repo :~

Best of luck!


Compare with:

feat: Personalize / adapt / change the `endSilenceTimeoutMs` mid-session

Dispatch and handle a custom setTimeout event ... recreate the internal speech recognizer in mid-session ...

Dispatch setTimeout event

    const timeoutEvent = new Event('recognition:set_timeout');
    timeoutEvent.data = { endSilenceTimeoutMs, text };

    window.dispatchEvent(timeoutEvent);

Recreate speech recognizer

    PRIV.resetRecognizer = async () => {
          if (PRIV.setTimeoutEvent) {
            // ...

            const { recognizer, OPT } = await createRecognizer(resetOpt);

            // ...
          }
    };

See :~ compulim/web-speech-cognitive-services@038dccb ~ recognizer.dispose() ~ 05-Dec-2018;

..

Re-factor, influenced by 'compulim/web-speech-cognitive-services' ~ 'createSpeechRecognitionPonyfill'

..


import { SpeechRecognizer } from 'SpeechSDK';

function createSpeechRecognitionFromRecognizer (recognizer: SpeechRecognizer): SpeechRecognition {

  class SpeechRecognition extends EventTarget { // Web API definition!
    // TODO ...!
  }

  return SpeechRecognition;
}

function createCognitiveRecognizer (options: DictationOptions): SpeechRecognizer {
  // ...

  const recognizer = new SpeechRecognizer(); // MS Azure SpeechSDK

  return recognizer;
}

export function createDictationRecognizerPonyfill (options: DictationOptions): Ponyfill {
  const recognizer = createCognitiveRecognizer(options);

  const SpeechRecognition = createSpeechRecognitionFromRecognizer(recognizer);

  return {
    SpeechGrammarList,
    SpeechRecognition
  }
}

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.