meemalabs / laravel-text-to-speech

💬 A wrapper for popular TTS services to create a more simple & uniform API. Currently, only AWS Polly is supported.
MIT License
35 stars 15 forks source link

How to change the speed of voice? [BUG] #20

Closed DelcinoCastelo closed 3 years ago

DelcinoCastelo commented 3 years ago

I need your help!!

chrisbbreuer commented 3 years ago

Hi @DelcinoCastelo,

Have you taken a look at SSML tags? That should solve your request 👍🏼

DelcinoCastelo commented 3 years ago

I have no idea of how to use. Can you give me some example?

chrisbbreuer commented 3 years ago

Of course, this little snippet is part of the documentation:

// use the SSML text type in the convert() method.
$path = TextToSpeech::ssml()
    ->convert('<speak>Hi There <break /> This is SSML syntax</speak>');

The supported tags are listed here: https://docs.aws.amazon.com/polly/latest/dg/supportedtags.html

So, in order to change the speed of text read out loud, you would have to check out the "prosody"-tag and the "rate" attribute.

$tts = '<speak>
     For dramatic purposes, you might wish to <prosody rate="slow">slow up the speaking 
     rate of your text.</prosody>                     
</speak>';

$path = TextToSpeech::ssml()
    ->convert($tts);

AWS docs list this:

  • rate

-- x-slow, slow, medium, fast,x-fast. Sets the pitch to a predefined value for the selected voice.

-- n%: A non-negative percentage change in the speaking rate. For example, a value of 100% means no change in speaking rate, a value of 200% means a speaking rate twice the default rate, and a value of 50% means a speaking rate of half the default rate. This value has a range of 20-200%.

chrisbbreuer commented 3 years ago

It's been 2 weeks, so I will close this in the meantime. Feel free to ping me with any questions!