gpt4 book ai didi

java - AWS Translate 代码引发无法解码错误

转载 作者:行者123 更新时间:2023-12-01 19:00:36 25 4
gpt4 key购买 nike

我正在尝试使用 AWS-translate 翻译 s3 存储桶中的 mp3 文件。目前,我抛出以下错误。我的代码是:

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;
}
}

我得到的错误是:

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

我正在寻找此错误的原因,或者至少了解如何引发此特定错误。任何帮助表示赞赏。谢谢。

最佳答案

在 Boris 思想的帮助下,我发现我对 s3 和转录使用了不同的版本。

关于java - AWS Translate 代码引发无法解码错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59642815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com