deepgram/deepgram-go-sdk

Handle `UtteranceEnd` message type

Closed this issue · 8 comments

Using the utterance_end_ms parameter for the live api requires handling of { type: UtteranceEnd }. Currently here's no way to handle this in the callback interface.

Perhaps an optional UnhandledResponse method on the callback interface could be an useful escape-hatch for new message types, rather than treating it as an error?

We just discussed this internally. Will expose this parameter shortly.

in the meantime @boyswan , you can expose custom parameter to the Live Client using this example:
#144

This should get you around that problem.

So this allows me to add the utterance_end_ms parameter, but what I'm referring to is an error from the router:

I1215 16:30:07.641232   96536 router.go:174] UnhandledMessage RAW:
{
  "type": "UtteranceEnd"
}
I1215 16:30:07.641236   96536 router.go:175] -----------------------------------------------


I1215 16:30:07.641253   96536 router.go:162] User callback is undefined
I1215 16:30:07.641257   96536 client.go:244] WebSocketClient::listen: router.Message failed. Err: invalid message type

So this allows me to add the utterance_end_ms header, but what I'm referring to is an error from the router:

I1215 16:30:07.641232   96536 router.go:174] UnhandledMessage RAW:
{
  "type": "UtteranceEnd"
}
I1215 16:30:07.641236   96536 router.go:175] -----------------------------------------------


I1215 16:30:07.641253   96536 router.go:162] User callback is undefined
I1215 16:30:07.641257   96536 client.go:244] WebSocketClient::listen: router.Message failed. Err: invalid message type

Not the header... you want to add as a query parameter. Just this one:

// example on how to send a custom parameter
params := make(map[string][]string, 0)
params["utterance_end_ms"] = []string{"your-value"}
ctx = cfginterfaces.WithCustomParameters(ctx, params)

Didn't mean to close with comment...

Sorry typo! Meant parameter:

params := make(map[string][]string, 0)
params["utterance_end_ms"] = []string{"2000"}
ctx = cfginterfaces.WithCustomParameters(ctx, params)

If I understand correctly, the router needs to handle the UtteranceEnd type:

Sorry typo! Meant parameter:

params := make(map[string][]string, 0)
params["utterance_end_ms"] = []string{"2000"}
ctx = cfginterfaces.WithCustomParameters(ctx, params)

If I understand correctly, the router needs to handle the UtteranceEnd type:

Ahhhh that's right. There is a new message type that needs to be added. Will need to wait then until the modifications are complete. Forget about the new message type. Trying to juggle too many things right now.

Will add that in a bit.