AWS Polly Java Client出现错误:无法从链中的任何提供者加载区域信息
我正在使用AWS的JavaSDK创建一个Polly客户端。 像这样:AWS Polly Java Client出现错误:无法从链中的任何提供者加载区域信息,java,amazon-web-services,amazon-iam,amazon-polly,Java,Amazon Web Services,Amazon Iam,Amazon Polly,我正在使用AWS的JavaSDK创建一个Polly客户端。 像这样: BasicAWSCredentials awsCreds = new BasicAWSCredentials("<IAM access Key>", "IAM secret key>"); AmazonPollyClient apClient = (AmazonPollyClient) AmazonPollyClientBuilder.standard() .withCred
BasicAWSCredentials awsCreds = new BasicAWSCredentials("<IAM access Key>", "IAM secret key>");
AmazonPollyClient apClient = (AmazonPollyClient) AmazonPollyClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.build();
SynthesizeSpeechRequest tssRequest = new SynthesizeSpeechRequest();
tssRequest.setText(<text>);
tssRequest.setVoiceId(<voiceid>);
tssRequest.setOutputFormat(OutputFormat.Mp3);
SynthesizeSpeechResult tssResult = apClient.synthesizeSpeech(tssRequest);
更新2:
在de.aws文件夹中创建包含以下内容的配置文件时:
[默认值]
地区=欧盟西部-1
它可以工作,但我需要一种不依赖于文件系统的方法来设置它。提供一个名为“AWS\u REGION”的系统环境变量就成功了。 请参阅IBM Bluemix中的配置屏幕截图
我想你可以这样设置区域
AmazonPollyClient apClient = (AmazonPollyClient) AmazonPollyClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCreds)).withRegion("<aws-region>").build();
AmazonPollyClient apClient=(AmazonPollyClient)AmazonPollyClientBuilder.standard()。带有凭证(新的AWSStaticCredentialsProvider(awsCreds))。带有区域(“”.build();
或者更好的方法-。例如,使用Region(Region.US\u WEST\u 1)
。
AmazonPollyClient apClient = (AmazonPollyClient) AmazonPollyClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCreds)).withRegion("<aws-region>").build();