#Trouble setting interim_results=True

1 messages · Page 1 of 1 (latest)

silver wasp
#

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

▶ Play video
pulsar pivotBOT
#

Thanks for asking your question. Please be sure to reply with as much detail as possible so we can assist you efficiently. Such as:

  • Provide the request_id if you've a question about a transcription response.
  • The options you used or the api.deepgram.com URL you sent your request to, including parameters.
  • Any code snippets you can include.
  • Any audio you can include, or if you can't share it here please email it to us at [email protected] and provide a link to this thread.
silver wasp
#

Any thoughts here <@&1108046479119097906>? 🙏

stable wedge
#

hi @silver wasp

The websocket options go on the URL as part of the query string.

This is the incorrect part:

              socket.send(JSON.stringify({
                  type: 'config',
                  interim_results: true,
              }));

You don't send a config.

fair lynx
#

@silver wasp In the future we'd appreciate if you didn't ping the discord Admin group, it notifies all Deepgram Admins. Thanks!

silver wasp
wide forge
# silver wasp You know you can disable that right?

We know how discord works.

The purpose of the admin group being pingable is to ensure there is a way for members to get our attention if someone is doing something egregious and we've yet to see it. It is to safeguard our community.

Please check out #welcome which contains the community rules and code of conduct, which you agree with to access this Discord. It specifically mentions this scenario, pinging of groups to get attention for your question.

We're a very small team handling a lot of requests and questions.

Thanks for your patience 👍🏻

silver wasp
#

No need to be so defensive Luke. Your team's responses here is a bad look.

wide forge
#

Thanks. Do you have an answer to your question?