0

I'm trying to use Amazon Transcribe, but whenever I start a new Transcribe job I receive the following timeout error:

    Error Error: TimeoutError
    at ClientRequest.<anonymous> (/Users/mrx/Desktop/Entwicklung/Backend/node_modules/@aws-sdk/credential-provider-imds/dist/cjs/remoteProvider/httpRequest.js:17:20)
    at ClientRequest.emit (events.js:314:20)
    at Socket.emitRequestTimeout (_http_client.js:715:9)
    at Object.onceWrapper (events.js:420:28)
    at Socket.emit (events.js:326:22)
    at Socket._onTimeout (net.js:483:8)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7) {
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

EDIT: I also sometimes get the following "Unable to connect to instance metadata service" error:

Error ProviderError: Unable to connect to instance metadata service
    at ClientRequest.<anonymous> (/Users/mrx/Desktop/Entwicklung/Backend/node_modules/@aws-sdk/credential-provider-imds/dist/cjs/remoteProvider/httpRequest.js:14:34)
    at ClientRequest.emit (events.js:314:20)
    at Socket.socketErrorListener (_http_client.js:427:9)
    at Socket.emit (events.js:314:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  tryNextLink: true,
  errno: 'EHOSTDOWN',
  code: 'EHOSTDOWN',
  syscall: 'connect',
  address: '149.124.129.254',
  port: 80,
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

That's what my transcribe_create_job.js file looks like:

const StartTranscriptionJobCommand = require("@aws-sdk/client-transcribe")
const transcribeClient = require("./libs/transcribeClient.js")

const dotenv = require('dotenv')
const result = dotenv.config({path: __dirname + '/./../../../../.env'})
 
if (result.error) {
  throw result.error
}

// Set the parameters
const params = {
  TranscriptionJobName: "Transcription Test",
  LanguageCode: "en-US",
  MediaFormat: "webm", 
  Media: {
    MediaFileUri: "https://speech-recognition.s3.eu-central-1.amazonaws.com/djoqiipn.webm",
  },
};

const run = async () => {
  try {
    const data = await transcribeClient.send(
      new StartTranscriptionJobCommand(params)
    );
    console.log("Success - put", data);
    return data; // For unit tests.
  } catch (err) {
    console.log("Error", err);
  }
};
run()

That's what my transcribeClient.js file looks like:

const dotenv = require('dotenv')
const result = dotenv.config({path: __dirname + '/../.env'})
 
if (result.error) {
  throw result.error
}

const { TranscribeClient } = require("@aws-sdk/client-transcribe");
const REGION = result.parsed.AWS_REGION
const transcribeClient = new TranscribeClient({ region: REGION });
module.exports = transcribeClient

I copied the code from the official documentation, but I can't figure out why I get this error. I don't find any explanation to this error online as well, so I hope somebody else knows why I get the error.

Thank you for your help in advance! Maurice

Maurice
  • 141
  • 1
  • 9

2 Answers2

1

Solved my problem by doing what I did here as well as adding AWS_REGION, AWS_ACCESS_KEY and AWS_SECRET_KEY to the client function.

const { TranscribeClient } = require("@aws-sdk/client-transcribe");
const transcribeClient = new TranscribeClient({ AWS_REGION, AWS_ACCESS_KEY, AWS_SECRET_KEY});
module.exports = { transcribeClient };
Maurice
  • 141
  • 1
  • 9
0

Please use this method

var params = {
  Media: { /* required */
    MediaFileUri: 'STRING_VALUE'
  },
  TranscriptionJobName: 'STRING_VALUE', /* required */

  MediaFormat: webm,
  
  
};
TranscribeClient.startTranscriptionJob(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});
megasubhash
  • 109
  • 4
  • Thank you for your answer. Unfortunately, it's not working. I receive that error: `TranscribeClient.startTranscriptionJob is not a function` I also wrote it with a lower case T, but that also doesn't work. – Maurice Jun 15 '21 at 12:20
  • Just added another error to my question that I sometimes receive when I'm trying to start the transcribe job. – Maurice Jun 15 '21 at 12:25
  • `var aws = require("aws-sdk") var TranscribeClient = new aws.TranscribeService()` please import like this – megasubhash Jun 15 '21 at 17:18
  • I did, but it still doesn't work. I also set up AWS Polly and here I get the same two errors (timeout or unable to connect to instance metadata service) as well. – Maurice Jun 15 '21 at 17:52
  • Can you please hard code the .env data like region and try – megasubhash Jun 15 '21 at 17:56
  • I did. Now it's SyntaxError: The requested module './libs/transcribeClient.js' does not provide an export named 'transcribeClient'. – Maurice Jun 16 '21 at 18:30