net - UK (2020-04)

(Antfer) #1

PROJECTS
Text-to-Speech API


There are many great options available for speech synthesis
APIs. Here are a few of the best ones, well worth trying out.

0LFURVRIW$]XUHŜ7H[W7R6SHHFK
https://azure.microsoft.com/en-us/services/cognitive-services/text-to-
speech
Microsoft’s solution boasts over 45 languages supported with
over 80 voices. Its audio is high quality and customisable. If you are
already working with APIs or tools within the Azure ecosystem,
this might be a great choice for you.

,%0şV:DWVRQ7H[WWR6SHHFK
https://www.ibm.com/cloud/watson-text-to-speech
Watson Text-to-Speech enables you to create human-like speech,
via IBM’s cloud API services, much like Google’s model. It boasts
upwards of 190 voices, with plenty of control and languages to suit
your needs. It’s another great option to explore, especially if you
are using IBM’s other cloud services already.

$PD]RQ3ROO\
https://aws.amazon.com/polly/
Amazon Polly transforms text into human speech using its deep
learning system. Polly works as a web service like the other APIs,
making it flexible for use across a wide range of devices and
platforms. It also features speaking styles, such as newscaster
or conversational speaking. These change speaking cadence and
rhythm for a realistic result.

API ALTERNATIVES


RESOURCES

that submit this data in the step after this one. In the
head of the HTML add this PHP code:

<?php
// get incoming vars, set defaults
if(isset($_POST[‘text’])){$text = $_POST[“text”];} else
{$text=”Hello.”;}
if(isset($_POST[‘gender’])){$gender = $_
POST[“gender”];} else {$gender=”female”;}
if(isset($_POST[‘type’])){$type= $_POST[“type”];} else
{$type=”en-GB-Wavenet-B”;}
?>

STEP 10:$'')250),(/'6
Add a few form fields for some voice type options.
We’ll add male or female options, along with language
type and a place for the text to be synthesised.

<textar ea type=”textarea” cols=60 rows=5
name=”text” id=”text” ><?php echo $text ?></
textarea><br/><br />
<select id=”gender” name=”gender”>
<option value=”female”>FEMALE</option>
<option value=”male”>MALE</option>
</select>
<select id=”type” name=”type”>
<option value=”en-GB-Wavenet-D”>English UK
Wavenet D</option>
<option value=”en-US-Wavenet-C”>English US
Wavenet C</option>
<option value=”en-AU-Wavenet-A”>Australian
Wavenet A</option>
<option value=”nl-NL-Wavenet-A”>Dutch Wavenet
A</option>
</select>

STEP 11:(19,5210(179$5,$%/(
The next code goes between the PHP tags, between
results tags where we indicated the php code
would go. You need to set the GOOGLE_APPLICATION_
CREDENTIALS variable. We did this in command line
previously and now can manage it here. Use the
putenv command to set an environment variable. Add
this code next in your PHP code:

putenv(‘GOOGLE_APPLICATION_CREDENTIALS=/Library/
WebServer/Documents/richardmattka_v1/proto/net-text-
to-speech/Text To Speech-bc489c0a7499.json’);

Remember to replace the path and file name with
your JSON private key file.

STEP 12:,1&/8'(7+(6'./,%5$5<
Next, incorporate the SDK library. Add this code in
your PHP code section:
Free download pdf