Android 文本到语音的音量没有改变 [英] Android text to speech volume not changing
本文介绍了Android 文本到语音的音量没有改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Android Studio 应用中,以下音量没有变化;它保持在最响亮的设置.注释代码已折旧,但仍在工作.我如何使用捆绑包中的新 API?
In an Android Studio app, the volume in the following is not changing; it remains at the loudest setting. The commented code is depreciated, but is working. How do I use the bundle in the new API?
public void speakthetext2(String s) {
final String msg = s;
tts = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status != TextToSpeech.ERROR) {
//HashMap<String, String> params = new HashMap<>();
//params.put(KEY_PARAM_VOLUME, "0.20");
Bundle b = new Bundle();
b.putString(KEY_PARAM_VOLUME,"0.10");
tts.speak(msg, TextToSpeech.QUEUE_ADD, b, "1");
//noinspection deprecation
//tts.speak(msg, TextToSpeech.QUEUE_FLUSH, params);
} else {
Toast.makeText(getApplicationContext(), "tts error!", Toast.LENGTH_LONG).show();
}
}
});
}
推荐答案
使用
b.putFloat(KEY_PARAM_VOLUME, 0.1f);
而不是 putString.
instead of putString.
这篇关于Android 文本到语音的音量没有改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文