Android的文本到语音和号码

问题描述:

我使用的阅读一些文字的Andr​​oid文本到语音引擎和它的工作。但我的文本中包含数字和我想要的号码逐位进行读出位。

I am using Android Text to Speech engine for reading some text and it's working. But my text contains numbers and I want the numbers to be read digit by digit.

我找不到文档中任何东西,但我仍然希望有人知道我怎么能做到这一点。

I couldn't find anything in the documentation, but I am still hoping someone knows how I can do that.

该API不允许您指定文本应阅读让你的code的修改文字输入,所以它读取的个体数

The API does not allow you to specify how the text should be read so your code has to modify the text input so that it reads the individual numbers.

我建议增加一个空间中的每个数字之间。这应该引起 TextToSpeech 阅读各个数字。

I suggest adding a space in between each number. That should cause the TextToSpeech to read the individual numbers.

如果你需要一些code帮你侦测数字使用:

If you need some code to help you detect numbers use this:

private boolean isNumber(String word)
{
    boolean isNumber = false;
    try
    {
        Integer.parseInt(word);
        isNumber = true;
    } catch (NumberFormatException e)
    {
        isNumber = false;
    }
    return isNumber;
}