Documentation ¶
Overview ¶
Package client wraps the transcribe proto client and implements the interface transcribepb.TranscribeServiceClient that can use GRPC to receive results from Transcribe server.
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) CompileContext(ctx context.Context, modelID, token string, ...) (*transcribepb.CompiledContext, error)
- func (c *Client) ListModels(ctx context.Context) ([]*transcribepb.Model, error)
- func (c *Client) StreamingRecognize(ctx context.Context, cfg *transcribepb.RecognitionConfig, audio io.Reader, ...) error
- func (c *Client) Versions(ctx context.Context) (string, error)
- type Option
- type RecognitionResponseHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CompileContext ¶
func (c *Client) CompileContext(ctx context.Context, modelID, token string, phrases []*transcribepb.ContextPhrase) (*transcribepb.CompiledContext, error)
CompileContext compiles recognition context information, such as a specialized list of words or phrases, into a compact, efficient form to send with subsequent `StreamingRecognize` requests to customize speech recognition. For example, a list of contact names may be compiled in a mobile app and sent with each recognition request so that the app user's contact names are more likely to be recognized than arbitrary names. This pre-compilation ensures that there is no added latency for the recognition request. It is important to note that in order to compile context for a model, that model has to support context in the first place, which can be verified by checking its `ModelAttributes.ContextInfo` obtained via the `ListModels` method. Also, the compiled data will be model specific; that is, the data compiled for one model will generally not be usable with a different model.
func (*Client) ListModels ¶
ListModels retrieves a list of available speech recognition models.
func (*Client) StreamingRecognize ¶
func (c *Client) StreamingRecognize(ctx context.Context, cfg *transcribepb.RecognitionConfig, audio io.Reader, handler RecognitionResponseHandler) error
StreamingRecognize wraps the bidirectional streaming API for performing speech recognition. It sets up recognition using the given cfg. Data is read from the given audio reader into a buffer and streamed to Transcribe server. As results are received from Transcribe server, they will be sent to the provided handlerFunc. If any error occurs while reading the audio or sending it to the server, this method will immediately exit, returning that error. This function returns only after all results have been passed to the resultHandler.
type Option ¶
type Option func(*clientArgs) error
Option configures how we setup the connection with a server.
func WithContext ¶
WithContext returns an Option that sets up context.Context to use for GRPC client connection.
func WithInsecure ¶
func WithInsecure() Option
WithInsecure returns an Option that sets up Client without using TLS enable.
func WithLogger ¶
WithLogger returns an Option that sets up Client logger.
func WithStreamingBufferSize ¶
WithStreamingBufferSize returns an Option that sets up the buffer size (bytes) of each message sent from the Client to the server during streaming GRPC calls. Use this only if Cobalt recommends you to do so. A value n>0 is required.
type RecognitionResponseHandler ¶
type RecognitionResponseHandler func(*transcribepb.StreamingRecognizeResponse)
RecognitionResponseHandler is a type of callback function that will be called when the `StreamingRecognize` method is running. For each response received from transcribe server, this method will be called once. The provided RecognitionResponse is guaranteed to be non-nil. Since this function is executed as part of the streaming process, it should preferably return quickly and certainly not block.