gpt4 book ai didi

java - Android编程: ANDROID_CONTEXT parameter is not passed in error

转载 作者:太空宇宙 更新时间:2023-11-04 13:19:23 24 4
gpt4 key购买 nike

我正在使用 Nuance SpeechKit 编写一个执行 TTS 的应用程序。它需要将上下文(从 getApplicationContext() 调用)传递到某些函数中。不幸的是,我在日志中收到此错误:ANDROID_CONTEXT 参数未传入!!!

让我提供更多背景信息:在一个主要 Activity 中,它通过按钮打开一个对话框。该对话框调用文本转语音功能。因此,我在主 Activity 中调用 getApplicationContext() 并使用 setter 将其作为参数传递给我的 DialogFragment。不幸的是,即使我调用 setter ,我也会收到此错误。那么可能出了什么问题呢?这是一些代码:

在我的主要 Activity 中:

// Instance variables...
private SpeechKit speechKit;
private Context context;

protected void onCreate(Bundle savedInstanceState) {
...
context = getApplicationContext();
...
this.speechKit = SpeechKit.initialize(context,
"CORRECT_API_KEY",
"sslsandbox.nmdp.nuancemobility.net",
443,
true,
SpeechKitAPIKey);
speechKit.connect();
}

public void invokeDialog() {
...
dialogueFragment.setContext(context);
dialogueFragment.setSpeechKit(speechKit);
...
}

这是我的对话框 fragment 代码:

   public void setSpeechKit(SpeechKit speechKit) {
this.speechKit = speechKit;
}

private SpeechKit speechKit;
private Context context;

public void setSpeechKit(SpeechKit speechKit) {
this.speechKit = speechKit;
}

public void setContext(Context context) {
this.context = context;
}

// Called when a button is pushed...
public void narrateText(String voice, String phrase) {
Vocalizer vocalizer = speechKit.createVocalizerWithVoice(voice, this, handler);
vocalizer.speakString(phrase, context);
}

现在我不知道为什么会出现这个错误。该代码编译良好。请问有什么建议吗?

最佳答案

我也遇到了同样的问题,结果是我的免费帐户过期了(有效期为 90 天)。

您发送的登录信息可能不再有效。

关于java - Android编程: ANDROID_CONTEXT parameter is not passed in error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33244768/

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