Java 如何在TextToSpeech android上添加换行符?

Java 如何在TextToSpeech android上添加换行符?,java,android,text-to-speech,Java,Android,Text To Speech,我在安卓系统中使用TextToSpeech阅读文本。在我的例子中,我有4个字符串要读取,字符串之间几乎没有延迟。我在字符串的末尾加上了句号。但它读起来像点。这是我试过的 public class TextToSpeechUtil implements TextToSpeech.OnInitListener, TextToSpeech.OnUtteranceCompletedListener { private Activity activity; private String m

我在安卓系统中使用TextToSpeech阅读文本。在我的例子中,我有4个字符串要读取,字符串之间几乎没有延迟。我在字符串的末尾加上了句号。但它读起来像点。这是我试过的

public class TextToSpeechUtil implements TextToSpeech.OnInitListener, TextToSpeech.OnUtteranceCompletedListener {
    private Activity activity;
    private String message;
    private TextToSpeech tts;

    public TextToSpeechUtil(Activity activity, String message) {
        this.activity = activity;
        this.message = message;
        tts = new TextToSpeech(activity, this);
        tts.setLanguage(Locale.US);

    }


    public void shutdown() {
        // Don't forget to shutdown tts!
        if (tts != null) {
            tts.stop();
            tts.shutdown();
        }

    }

    @Override
    public void onInit(int status) {

        if (status == TextToSpeech.SUCCESS) {
            int result = tts.setLanguage(Locale.US);

            if (result == TextToSpeech.LANG_MISSING_DATA
                    || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                Log.e("TTS", "This Language is not supported");
            } else {
                speakOut();
            }
            tts.setOnUtteranceCompletedListener(this);
        } else {
            Log.e("TTS", "Initilization Failed!");
        }
    }

    private void speakOut() {
        HashMap<String, String> hashAlarm = new HashMap<>();
        hashAlarm.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, message);
        tts.speak(message, TextToSpeech.QUEUE_FLUSH, hashAlarm);
    }

    @Override
    public void onUtteranceCompleted(String utteranceId) {
        shutdown();
    }
}
这些字符串正在连续读取。如何修复此问题?

如果在每个字符串的末尾添加一个\n,会发生什么情况?它与换行符一起工作。谢谢
     static Timer timing;
   while (st.hasMoreTokens()) {  
            tts.speak(st.nextToken()//(or) your string, TextToSpeech.QUEUE_ADD, null); 
        } 
        if (timing != null) { 
            timing.cancel();  
            timing = null;  
        }  
        String strRepeat="Repeat";
        timing = new Timer();
        timing.schedule(new Updater(con,txt_title,strRepeat), 20000,20000);


 public void onInit(int status) {
    // TODO Auto-generated method stub

    if (status == TextToSpeech.SUCCESS) {
        check_ttsComplete=status;
        int result = tts.setLanguage(Locale.getDefault());

        if (result == TextToSpeech.LANG_MISSING_DATA
                || result == TextToSpeech.LANG_NOT_SUPPORTED) {
            Toast.makeText(this, "Language not supported",     Toast.LENGTH_LONG).show();
            Log.e("TTS", "Language is not supported");
        } else {
            //              btnSpeak.setEnabled(true);
        }

    } else {
        Log.e("TTS", "Initilization Failed");
    }

}
 @Override
public void onUtteranceCompleted(String uttId) {
    Toast.makeText(Activity.this,"done", Toast.LENGTH_LONG).show();
    if (uttId.equalsIgnoreCase("done")) {
        Toast.makeText(Activity.this,"inside done", Toast.LENGTH_LONG).show();
    } 
}
     static Timer timing;
   while (st.hasMoreTokens()) {  
            tts.speak(st.nextToken()//(or) your string, TextToSpeech.QUEUE_ADD, null); 
        } 
        if (timing != null) { 
            timing.cancel();  
            timing = null;  
        }  
        String strRepeat="Repeat";
        timing = new Timer();
        timing.schedule(new Updater(con,txt_title,strRepeat), 20000,20000);


 public void onInit(int status) {
    // TODO Auto-generated method stub

    if (status == TextToSpeech.SUCCESS) {
        check_ttsComplete=status;
        int result = tts.setLanguage(Locale.getDefault());

        if (result == TextToSpeech.LANG_MISSING_DATA
                || result == TextToSpeech.LANG_NOT_SUPPORTED) {
            Toast.makeText(this, "Language not supported",     Toast.LENGTH_LONG).show();
            Log.e("TTS", "Language is not supported");
        } else {
            //              btnSpeak.setEnabled(true);
        }

    } else {
        Log.e("TTS", "Initilization Failed");
    }

}
 @Override
public void onUtteranceCompleted(String uttId) {
    Toast.makeText(Activity.this,"done", Toast.LENGTH_LONG).show();
    if (uttId.equalsIgnoreCase("done")) {
        Toast.makeText(Activity.this,"inside done", Toast.LENGTH_LONG).show();
    } 
}