- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 IVONA SpeachCloud SDK(创建语音示例):https://github.com/IvonaSoftware/ivona-speechcloud-sdk-java/blob/master/src/samples/IvonaSpeechCloudCreateSpeech/SampleIvonaSpeechCloudCreateSpeech.java
使用此代码设置类路径
private static IvonaSpeechCloudClient speechCloud;
private static void init() {
speechCloud = new IvonaSpeechCloudClient(
new ClasspathPropertiesFileCredentialsProvider("IvonaCredentials.properties"));
speechCloud.setEndpoint("https://tts.eu-west-1.ivonacloud.com");
}
以下是 ivona.properties 文件的格式。文件位于基本目录中。我的 SpeechCloud 帐户中拥有所需的凭据
accessKey = mykey
secretKey = mysecretKey
下面是我遇到的异常
Exception in thread "main" com.amazonaws.AmazonClientException: Unable to load AWS credentials from the /resources/ivona.properties file on the classpath
at com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider.getCredentials(ClasspathPropertiesFileCredentialsProvider.java:81)
at com.ivona.services.tts.IvonaSpeechCloudClient.prepareRequest(IvonaSpeechCloudClient.java:279)
at com.ivona.services.tts.IvonaSpeechCloudClient.prepareRequest(IvonaSpeechCloudClient.java:272)
at com.ivona.services.tts.IvonaSpeechCloudClient.invoke(IvonaSpeechCloudClient.java:259)
at com.ivona.services.tts.IvonaSpeechCloudClient.createSpeech(IvonaSpeechCloudClient.java:148)
at SampleIvonaSpeechCloudCreateSpeech.main(SampleIvonaSpeechCloudCreateSpeech.java:45
我怎样才能解决这个异常,或者我怎样才能创建一个类来解决这个问题并手动输入我的accessKey和secretKey作为字符串。谢谢。
最佳答案
好吧,在对源文件进行了几个小时的研究之后,我发现了这一点。您可以创建自己的提供程序类,在其中可以将凭据作为字符串参数传递。
这是我的自定义凭证类“IvonaCredentials”
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider;
public class IvonaCredentials implements AWSCredentialsProvider{
public IvonaCredentials(String mSecretKey, String mAccessKey) {
super();
this.mSecretKey = mSecretKey;
this.mAccessKey = mAccessKey;
}
private String mSecretKey;
private String mAccessKey;
@Override
public AWSCredentials getCredentials() {
AWSCredentials awsCredentials = new AWSCredentials() {
@Override
public String getAWSSecretKey() {
// TODO Auto-generated method stub
return mSecretKey;
}
@Override
public String getAWSAccessKeyId() {
// TODO Auto-generated method stub
return mAccessKey;
};
};
return awsCredentials;
}
@Override
public void refresh() {
// TODO Auto-generated method stub
}
}
这就是我如何称呼我的类(class)
private static void init() {
speechCloud = new IvonaSpeechCloudClient(new IvonaCredentials("secretKey", "accessKey"));
speechCloud.setEndpoint("https://tts.eu-west-1.ivonacloud.com");
}
关于java - 无法加载 AWS Ivona 属性文件 Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35270354/
我安装了 https://play.google.com/store/apps/details?id=com.ivona.tts和他们所有的声音。我如何以编程方式从 ivona tts 获取所有已安装
我正在使用 IVONA SpeachCloud SDK(创建语音示例):https://github.com/IvonaSoftware/ivona-speechcloud-sdk-java/blob
我想加载多种语言以将 IVONA SDK 与适用于 iPhone 的 SSML 一起使用。没有在Xcode/objective-C 中使用的文档,只给出了 SDK 本身和几个 C/java 示例。 如
我已经开始使用 IVONA TTS,AWS 是它的依赖项,所以我也将其导入到项目中。我的问题是,当运行示例 Java 应用程序时,我会收到以下错误: Exception in thread "main
我正在尝试根据 this documnent 实现 Ivona 请求签名 一切正常,所有结果都与示例值匹配,签名结果除外。所以我的签名结果是 cf1141e33a8fbba23913f8f36f29f
我目前正在试用适用于 iOS 的 ivona SDK,声音很棒,非常非常自然。 但是我正在使用的声音(德国女性)有一个文件大小为 230 MB 的语音文件。 当我想使用 4 种声音时,我的应用大约有
我是一名优秀的程序员,十分优秀!