Search code examples
javascriptspeech-recognitionamazon-cognitospeech-to-textaws-sdk-js

Uncaught TypeError: AWS.TranscribeService is not a constructor


I am trying to access AWS Transcribe API via JavaScript SDK on my web page for implement a sample Text to Speech web application. I had referred the documentation in AWS websites, include generating the CognitoIdentityCredentials.

HTML

<!DOCTYPE html>
 <html>

<head>
<meta charset="utf-8" />
<title></title>
<script src="https://requirejs.org/docs/release/2.3.6/minified/require.js"></script>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.653.0.min.js"></script>
<script type="text/javascript">
    debugger;

    AWS.config = new AWS.Config({
        access_key_id: 'xxxxx',
        secretAccessKey: 'xxxx',
        region: 'us-east-2'
    });

    // Initialize the Amazon Cognito credentials provider
    AWS.config.region = 'us-east-2'; // Region
    AWS.config.credentials = new AWS.CognitoIdentityCredentials({
        IdentityPoolId: 'us-east-2:xx-xx-xxxx-xxxx-xxx',
    });

    console.log(AWS);

    debugger;
    var transcribeservice = new AWS.TranscribeService();
</script>

Error

enter image description here


Solution

  • The easiest way to create your own build of the AWS SDK for JavaScript is to use the SDK builder web application at https://sdk.amazonaws.com/builder/js. Use the SDK builder to specify services, and their API versions, to include in your build.

    Choose Select all services or choose Select default services as a starting point from which you can add or remove services. Choose Development for more readable code or choose Minified to create a minified build to deploy. After you choose the services and versions to include, choose Build to build and download your custom SDK.