Today in the development of a text to voice function , Into a lot of holes .

First of all, I use iFLYTEK's online speech synthesis technology . When he's done, he can read it on a lower version of the phone , But a higher version 7.0 I can't read the above , I can't understand what to read .

My code is posted below :  First of all, the iFLYTEK official website was created and applied , Get it APPID  And then generate sdk jar package   I won't take this out   It's very simple. Just go to the official website

This is the tool class of text to voice :
public class AudioUtils { private static AudioUtils audioUtils; private
SpeechSynthesizer mySynthesizer; public AudioUtils() { } /** * describe : Single case * author : Bu Junwen *
mailbox :[email protected] * Creation time : 2016/8/19 14:38 */ public static AudioUtils
getInstance() { if (audioUtils == null) { synchronized (AudioUtils.class) { if
(audioUtils == null) { audioUtils = new AudioUtils(); } } } return audioUtils;
} private InitListener myInitListener = new InitListener() { @Override public
void onInit(int code) { Log.d("mySynthesiezer:", "InitListener init() code = "
+ code); } }; /** * describe : Initialize voice configuration * author : Bu Junwen * mailbox :[email protected] * Creation time : 2016/8/19
14:38 */ public void init(Context context) { // Processing key classes of speech synthesis mySynthesizer =
SpeechSynthesizer.createSynthesizer(context, myInitListener); // Set speaker
mySynthesizer.setParameter(SpeechConstant.VOICE_NAME, "xiaoyan"); // Set tone
mySynthesizer.setParameter(SpeechConstant.PITCH, "50"); // set volume
mySynthesizer.setParameter(SpeechConstant.VOLUME, "50");
mySynthesizer.setParameter(SpeechConstant.ENGINE_TYPE,SpeechConstant.TYPE_CLOUD);
} /** * describe : Convert and play audio based on incoming text * author : Bu Junwen * mailbox :[email protected] * Creation time : 2016/8/19
14:39 */ public void speakText(String content) { int code =
mySynthesizer.startSpeaking(content, new SynthesizerListener() { @Override
public void onSpeakBegin() { } @Override public void onBufferProgress(int i,
int i1, int i2, String s) { } @Override public void onSpeakPaused() { }
@Override public void onSpeakResumed() { } @Override public void
onSpeakProgress(int i, int i1, int i2) { } @Override public void
onCompleted(SpeechError speechError) { } @Override public void onEvent(int i,
int i1, int i2, Bundle bundle) { } }); } }
When using Application register   Initialize it ,
SpeechUtility.createUtility(getApplicationContext(),
"appid= It was generated when you created the app APPID");
AudioUtils.getInstance().init(getApplicationContext());
use :
AudioUtils.getInstance().speakText(" Hello ");
I don't know how to fit a new version of mobile phone , So it's not in this way .

I use it Android  The system's own text to speech   It's very simple and easy to use ,( Simple and crude to achieve the effect you want directly )

Code directly :
private TextToSpeech mTextToSpeech; private void speakChina(){ // Set reading language
mTextToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override public void onInit(int status) { if (status==TextToSpeech.SUCCESS) {
// Set reading language int supported= mTextToSpeech.setLanguage(Locale.US); if
((supported!=TextToSpeech.LANG_AVAILABLE)&&(supported!=TextToSpeech.LANG_COUNTRY_AVAILABLE))
{ Toast.makeText(sAppContext, " The current language is not supported !", Toast.LENGTH_SHORT).show(); } } } });
} A method of encapsulation
use  
mTextToSpeech.speak(" Fill in the text you want to convert into speech ", TextToSpeech.QUEUE_FLUSH, null);
All right, this realizes the function of text to speech .

I hope it can help the apes !