如何设置体积为文本到语音"说话"方法?体积、如何设置、语音、文本

2023-09-05 08:17:44 作者:红嫁衣。

我在失落。我希望能够调节音量说话。无论我做什么,我不能增加它的体积。我如何让它大声,在Android设置中(如下图)?

系统设置 - >语音输入和输出 - >文本到语音设置 - >听一个例子

我的code在这一刻是:

  AudioManager mAudioManager =(AudioManager)getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setSpeakerphoneOn(真正的);
INT loudmax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION);
mAudioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION,loudmax,AudioManager.FLAG_PLAY_SOUND);
mTts.speak(姓名,TextToSpeech.QUEUE_FLUSH,NULL);
 

解决方案

尝试使用 AudioManager.STREAM_MUSIC 调用时, setStreamVolume(...) 方法。这个例子的讲话被媒体音量影响,如果我调整音乐播放的音量在我的手机,所以我想 STREAM_MUSIC 是你所需要的。

编辑::此code完美的作品对我来说...

  AudioManager上午=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
INT amStreamMusicMaxVol = am.getStreamMaxVolume(am.STREAM_MUSIC);
am.setStreamVolume(am.STREAM_MUSIC,amStreamMusicMaxVol,0);
tts.speak(你好,TextToSpeech.QUEUE_FLUSH,NULL);
 

在最大音量的 STREAM_MUSIC 我的手机是15,我甚至通过更换测试了这个 amStreamMusicMaxVol 的我呼吁 am.setStreamVolume(...)上面的值3,6,9,12,15,并设置正确的讲话音量。

Win7文本到语音转换怎么不能用啊

I'm at a lost. I want to be able to adjust the speak volume. Whatever I do, I can't increase its volume. How do I make it as loud as that found in the Android settings (as below)?

System Settings -> Voice input and output -> Text-to-Speech settings -> Listen to an example

My code at this moment is:

AudioManager mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setSpeakerphoneOn(true);
int loudmax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_NOTIFICATION);
mAudioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION,loudmax, AudioManager.FLAG_PLAY_SOUND);
mTts.speak(name,TextToSpeech.QUEUE_FLUSH, null);

解决方案

Try using AudioManager.STREAM_MUSIC when calling the setStreamVolume(...) method. The example speech is affected by the media volume if I adjust the volume of music playback on my phone so I guess STREAM_MUSIC is what you need.

EDIT: This code works perfectly for me...

AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
int amStreamMusicMaxVol = am.getStreamMaxVolume(am.STREAM_MUSIC);
am.setStreamVolume(am.STREAM_MUSIC, amStreamMusicMaxVol, 0);
tts.speak("Hello", TextToSpeech.QUEUE_FLUSH, null);

The max volume for STREAM_MUSIC on my phone is 15 and I've even tested this by replacing amStreamMusicMaxVol in my call to am.setStreamVolume(...) above with the values 3, 6, 9, 12, 15 and the volume of the speech is correctly set.