\duncan3dc\Speaker\ProvidersGoogleProvider

Convert a string of a text to spoken word audio.

Summary

Methods
Properties
Constants
setClient()
getClient()
getFormat()
getOptions()
__construct()
withLanguage()
textToSpeech()
No public properties found
No constants found
sendRequest()
No protected properties found
N/A
getLanguage()
$client
$language
N/A

Properties

$client

$client : \GuzzleHttp\ClientInterface

Type

\GuzzleHttp\ClientInterface — A guzzle instance for http requests.

$language

$language : string

Type

string — The language to use.

Methods

setClient()

setClient(\GuzzleHttp\ClientInterface  $client) : \duncan3dc\Speaker\Providers\ProviderInterface

Get the guzzle client instance to use.

Parameters

\GuzzleHttp\ClientInterface $client

Returns

\duncan3dc\Speaker\Providers\ProviderInterface

getClient()

getClient() : \GuzzleHttp\ClientInterface

Get the guzzle client.

Returns

\GuzzleHttp\ClientInterface

getFormat()

getFormat() : string

Get the format of this audio.

Returns

string

getOptions()

getOptions() : array

Get the current options.

This is used in caching to determine if we have sent a request with these options before and can use the previous result.

Returns

array

__construct()

__construct(string  $language = null) 

Create a new instance.

Parameters

string $language

The language to use.

withLanguage()

withLanguage(string  $language) : self

Set the language to use.

Parameters

string $language

The language to use (eg 'en')

Returns

self

textToSpeech()

textToSpeech(string  $text) : string

Convert the specified text to audio.

Parameters

string $text

The text to convert

Returns

string —

The audio data

sendRequest()

sendRequest(string  $hostname, array<mixed,string>  $params) : string

Send a http request.

Parameters

string $hostname

The hostname to send the request to

array<mixed,string> $params

The parameters of the request

Returns

string —

The response body

getLanguage()

getLanguage(string  $language) : string

Check if the language is valid, and convert it to the required format.

Parameters

string $language

The language to use

Returns

string