Android的文本到语音和号码 [英] Android Text To Speech And Numbers

查看:117
本文介绍了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;
}

这篇关于Android的文本到语音和号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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