# aws-transcribe

> A client for Amazon Transcribe using the websocket interface

Latest version **1.1.1** (published 2021-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install aws-transcribe
pnpm add aws-transcribe
yarn add aws-transcribe
bun add aws-transcribe
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2021-01-10 |
| First published | 2020-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 42.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Muhammad Qasim |
| Maintainers | qasim9872 |
| Keywords | amazon, aws, transcribe, speech, transcription, websocket |

## Links

- npm: https://www.npmjs.com/package/aws-transcribe
- Repository: https://github.com/qasim9872/aws-transcribe
- Homepage: https://github.com/qasim9872/aws-transcribe#readme
- Issues: https://github.com/qasim9872/aws-transcribe/issues
- npm.io page: https://npm.io/package/aws-transcribe

## Dependencies (6)

- [ws](https://npm.io/package/ws.md) ^7.2.3
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [query-string](https://npm.io/package/query-string.md) ^6.11.1
- [@aws-sdk/util-utf8-node](https://npm.io/package/@aws-sdk/util-utf8-node.md) 0.1.0-preview.1
- [@aws-sdk/eventstream-marshaller](https://npm.io/package/@aws-sdk/eventstream-marshaller.md) 0.1.0-preview.2

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2021-01-10
- 1.0.2-0 (next) — 2020-03-30
- 1.1.0 — 2020-05-13
- 1.0.1-1 — 2020-03-29
- 1.0.1-0 — 2020-03-28
- 1.0.0 — 2020-03-28

## README

# AWS Transcribe

A client for Amazon Transcribe using the websocket interface

> **_WARNING:_** This module is now deprecated and will no longer be maintained. Please use the official package provided by amazon, it can be found [here](https://www.npmjs.com/package/@aws-sdk/client-transcribe)

## 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

```typescript
import { AwsTranscribe, StreamingClient, TranscriptEvent } 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: TranscriptEvent) => {
        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](https://docs.aws.amazon.com/transcribe/latest/dg/streaming.html)

It may also optionally include:

-   `showSpeakerLabel` - when `true`, [speaker identification](https://docs.aws.amazon.com/transcribe/latest/dg/diarization-streaming.html) will be enabled

### 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.

```cli
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.

---
_Source: https://npm.io/package/aws-transcribe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
