X

API How-To

Web Dictation - JavaScript

Introduction

This How-To provides a quick jump-start for embedding nVoq medical dictation in web applications. It uses the nVoq WebSocket API and only requires a few simple additions to your html and/or JavaScript.

Before You Begin

API User Account

If your organization has not already been in contact with our Sales team, please complete this short form on the Developer Registration Page and we will reach out to you regarding a user account and development with our APIs.

Once you have an account, you must change your password before the account can be used for API calls.

Audio Format

The nVoq API supports ogg Vorbis, WebM, MPEG-4, and PCM encoded audio sampled at 16kHz.  For more information on Audio Formats, click here

Note: the best audio processing performance is when audio chunks are about 300ms long.

Try It!

Before getting started on implementation, initialize the web dictation library using the form below with the credentials you received from our sales or customer success team.




Topic: General Medicine







Put your cursor in the text area below, press F2 to start recording, dicate a medical note, then press F2 to stop recording. You will need to allow microphone access when prompted by your browser.

Let's Go!

The most straight forward way to illustrate the use of our Web Dictation JavaScript library is to look at the implementation of the sample dictation form you just used above.

Import Library

Download the nVoq dictation library from here. Then add it at the top of your document body tag:

    <script src="nVoqDictation.js"></script>

The Web Form

Here is html for the form shown above.

<form>
    <label for="dictationurl">URL:</label>
    <input type="text" id="dictationurl" name="dictation_url" value="wss://test.nvoq.com">
    Topic: General Medicine
    <label for="username">Username:</label>
    <input type="text" id="username" name="user_name">
    <label for="password">Password:</label>
    <input type="password" id="userpassword" name="user_password">
    <input id="loginButton" type="button" value="Initialize">
</form>
<!-- And a place to put the text -->
<form>
  <textarea id="msg" name="user_message" cols="80" rows="5"></textarea>
</form>				     

Initialization

Initialization is performed in response to clicking the authorization button above. The JavaScript code below initializes the dictation engine, registers for the hot-key, and prepares for dictation.

  var loginBtn = document.getElementById("loginButton");
  loginBtn.addEventListener('click', dictationLogin);

  function dictationLogin() {

  var aUrl = document.getElementById("dictationurl").value;
  var aUsername = document.getElementById("username").value;
  var aPassword = document.getElementById("userpassword").value;
  nVoqAPI.init({ 
            url: aUrl,
            username: aUsername, 
            password: aPassword,
            //apikey: "",
            //api or password can be used, but not both
            dictationTopic: "general_medicine",
            dictationHotkey: "F2",
        });
  }

Dictate

Once these elements are included in your web app, you should be able to refresh/reload and perform a dictation by placing your cursor in the text area and pressing the hotkey.

If you have any questions, please reach out to support@nvoq.com.

© 2024 nVoq Inc. | Privacy Policy