Hi there,
I was following Deepgram's video tutorial here on using your Microphone for transcriptions through the browser:
https://youtu.be/kIyPX16zuQY?si=LewTFsvkiLuuq6yP
And it works fine, except in the Deepgram example video, all the results come back with is_final= false. Which is what I want.
However, when I run the exact same code all my results come back with the flag:
is_final: true
My guess is the default response has changed since this video was made, but I'm really not aware of how to set the interim_results=True.
This is my current code with an attempt at setting the option when connecting to the socket.
<!DOCTYPE html>
<html>
<body>
<script src='key.js'></script>
<script>
navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
const mediaRecorder = new MediaRecorder(stream, { mimeType: 'audio/webm'})
const socket = new WebSocket('wss://api.deepgram.com/v1/listen', ['token', DG_KEY])
socket.onopen = () => {
// Send configuration with interim results enabled
socket.send(JSON.stringify({
type: 'config',
interim_results: true,
}));
mediaRecorder.addEventListener('dataavailable', event => {
socket.send(event.data)
})
mediaRecorder.start(250)
}
socket.onmessage = (message) => {
const received = JSON.parse(message.data)
const transcript = received.channel.alternatives[0].transcript
console.log(transcript)
}
})
</script>
</body>
</html>
I appreciate any help you can give!
In this video, Senior Developer Advocate Kevin Lewis shows you how to use Deepgram's Speech Recognition API to get live captions directly in your browser.
------------- USEFUL LINKS -------------
Get a free Deepgram account: https://console.deepgram.com/signup
Read the blog post: https://developers.deepgram.com/blog/2021/11/live-transcription-...