Skip to content

Commit

Permalink
Merge pull request #129 from deepgram/new-readme
Browse files Browse the repository at this point in the history
updated live transcription section in README
  • Loading branch information
briancbarrow authored May 15, 2023
2 parents ab585a8 + ef4c0dc commit d94811d
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,7 @@ const response = await deepgram.transcription.preRecorded(streamSource, {

### Transcribe Audio in Real-Time

```js
navigator.mediaDevices.getUserMedia({ audio: true }).then((stream) => {
const mediaRecorder = new MediaRecorder(stream, {
mimeType: 'audio/webm',
});
const deepgramSocket = deepgram.transcription.live({ punctuate: true });

deepgramSocket.addEventListener('open', () => {
mediaRecorder.addEventListener('dataavailable', async (event) => {
if (event.data.size > 0 && deepgramSocket.readyState == 1) {
deepgramSocket.send(event.data)
}
})
mediaRecorder.start(1000)
});

deepgramSocket.addEventListener("message", (message) => {
const received = JSON.parse(message.data);
const transcript = received.channel.alternatives[0].transcript;
if (transcript && received.is_final) {
console.log(transcript);
}
});
});
```
See an example real time project at https://github.com/deepgram-devs/node-live-example, or visit this [Getting Started guide](https://developers.deepgram.com/documentation/getting-started/streaming/)

## Samples

Expand Down

0 comments on commit d94811d

Please sign in to comment.