Documentation ¶
Overview ¶
Package texttospeech offers a Client to interact with Google Cloud Text-to-Speech API.
Client initialization
// Retrieve context ctx := context.Background() // Init client and check for errors client, err := texttospeech.NewClient(ctx) if err != nil { log.Fatal(err) } defer client.Close()
ListVoices method ¶
Returns a list of Voice supported for synthesis.
resp, err := client.ListVoices(ctx, &texttospeechpb.ListVoicesRequest{ LanguageCode: "en", }) if err != nil { log.Fatal(err) } // do something with response
SynthesizeSpeech ¶
Synthesizes speech synchronously: receive results after all text input has been processed.
resp, err := client.SynthesizeSpeech(ctx, &texttospeechpb.SynthesizeSpeechRequest{ Input: &texttospeechpb.SynthesisInput{ InputSource: &texttospeechpb.SynthesisInput_Text{ Text: "Hello world", }, }, Voice: &texttospeechpb.VoiceSelectionParams{ LanguageCode: "en-US", Name: "en-US-Wavenet-A", SsmlGender: "MALE", }, AudioConfig: &texttospeechpb.AudioConfig{ AudioEncoding: texttospeechpb.AudioEncoding_MP3, }, }) if err != nil { log.Fatal(err) } // do something with response
Package texttospeech offers a Client to interact with Google Cloud Text-to-Speech API.
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) Connection() *grpc.ClientConn
- func (c *Client) ListVoices(ctx context.Context, req *texttospeechpb.ListVoicesRequest, ...) (*texttospeechpb.ListVoicesResponse, error)
- func (c *Client) SynthesizeSpeech(ctx context.Context, req *texttospeechpb.SynthesizeSpeechRequest, ...) (*texttospeechpb.SynthesizeSpeechResponse, error)
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
}
Client is a client for interacting with Google Cloud Text-to-Speech API.
func (*Client) Close ¶
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*Client) Connection ¶
func (c *Client) Connection() *grpc.ClientConn
Connection returns the client's connection to the API service.
func (*Client) ListVoices ¶
func (c *Client) ListVoices(ctx context.Context, req *texttospeechpb.ListVoicesRequest, opts ...gax.CallOption) (*texttospeechpb.ListVoicesResponse, error)
ListVoices returns a list of Voice supported for synthesis.
func (*Client) SynthesizeSpeech ¶
func (c *Client) SynthesizeSpeech(ctx context.Context, req *texttospeechpb.SynthesizeSpeechRequest, opts ...gax.CallOption) (*texttospeechpb.SynthesizeSpeechResponse, error)
SynthesizeSpeech synthesizes speech synchronously: receive results after all text input has been processed.