Last active
October 24, 2018 13:30
-
-
Save Rhincodon/359d78f2391350bb18fccfb164f21fa3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://speech-poc.awsext.berlitz.net/libs/speech-to-text.js"></script> | |
<!-- Azure Only --> | |
<script src="https://speech-poc.awsext.berlitz.net/libs/microsoft.cognitiveservices.speech.sdk.bundle.js"></script> | |
<script> | |
// INITIALIZATION | |
const speechToText = new SpeechToText(); | |
speechToText.addService('azure', new SpeechToTextAzure({ | |
key: 'key', | |
region: 'westus', | |
language: 'en-US' | |
})); | |
speechToText.addService('google', new SpeechToTextGoogle({ | |
socketUrl: 'https://some-url' | |
})); | |
speechToText.addService('browser', new SpeechToTextBrowserApi()); | |
speechToText.setCurrentService('azure'); | |
// or | |
speechToText.setServicePriority(['browser', 'azure', 'google']); | |
// USAGE | |
try { | |
speechToText.init(); // check microphone, throw exception if none of services works | |
} catch (e) { | |
// mic or services not working | |
} | |
speechToText.onResults = (text, isCorrect, isCorrectByAlternative) => { | |
// process results | |
} | |
speechToText.startRecognition({answer: 'Some Text', alternatives: ['alternative'], maxListenTime: 10}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment