\duncan3dc\Speaker\ProvidersVoiceRssProvider

Convert a string of a text to spoken word audio.

Summary

Methods
Properties
Constants
setClient()
getClient()
getFormat()
getOptions()
__construct()
withLanguage()
withSpeed()
textToSpeech()
No public properties found
No constants found
sendRequest()
No protected properties found
N/A
getLanguage()
getSpeed()
$client
$language
$speed
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.

$speed

$speed : integer

Type

integer — The speech rate.

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(\duncan3dc\Speaker\Providers\string  $apikey, string  $language = null, integer  $speed = null) 

Create a new instance.

Parameters

\duncan3dc\Speaker\Providers\string $apikey
string $language

The language to use.

integer $speed

The speech rate to use.

withLanguage()

withLanguage(string  $language) : self

Set the language to use.

Parameters

string $language

The language to use (eg 'en')

Returns

self

withSpeed()

withSpeed(integer  $speed) : $this

Set the speech rate to use.

Parameters

integer $speed

The speech rate to use (between -10 and 10)

Returns

$this

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

getSpeed()

getSpeed(integer  $speed) : integer

Check the speech rate is valid.

Parameters

integer $speed

The speech rate to use

Returns

integer