live

package
v1.3.1-0...-b434ee1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. Use of this source code is governed by a MIT license that can be found in the LICENSE file. SPDX-License-Identifier: MIT

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidMessageType invalid message type
	ErrInvalidMessageType = errors.New("invalid message type")

	// ErrUserCallbackNotDefined user callback object not defined
	ErrUserCallbackNotDefined = errors.New("user callback object not defined")
)

Functions

This section is empty.

Types

type DefaultCallbackHandler

type DefaultCallbackHandler struct{}

DefaultCallbackHandler is a default callback handler for live transcription Simply prints the transcript to stdout

func NewDefaultCallbackHandler

func NewDefaultCallbackHandler() DefaultCallbackHandler

NewDefaultCallbackHandler creates a new DefaultCallbackHandler

func (DefaultCallbackHandler) Close added in v1.1.6

Close is the callback for when the connection closes

func (DefaultCallbackHandler) Error

Error is the callback for a error messages

func (DefaultCallbackHandler) Message

Message is the callback for a transcription message

func (DefaultCallbackHandler) Metadata

Metadata is the callback for information about the connection

func (DefaultCallbackHandler) Open added in v1.1.6

Open is the callback for when the connection opens

func (DefaultCallbackHandler) SpeechStarted added in v1.1.1

SpeechStarted is when VAD detects noise

func (DefaultCallbackHandler) UnhandledEvent added in v1.1.6

func (dch DefaultCallbackHandler) UnhandledEvent(byData []byte) error

UnhandledEvent is the callback for unknown messages

func (DefaultCallbackHandler) UtteranceEnd added in v1.0.2

UtteranceEnd is the callback for when a channel goes silent

type MessageRouter

type MessageRouter struct {
	// contains filtered or unexported fields
}

MessageRouter routes events

func New

New creates a MessageRouter with a user-defined callback

func NewWithDefault

func NewWithDefault() *MessageRouter

NewWithDefault creates a MessageRouter with the default callback handler

func (*MessageRouter) CloseHelper added in v1.1.6

func (r *MessageRouter) CloseHelper(or *interfaces.CloseResponse) error

OpenResponse handles the OpenResponse message

func (*MessageRouter) ErrorHelper added in v1.3.0

func (r *MessageRouter) ErrorHelper(er *interfaces.ErrorResponse) error

ErrorResponse handles the OpenResponse message

func (*MessageRouter) Message

func (r *MessageRouter) Message(byMsg []byte) error

Message handles platform messages and routes them appropriately based on the MessageType

func (*MessageRouter) OpenHelper added in v1.1.6

func (r *MessageRouter) OpenHelper(or *interfaces.OpenResponse) error

OpenHelper handles the OpenResponse message

func (*MessageRouter) UnhandledMessage

func (r *MessageRouter) UnhandledMessage(byMsg []byte) error

UnhandledMessage logs and handles any unexpected message types

type MessageType

type MessageType struct {
	Type string `json:"type"`
}

MessageType is the header to bootstrap you way unmarshalling other messages

Example:
{
	"type": "message",
	"message": {
		...
	}
}

Directories

Path Synopsis
This package defines interfaces for the live API
This package defines interfaces for the live API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL