npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@igoratron/aws-transcribe

v1.0.3

Published

A client for Amazon Transcribe using the websocket interface

Downloads

5

Readme

AWS Transcribe

A client for Amazon Transcribe using the websocket interface

Getting Started

With NPM install the module with: npm install aws-transcribe --save
With YARN install the module with: yarn add aws-transcribe

Example

An example of streaming from microphone can be found in src/examples/stream-from-microphone.ts

import { AwsTranscribe, StreamingClient } from "aws-transcribe"

const client = new AwsTranscribe({
    // if these aren't provided, they will be taken from the environment
    accessKeyId: "ACCESS KEY HERE",
    secretAccessKey: "SECRET KEY HERE",
})

const transcribeStream = client
    .createStreamingClient({
        region: "eu-west-1",
        sampleRate: 16000,
        languageCode: "en-US",
    })
    // enums for returning the event names which the stream will emit
    .on(StreamingClient.EVENTS.OPEN, () => console.log(`transcribe connection opened`))
    .on(StreamingClient.EVENTS.ERROR, console.error)
    .on(StreamingClient.EVENTS.CLOSE, () => console.log(`transcribe connection closed`))
    .on(StreamingClient.EVENTS.DATA, (data) => {
        const results = data.Transcript.Results

        if (!results || results.length === 0) {
            return
        }

        const result = results[0]
        const final = !result.IsPartial
        const prefix = final ? "recognized" : "recognizing"
        const text = result.Alternatives[0].Transcript
        console.log(`${prefix} text: ${text}`)
    })

yourStream.pipe(transcribeStream)

API

new AwsTranscribe(clientConfig)

This creates a service wrapper which can then be used to create a streaming client

The clientConfig is optional and can be provided with the following properties:

  • accessKeyId if not provided, the package will look for AWS_ACCESS_KEY_ID environment variable
  • secretAccessKey if not provided, the package will look for AWS_SECRET_ACCESS_KEY environment variable

AwsTranscribe.createStreamingClient(transcribeStreamConfig)

This will create a presigned url using the config and return an instance of StreamingClient which is a wrapper around the websocket. It will decode binary messages coming from AWS and encode messages to binary when sending them

The transcribeStreamConfig is required and must have the following properties:

  • region must be one of "us-east-1", "us-east-2", "us-west-2", "ap-southeast-2", "ca-central-1", "eu-west-1"
  • languageCode must be one of "en-US", "en-AU", "en-GB", "fr-CA", "fr-FR", "es-US"
  • sampleRate must be between 8000 and 44100 - the supported sample rate differs depending on the language code being used. For more information, go here

StreamingClient EVENTS

  • open - when the socket to aws is opened
  • error - any errors sent as part of websocket message or websocket error
  • data - emits the transcription object
  • close - when the socket to aws closes

Debugging

set environment variable to below when running your application.

DEBUG=aws-transcribe:\*

Issues

If you discover a bug, please raise an issue on Github. https://github.com/qasim9872/aws-transcribe/issues

Contribution

Pull requests are very welcome. Please:

  • ensure all tests pass before submitting PR
  • add tests for new features
  • document new functionality/API additions in README.md

License

Copyright (c) 2020 Muhammad Qasim. Licensed under the MIT license.