Why doesn't my java transcribe job return the correct status?

0

When I check the status through the API it remains in progress forever, but it does complete according to the dashboard. What am I missing?

StartTranscriptionJobRequest request = buildVTTRequest(subFolder, audioFileId, userId);
StartTranscriptionJobResult response = transcribeClient.startTranscriptionJob(request);
TranscriptionJob transcriptionJob = response.getTranscriptionJob();
StartTranscriptionJobResult response = transcribeClient.startTranscriptionJob(request);
TranscriptionJob transcriptionJob = response.getTranscriptionJob();
Boolean inProgress = transcriptionJob.getTranscriptionJobStatus().equalsIgnoreCase(TranscriptionJobStatus.IN_PROGRESS.name());

private static StartTranscriptionJobRequest buildVTTRequest(String subFolder, String audioFileId, Long userId) throws WIOSException {
        StartTranscriptionJobRequest request = new StartTranscriptionJobRequest();
        request.setMediaSampleRateHertz(16000);
        request.setMediaFormat("mp3");
        request.setLanguageCode("en-US");
        request.setTranscriptionJobName(userId.toString());
		
        Media media = new Media();
	String s3BucketURI = "...";
        media.setMediaFileUri(s3BucketURI);
        request.setMedia(media);
	request.setOutputBucketName("...");
	request.setOutputKey("...");
        return request;
    }

asked a month ago24 views
1 Answer
0
  1. Polling Delay The most common reason for this is that your check for the status might be happening before the transcription job has finished. In AWS Transcribe, even though the job completes in the dashboard, it can take a little time for the status to reflect in the API.

Solution: Implement a delay or polling mechanism to check the transcription job status at regular intervals. Don't check the status immediately after starting the job. Here's how you can modify your code:

// Start the transcription job StartTranscriptionJobRequest request = buildVTTRequest(subFolder, audioFileId, userId); StartTranscriptionJobResult response = transcribeClient.startTranscriptionJob(request); TranscriptionJob transcriptionJob = response.getTranscriptionJob();

// Poll the job status boolean inProgress = true; while (inProgress) { transcriptionJob = transcribeClient.getTranscriptionJob(new GetTranscriptionJobRequest().withTranscriptionJobName(transcriptionJob.getTranscriptionJobName())).getTranscriptionJob(); String status = transcriptionJob.getTranscriptionJobStatus();

// Log or debug the status here
System.out.println("Current status: " + status);

if (status.equalsIgnoreCase(TranscriptionJobStatus.COMPLETED.name()) ||
    status.equalsIgnoreCase(TranscriptionJobStatus.FAILED.name())) {
    inProgress = false;
} else {
    // Sleep for a while before checking again
    Thread.sleep(5000);  // Sleep for 5 seconds
}

}

// Once the loop ends, you can check the status if (transcriptionJob.getTranscriptionJobStatus().equalsIgnoreCase(TranscriptionJobStatus.COMPLETED.name())) { // Handle the completed job System.out.println("Transcription job completed successfully."); } else { // Handle failure System.out.println("Transcription job failed."); } This will periodically check the job status every 5 seconds and will break when the status is either COMPLETED or FAILED.

  1. Check Status Using GetTranscriptionJob It seems like you're trying to check the job status immediately after starting it, but the job may not have updated yet. You need to poll for the job status using the GetTranscriptionJob API, as you are doing in the code above, but ensure you're doing so after some delay.

  2. Ensure Proper Transcription Job Status Handling It is important that your job status handling is robust. You're already checking for IN_PROGRESS, but you should also be handling other statuses like COMPLETED, FAILED, or STOPPED. Always handle edge cases where the job might not be in progress, especially if it fails.

  3. Verify the Job Name Ensure that the transcription job name (userId.toString()) is unique, as reusing a job name could result in issues where the API might return incorrect status for a previously initiated job. AWS Transcribe requires unique job names, and if there's a conflict, it can cause unexpected results.

  4. Check TranscriptionJob Response Sometimes there might be an issue with how the TranscriptionJob is being returned. Add additional logging to check the complete details of the response from the startTranscriptionJob call.

System.out.println("Transcription Job started: " + transcriptionJob.getTranscriptionJobName()); This will help you track the job and its status more effectively.

  1. Timeout or Errors Ensure that your client is not timing out or encountering errors. If you're continuously polling for the status of a transcription job, make sure you're not hitting any API rate limits or experiencing connection issues.

regards, https://zeonedge.com

answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions