turnend

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package turnend is the client for an acoustic end-of-turn classifier served over HTTP - Smart Turn in the duplex deployment profiles (tools/duplexmodels/turn_server.py, POST /v1/endpoint/smart-turn).

The request body is the most recent user audio as little-endian float32 mono at 16 kHz, at most MaxWindow long and ending at the pause being judged; the response is {"probability": P(turn complete), "model": "..."}. The transcript heard so far travels percent-encoded in TranscriptHeader, so a classifier that reads words (LiveKit's turn detector) or both (a fusion) answers through the same route; an acoustic one ignores it. The classifier never sees audio or words from after the pause, so the evidence is causal.

Index

Constants

View Source
const (
	// SampleRateHz is the rate the service reads.
	SampleRateHz = uint32(16_000)
	// MaxWindow is the most audio sent: Smart Turn reads up to eight seconds.
	MaxWindow = 8 * time.Second
	// DefaultTimeout bounds one classification. The call sits on the pause
	// decision, so a slow classifier costs the user that much waiting.
	DefaultTimeout = 300 * time.Millisecond

	// TranscriptHeader carries the percent-encoded transcript of the turn so
	// far.
	TranscriptHeader = "X-OpenRealtime-Transcript"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client classifies pauses.

func New

func New(config Config) (*Client, error)

New validates the configuration.

func (*Client) Evaluate

func (client *Client) Evaluate(ctx context.Context, pcm16le []byte, transcript string) (interaction.AcousticEndpoint, error)

Evaluate classifies the pause at the end of pcm16le, which must be 16 kHz mono PCM16, given the transcript of the turn so far (possibly empty). Audio beyond MaxWindow is dropped from the front.

func (*Client) Name

func (client *Client) Name() string

Name identifies the client and route in evidence.

type Config

type Config struct {
	URL        string
	Timeout    time.Duration
	HTTPClient *http.Client
}

Config configures the client.

Jump to

Keyboard shortcuts

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