Search code examples
amazon-web-servicesamazon-s3aws-java-sdkamazon-transcribe

Access results of AWS Transcribe job with Java SDK


I have a AWS Transcribe job that gives me a URI when completed. This URI should be where the transcription text is stored. I want to access that text with the Java SDK, but GetObject does not seem to support this option. How do I access the text from the Transcribe job?

// I am given this
String URI = job.getTranscript().getTranscriptFileUri();
// I want to do this
S3Object transcript = s3.getObject(URI);

Solution

  • You need to parse the bucket and the object key from the given URI, or you can use the provided class from AWS SDK, the AmazonS3URI. Then do as follows:

    String URI = job.getTranscript().getTranscriptFileUri();
    AmazonS3URI s3ObjectURI = new AmazonS3URI(URI);
    S3Object transcript = s3.getObject(s3ObjectURI.getBucket(), s3ObjectURI.getKey());