1.0.6 • Published 4 years ago

@gkt/transcriber v1.0.6

Weekly downloads
258
License
Apache-2.0
Repository
github
Last release
4 years ago

@gkt/transcriber

@gkt/transcriber is a JavaScript library for performing voice transcriptions via GreenKey's backend services.

Installation

$ npm install @gkt/transcriber 

Or via unpkg.com:

<script type="text/javascript" src="https://unpkg.com/@gkt/transcriber"></script>

Usage

// es6 module
import Transcriber from '@gkt/transcriber';

// common js module
// const Transcriber = require('@gkt/transcriber');

// script tag
// const Transcriber = window.Transcriber;

// Provide a base URL that is proxied to your GreenKey backend instance
const transcriber = new Transcriber({gkUrl: '/greenkey'});

// This will prompt the user for access to the microphone
transcriber.init().then(function() {
  // Register a callback for transcription data. Updates will be emitted periodically while a
  // transcription is active. A final data object will be emitted after the transcription is stopped
  // and is indicated by the `data.final` property.
  transcriber.on(Transcriber.TRANSCRIBER_DATA_RECEIVED, function(t, data) {
    console.log(data);
  });

  // Start recording audio data from the microphone and send it to the GreenKey backend for
  // processing.
  transcriber.start();

  // Stop recording audio data.
  transcriber.stop();
});

Processing Results

Transcriptions are produced in real time and communicated to the client via the Transcriber.TRANSCRIBER_DATA_RECEIVED event. The first argument to the event handler is the transcriber instance and the second is an object containing the current result of the transcription. The following top-level fields are included:

FieldTypeDescription
sessionstringA unique identifier for the transcription session
finalbooleanIndicates whether this is the final version of the transcript
clockStartstring (ISO8601 date)The time the transcription recording started
segmentsarray of objectsA list of segment objects

And the segments array contains objects with these fields:

FieldTypeDescription
finalbooleanIndicates whether this segment is finished processing
startTimeSecnumberThe offset in seconds from clockStart where the segment audio started
endTimeSecnumberThe offset in seconds from clockStart where the segment audio ended
transcriptstringThe text of the raw transcript
interpreted_quoteobjectPresent when a quote is detected in the transcript
interpreted_quote.imStringstringThe generated IM String of the detected quote
interpreted_quote.productClass.labelstringThe product class of the detected quote
wordsarrayA list of transcript works with confidence levels

Example Apps

Some example apps are provided in the examples directory. Edit the .html files to set the gkUrl variable to your GreenKey instance before opening in a browser.

The examples are full apps that send audio data recorded from the microphone, receive transcription results and display them.

Notes

This library uses the MediaDevices.getUserMedia() API for gaining access to the user's microphone hardware. This API is only available in secure contexts, so your application must be served over HTTPS in order for it to work.

Publishing

To publish a new version, update the version field in the package.json file and run:

$ npm publish --access public

This will automatically apply a git tag matching the version and push it.

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago