From 79ac067769adb95a953fa9e23edcb935f090c01c Mon Sep 17 00:00:00 2001 From: Andela Developer Date: Tue, 6 Mar 2018 16:06:54 +0100 Subject: [PATCH] cookbook for aws-polly --- web/_sidebar.md | 1 + web/solutions/aws-polly.md | 85 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 web/solutions/aws-polly.md diff --git a/web/_sidebar.md b/web/_sidebar.md index 8b6083f..b47d1fa 100644 --- a/web/_sidebar.md +++ b/web/_sidebar.md @@ -22,6 +22,7 @@ - [Wordpress on Lightsail](/solutions/aws-wordpress) - [NodeJS on Lightsail](/solutions/aws-node) - [Ethereum on Lightsail](/solutions/aws-ethereum) + - [Polly](/solutions/aws-polly) - Payments - [Stripe](/solutions/stripe-payment) - Deployment diff --git a/web/solutions/aws-polly.md b/web/solutions/aws-polly.md new file mode 100644 index 0000000..31419c0 --- /dev/null +++ b/web/solutions/aws-polly.md @@ -0,0 +1,85 @@ +# AWS Polly + +* Preparation: **2 minutes** +* Requirements: + * Initiated Syncano project + * AWS ACCESS_KEY_ID + * AWS SECRET_ACCESS_KEY + * Region + +### Problem to solve + +You want to integrate a service that converts text to speech into application: + +### Solution + +Our solution is established using [aws-polly](https://syncano.io/#/sockets/aws-polly) Text-to-Speech (TTS) cloud service that converts text into lifelike speech. + +### Installing dependencies + +#### Server-side + +To install aws-polly, type: + +```sh +$ syncano-cli add aws-polly +``` + +Provide `AWS ACCESS_KEY_ID`, `AWS SECRET_ACCESS_KEY` and `Region` + +* N/B: To find `AWS ACCESS_KEY_ID` and `AWS SECRET_ACCESS_KEY`, log into your AWS account to get it. +Also to get `Region`, search for Polly on your AWS Console to check supported regions and select one (e.g, us-east-1 ) + +Deploy aws-polly to update socket + +```sh +$ syncano-cli deploy aws-polly +``` + +#### Client-side + +Install syncano-client to interact with Syncano aws-polly socket: +N/B: There are two way's of achieving installation. + +1. When using webpack and es6 the way to handle the client lib is: +Shell: + +```sh +$ npm i -S @syncano/client +``` + +Create a connection by initializing Syncano object with instance name: + +```javascript +import SyncanoClient from "@syncano/client" + +const s = new SyncanoClient("MY_INSTANCE_NAME"); +``` + +2. And the vanilla js way: +```HTML + + +``` + +Implement text-to-speech process using aws-polly synthesizeSpeech endpoint: + +```javascript + +const polly = synthesizeSpeechParams => { + try { + const synthesizeSpeech = s.post("aws-polly/synthesizeSpeech", synthesizeSpeechParams); + (response) => { + return { data: response.data} + } + } catch (error) { + return error.message; + } +}; +``` + +### Testing functionality + +Now you can create a text-box collecting text from user and pass on to script file for conversion to speech. On you application, You could decide for your users to download file or listen to speech.