Skip to content

Commit

Permalink
feat: update websocket to use w3cwebsocket for node/browser/edge work…
Browse files Browse the repository at this point in the history
…er examples (#205)
  • Loading branch information
lukeocodes authored Nov 22, 2023
1 parent d2d94d4 commit a75db1f
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 64 deletions.
70 changes: 68 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@

Official JavaScript SDK for [Deepgram](https://www.deepgram.com/). Power your apps with world-class speech and Language AI models.

- [Migrating from v2](#migrating-from-v2)
- [Installation](#installation)
- [UMD](#umd)
- [ESM](#esm)
- [Initialization](#initialization)
- [Getting an API Key](#getting-an-api-key)
- [Scoped Configuration](#scoped-configuration)
- [Rest requests in the browser](#rest-requests-in-the-browser)
- [Transcription](#transcription)
- [Transcription (Synchronous)](#transcription-synchronous)
- [Remote Files](#remote-files)
- [Local Files](#local-files)
- [Transcription (Asynchronous / Callbacks)](#transcription-asynchronous--callbacks)
- [Remote Files](#remote-files-1)
- [Local Files](#local-files-1)
- [Transcription (Live / Streaming)](#transcription-live--streaming)
- [Live Audio](#live-audio)
- [Transcribing to captions](#transcribing-to-captions)
- [Projects](#projects)
Expand Down Expand Up @@ -51,8 +56,13 @@ Official JavaScript SDK for [Deepgram](https://www.deepgram.com/). Power your ap
- [Create On-Prem credentials](#create-on-prem-credentials)
- [Delete On-Prem credentials](#delete-on-prem-credentials)
- [Development and Contributing](#development-and-contributing)
- [Debugging and making changes locally](#debugging-and-making-changes-locally)
- [Getting Help](#getting-help)

# Migrating from v2

We have published [a migration guide on our docs](https://developers.deepgram.com/docs/js-sdk-v2-to-v3-migration-guide), showing how to move from v2 to v3.

# Installation

You can install this SDK directly from [npm](https://www.npmjs.com/package/@deepgram/sdk).
Expand Down Expand Up @@ -146,7 +156,7 @@ const deepgram = createClient("proxy", {

Your proxy service should replace the Authorization header with `Authorization: token <DEEPGRAM_API_KEY>` and return results verbatim to the SDK.

# Transcription
# Transcription (Synchronous)

## Remote Files

Expand Down Expand Up @@ -187,6 +197,58 @@ const { result, error } = await deepgram.listen.prerecorded.transcribeFile(

[See our API reference for more info](https://developers.deepgram.com/reference/pre-recorded).

# Transcription (Asynchronous / Callbacks)

## Remote Files

```js
import { CallbackUrl } from "@deepgram/sdk";

const { result, error } = await deepgram.listen.prerecorded.transcribeUrlCallback(
{
url: "https://dpgr.am/spacewalk.wav",
},
new CallbackUrl("http://callback/endpoint"),
{
model: "nova",
}
);
```

[See our API reference for more info](https://developers.deepgram.com/reference/pre-recorded).

## Local Files

```js
import { CallbackUrl } from "@deepgram/sdk";

const { result, error } = await deepgram.listen.prerecorded.transcribeFileCallback(
fs.createReadStream("./examples/spacewalk.wav"),
new CallbackUrl("http://callback/endpoint"),
{
model: "nova",
}
);
```

or

```js
import { CallbackUrl } from "@deepgram/sdk";

const { result, error } = await deepgram.listen.prerecorded.transcribeFileCallback(
fs.readFileSync("./examples/spacewalk.wav"),
new CallbackUrl("http://callback/endpoint"),
{
model: "nova",
}
);
```

[See our API reference for more info](https://developers.deepgram.com/reference/pre-recorded).

# Transcription (Live / Streaming)

## Live Audio

```js
Expand Down Expand Up @@ -499,6 +561,10 @@ To make sure our community is safe for all, be sure to review and agree to our
[Code of Conduct](./CODE_OF_CONDUCT.md). Then see the
[Contribution](./CONTRIBUTING.md) guidelines for more information.

## Debugging and making changes locally

If you want to make local changes to the SDK and run the [`examples/`](./examples/), you'll need to `npm run build` first, to ensure that your changes are included in the examples that are running.

# Getting Help

We love to hear from you so if you have questions, comments or find a bug in the
Expand Down
Loading

0 comments on commit a75db1f

Please sign in to comment.