0

总是说最后的元素。但我想先说孟加拉国,然后是印度,然后巴尔马最后也说塔纳纳语。当我运行我的代码时,总是说 Tanana。

我的代码:

int wordNumber=0;
String[] splitspeech = { "Bangladesh", "India", "Barma",
                        "Banana", "Tanana" };
                do {
                    reader(splitspeech[wordNumber]);
                    wordNumber++;
                } while (wordNumber < splitspeech.length);


public void reader(final String msg) {
        Log.e("reader output:", "msg:" + msg);
        TextToSpeech textReader = new TextToSpeech(getApplicationContext(),
                new OnInitListener() {

                    @Override
                    public void onInit(int status) {
                        HashMap<String, String> map = new HashMap<String, String>();
                        map.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,
                                "Hello");

                        textReader.speak(msg,

                        TextToSpeech.QUEUE_FLUSH, map);

                    }
                });
    }

如何实现是根据循环说话。这意味着首先说第一元素,这意味着孟加拉国,最后说塔纳纳(最后一个元素)。请帮我。我不知道这是否容易。但这对我来说非常复杂。请帮我。谢谢

4

1 回答 1

1

Use QUEUE_ADD instead of QUEUE_FLUSH. You are clearing the TTS queue in this way.

于 2015-01-17T16:27:16.250 回答