2

I am trying to use AWS-translate to translate an mp3 file in an s3 bucket. Currently, I have the error below being thrown. My code is:

public class ProviderTranscribeController {

private static final Logger LOGGER = Logger.getLogger(ProviderTranscribeController.class);

private AmazonTranscribe client = AmazonTranscribeClient.builder().withRegion(Regions.EU_WEST_2).build();
final AmazonS3 s3 = AmazonS3ClientBuilder.standard().withRegion(Regions.EU_WEST_2).build();


public TranscriptionJob transcribeMp3(){
    StartTranscriptionJobRequest request = new StartTranscriptionJobRequest();
    request.withLanguageCode(LanguageCode.EsUS);
    Media media = new Media();

    media.setMediaFileUri(Uri);

    request.withMedia(media).withMediaSampleRateHertz(8000);
    String transcriptionJobName = "myJob";
    request.setTranscriptionJobName(transcriptionJobName);
    request.withMediaFormat("mp3");
    LOGGER.info(request.getLanguageCode());
    LOGGER.info(request.getMedia().getMediaFileUri());
    LOGGER.info(request.getMediaFormat());
    LOGGER.info(request.getMediaSampleRateHertz());
    LOGGER.info(request.getTranscriptionJobName());

    client.startTranscriptionJob(request);

    GetTranscriptionJobRequest jobRequest = new GetTranscriptionJobRequest();
    jobRequest.setTranscriptionJobName(transcriptionJobName);
    TranscriptionJob transcriptionJob;
    transcriptionJob = client.getTranscriptionJob(jobRequest).getTranscriptionJob();

    return transcriptionJob;
}
}

And the error I am getting is:

Unable to unmarshall error response (null). Response Code: 400, Response Text: Bad Request:   
com.amazonaws.SdkClientException
com.amazonaws.SdkClientException: Unable to unmarshall error response (null). Response Code:   
400, Response Text: Bad Request
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1708)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1367)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1113)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:770)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:744)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:726)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:686)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:668)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:532)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:512)
at com.amazonaws.services.transcribe.AmazonTranscribeClient.doInvoke(AmazonTranscribeClient.java:349)
at com.amazonaws.services.transcribe.AmazonTranscribeClient.invoke(AmazonTranscribeClient.java:325)
at com.amazonaws.services.transcribe.AmazonTranscribeClient.executeStartTranscriptionJob(AmazonTranscribeClient.java:289)
at com.amazonaws.services.transcribe.AmazonTranscribeClient.startTranscriptionJob(AmazonTranscribeClient.java:264)
at transcribe.back.providers.ProviderTranscribeController.transcribeMp3(ProviderTranscribeController.java:37)
at transcribe.back.services.ServiceCollectHttp.createTranscription(ServiceCollectHttp.java:27)
at transcribe.back.ApplicationHandler.handleRequest(ApplicationHandler.java:22)
at transcribe.back.ApplicationHandler.handleRequest(ApplicationHandler.java:13)
Caused by: java.lang.NullPointerException
at com.amazonaws.http.JsonErrorResponseHandler.unmarshallException(JsonErrorResponseHandler.java:134)
at com.amazonaws.http.JsonErrorResponseHandler.createException(JsonErrorResponseHandler.java:124)
at com.amazonaws.http.JsonErrorResponseHandler.handle(JsonErrorResponseHandler.java:91)
at com.amazonaws.http.JsonErrorResponseHandler.handle(JsonErrorResponseHandler.java:37)
at com.amazonaws.http.AwsErrorResponseHandler.handleAse(AwsErrorResponseHandler.java:53)
at com.amazonaws.http.AwsErrorResponseHandler.handle(AwsErrorResponseHandler.java:41)
at com.amazonaws.http.AwsErrorResponseHandler.handle(AwsErrorResponseHandler.java:26)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1694)
... 17 more

I am looking to find the cause of this error or at least understand how this particular error is thrown. Any help is appreciated. Thanks.

Hywel Griffiths
  • 287
  • 5
  • 16
  • What is `Uri` in `setMediaFileUri(Uri)`? – Boris Jan 08 '20 at 10:26
  • Its the uri for the file in the bucket with the format "https://s3.eu-west-2.amazonaws.com//.mp3" @Boris – Hywel Griffiths Jan 08 '20 at 11:52
  • I've now changed the format of the Uri to "s3:///.mp3" but to no avail... – Hywel Griffiths Jan 08 '20 at 12:41
  • 1
    What is the version of `aws-sdk-java` you are using? We could then look at the source of [JsonErrorResponseHandler.java](https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/http/JsonErrorResponseHandler.java) to see which variable is null. – Boris Jan 08 '20 at 14:51
  • 1
    Thanks Boris - my s3 and transcribe were different versions so I've made them the same and I seem to have progress! It just complaining over authorization now... @Boris – Hywel Griffiths Jan 09 '20 at 06:57

1 Answers1

1

With the help of Boris's thoughts I worked out I was using different versions for the s3 and transcribe.

Hywel Griffiths
  • 287
  • 5
  • 16