Documentation ¶
Overview ¶
Package diatheke provides an interface to interact with Diatheke server using gRPC.
Index ¶
- type ASRStream
- type AudioInputStream
- type Client
- func (c *Client) AppendCallOptions(opts ...grpc.CallOption)
- func (c *Client) Close() error
- func (c *Client) CommandFinished(ctx context.Context, commandStatus *diathekepb.CommandStatus) error
- func (c *Client) DiathekeVersion(ctx context.Context) (string, error)
- func (c *Client) EndSession(ctx context.Context, sessionID string) error
- func (c *Client) ListModels(ctx context.Context) ([]string, error)
- func (c *Client) NewSession(ctx context.Context, model string) (string, error)
- func (c *Client) PushText(ctx context.Context, sessionID, text string) error
- func (c *Client) SessionEventStream(ctx context.Context, sessionID string) (diathekepb.Diatheke_SessionEventStreamClient, error)
- func (c *Client) SetCallOptions(opts ...grpc.CallOption)
- func (c *Client) StreamASR(ctx context.Context, model string) (*ASRStream, error)
- func (c *Client) StreamAudioInput(ctx context.Context, sessionID string) (*AudioInputStream, error)
- func (c *Client) StreamAudioReplies(ctx context.Context, sessionID string) (diathekepb.Diatheke_StreamAudioRepliesClient, error)
- func (c *Client) StreamTTS(ctx context.Context, model, text string) (diathekepb.Diatheke_StreamTTSClient, error)
- type Option
- type Session
- func (sess *Session) CommandFinished(ctx context.Context, status *diathekepb.CommandStatus) error
- func (sess *Session) EndSession(ctx context.Context) error
- func (sess *Session) EventStream(ctx context.Context) (diathekepb.Diatheke_SessionEventStreamClient, error)
- func (sess *Session) PushText(ctx context.Context, text string) error
- func (sess *Session) StreamAudioInput(ctx context.Context) (*AudioInputStream, error)
- func (sess *Session) StreamAudioReplies(ctx context.Context) (diathekepb.Diatheke_StreamAudioRepliesClient, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ASRStream ¶
type ASRStream struct {
PBStream diathekepb.Diatheke_StreamASRClient
}
ASRStream is a bi-directional stream that allows audio data to be pushed to the server, while transcription results are streamed back to the client. Audio pushed to an ASRStream does not contribute to any currently running sessions and their dialogs. It is mainly useful for cases where the client only wants a transcription without any other interactions with Diatheke.
func (*ASRStream) AudioFinished ¶
AudioFinished notifies Diatheke that no more audio is coming from the client.
func (*ASRStream) Receive ¶
func (asr *ASRStream) Receive() (*diathekepb.ASRResponse, error)
Receive waits for a transcript from the server.
type AudioInputStream ¶
type AudioInputStream struct {
PBStream diathekepb.Diatheke_StreamAudioInputClient
}
AudioInputStream allows audio to be pushed to the server for a session. The audio pushed to this stream will contribute to the session's current dialog. Transcriptions are returned as Recognize events on the session's event stream.
func (*AudioInputStream) Finish ¶
func (ais *AudioInputStream) Finish() error
Finish notifies Diatheke that no more audio is coming from the client.
type Client ¶
type Client struct { // The protobuf-defined client. Most users will not need to call this // directly, but is exposed as a convenience for advanced users who // wish to use gRPC functionality beyond what this interface provides. PBClient diathekepb.DiathekeClient // The list of gRPC call options that are used when the client // makes server requests. CallOpts []grpc.CallOption // contains filtered or unexported fields }
Client is an object for interacting with the Diatheke gRPC API.
All methods except Close may be called concurrently.
func NewClient ¶
NewClient creates a new Client that connects to a Diatheke Server listening on the provided address. Transport security is enabled by default. Use Options to override default settings if necessary.
func (*Client) AppendCallOptions ¶
func (c *Client) AppendCallOptions(opts ...grpc.CallOption)
AppendCallOptions adds the given gRPC call options to the current list of options to use when making server requests. It does not check to see if the options are unique in the final list.
func (*Client) Close ¶
Close closes the connection to the API service. The user should only invoke this when the client is no longer needed. Pending or in-progress calls to other methods may fail with an error if Close is called, and any subsequent calls with this client will also fail.
func (*Client) CommandFinished ¶
func (c *Client) CommandFinished(ctx context.Context, commandStatus *diathekepb.CommandStatus) error
CommandFinished notifies the server that a command has completed. This should be called after receiving a command event in the session's event stream, as required by the Diatheke model.
func (*Client) DiathekeVersion ¶
DiathekeVersion queries the Diatheke server for its version.
func (*Client) EndSession ¶
EndSession ends an existing session.
func (*Client) ListModels ¶
ListModels queries the server for the list of currently loaded Diatheke models.
func (*Client) NewSession ¶
NewSession creates a new session and returns the session id.
func (*Client) PushText ¶
PushText sends the given text to Diatheke as part of a conversation for the given session.
func (*Client) SessionEventStream ¶
func (c *Client) SessionEventStream(ctx context.Context, sessionID string) (diathekepb.Diatheke_SessionEventStreamClient, error)
SessionEventStream returns a new event stream for the given session ID.
func (*Client) SetCallOptions ¶
func (c *Client) SetCallOptions(opts ...grpc.CallOption)
SetCallOptions replaces any current gRPC call options with the given set to use when making server requests.
func (*Client) StreamASR ¶
StreamASR runs streaming speech recognition unrelated to a session, using the specified ASR model.
func (*Client) StreamAudioInput ¶
StreamAudioInput returns a stream object that may be used to push audio data to the Diatheke server for the given session. Only one stream per session should be running concurrently.
func (*Client) StreamAudioReplies ¶
func (c *Client) StreamAudioReplies(ctx context.Context, sessionID string) (diathekepb.Diatheke_StreamAudioRepliesClient, error)
StreamAudioReplies returns a stream object that receives output audio from Diatheke specifically for the given session. The stream will include start and end messages to indicate when a section of audio for a group of text begins and ends.
func (*Client) StreamTTS ¶
func (c *Client) StreamTTS(ctx context.Context, model, text string) (diathekepb.Diatheke_StreamTTSClient, error)
StreamTTS runs streaming text-to-speech unrelated to a session. It synthesizes speech for the given text, using the specified TTS model. To create a stream that can be cancelled by the client, use the context.WithCancel() function to create a new context and context.CancelFunc. Pass the new context to this function, and the stream will end when the corresponding CancelFunc is called.
type Option ¶
Option configures how we setup the connection with a server.
func WithClientCert ¶
WithClientCert returns an Option which sets up the given PEM certificate and key as the credentials presented by this Client when connecting to a server. Use this when setting up mutually authenticated TLS.
func WithInsecure ¶
func WithInsecure() Option
WithInsecure returns an Option which disables transport security for this Client. Use this when connecting to a non-TLS enabled diatheke server, such as during debugging.
func WithServerCert ¶
WithServerCert returns an Option which sets up the given PEM certificate as a root certificate that can validate the certificate presented by the server we are connecting to. Use this when connecting to an instance of diatheke server that is using a self-signed certificate.
type Session ¶
Session represents a Diatheke session. It is a wrapper around diatheke.Client, provided as a convenience for working with methods that require a session ID.
func (*Session) CommandFinished ¶
func (sess *Session) CommandFinished(ctx context.Context, status *diathekepb.CommandStatus) error
CommandFinished notifies the server that a command has completed. This should be called after receiving a command event in the session's event stream, as required by the Diatheke model.
func (*Session) EndSession ¶
EndSession ends this session.
func (*Session) EventStream ¶
func (sess *Session) EventStream(ctx context.Context) (diathekepb.Diatheke_SessionEventStreamClient, error)
EventStream returns a new event stream for this session.
func (*Session) PushText ¶
PushText sends the given text to Diatheke as part of a conversation for this session.
func (*Session) StreamAudioInput ¶
func (sess *Session) StreamAudioInput(ctx context.Context) (*AudioInputStream, error)
StreamAudioInput returns a stream object that may be used to push audio data to the Diatheke server for this session. Only one stream per session should be running concurrently.
func (*Session) StreamAudioReplies ¶
func (sess *Session) StreamAudioReplies(ctx context.Context) (diathekepb.Diatheke_StreamAudioRepliesClient, error)
StreamAudioReplies returns a stream object that receives output audio from Diatheke specifically for this session. The stream will include start and end messages to indicate when a section of audio for a group of text begins and ends.