texttospeech

package
v0.0.0-...-cdd8ae1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2018 License: MIT Imports: 6 Imported by: 0

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

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 NewClient

func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error)

NewClient creates a new texttospeech client.

func (*Client) Close

func (c *Client) Close() error

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

ListVoices returns a list of Voice supported for synthesis.

func (*Client) SynthesizeSpeech

SynthesizeSpeech synthesizes speech synchronously: receive results after all text input has been processed.

Jump to

Keyboard shortcuts

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