Skip to content

Commit 7dd99c9

Browse files
committed
fix: update live example to demonstrate utteranceend and speechstarted
1 parent ba1557d commit 7dd99c9

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

examples/node-live/index.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
const { createClient, LiveTranscriptionEvents } = require("../../dist/main/index");
1+
const {
2+
createClient,
3+
LiveTranscriptionEvents,
4+
LiveTranscriptionEvent,
5+
} = require("../../dist/main/index");
26
const fetch = require("cross-fetch");
37

48
const live = async () => {
59
const url = "http://stream.live.vc.bbcmedia.co.uk/bbc_world_service";
610

711
const deepgram = createClient(process.env.DEEPGRAM_API_KEY);
812

9-
const connection = deepgram.listen.live({ model: "general", tier: "enhanced" });
13+
const connection = deepgram.listen.live({
14+
model: "nova-2",
15+
utterance_end_ms: 1500,
16+
interim_results: true,
17+
});
1018

1119
connection.on(LiveTranscriptionEvents.Open, () => {
1220
connection.on(LiveTranscriptionEvents.Close, () => {
@@ -18,6 +26,14 @@ const live = async () => {
1826
});
1927

2028
connection.on(LiveTranscriptionEvents.Transcript, (data) => {
29+
console.log(data.channel);
30+
});
31+
32+
connection.on(LiveTranscriptionEvents.UtteranceEnd, (data) => {
33+
console.log(data);
34+
});
35+
36+
connection.on(LiveTranscriptionEvents.SpeechStarted, (data) => {
2137
console.log(data);
2238
});
2339

0 commit comments

Comments
 (0)