如何设置体积为文本到语音"说话"方法? [英] How to set volume for text-to-speech "speak" method?

查看:125
本文介绍了如何设置体积为文本到语音"说话"方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在失落。我希望能够调节音量说话。无论我做什么,我不能增加它的体积。我如何让它大声,在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,并设置正确的讲话音量。

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.

这篇关于如何设置体积为文本到语音"说话"方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆