Android TTS是否支持语音合成标记语言?

时间:2010-08-19 19:21:17

标签: android text-to-speech ssml

将以下SSML(Speech Synthesis Markup Language)文档传递给com.svox.pico TextToSpeech引擎会导致读取XML正文,但无法通过音素元素或强调元素进行控制。这个结果(没有明显的SSML控制)在运行Android 2.2的Nexus One以及运行SDK级别为8的AVD的模拟器上是相同的。

            String text = "<?xml version=\"1.0\"?>" +
                "<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" " +
                    "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
                    "xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis " +
                        "http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" " +
                    "xml:lang=\"en-US\">" +

                    "tomato " +
                    "<phoneme alphabet=\"ipa\" ph=\"t&amp;#x259;mei&amp;#x325;&amp;#x27E;ou&amp;#x325;\"> tomato </phoneme> " +

                    "That is a big car! " +
                    "That <emphasis> is </emphasis> a big car! " +
                    "That is a <emphasis> big </emphasis> car! " +
                    "That is a huge bank account! " +
                    "That <emphasis level=\"strong\"> is </emphasis> a huge bank account! " +
                    "That is a <emphasis level=\"strong\"> huge </emphasis> bank account!" +
                "</speak>";
            mTts.speak(text, TextToSpeech.QUEUE_ADD, null);

是否有任何Android TTS引擎支持任何SSML元素?

3 个答案:

答案 0 :(得分:3)

我一直在尝试使用SSML,似乎TTS引擎使用根<speak>元素自动包装其输入,所以如果你把它留下来,那么它工作正常而且你没有得到解析器错误。

示例:

String text = "Testing <phoneme alphabet=\"xsampa\" ph=\"&#34;{k.t@`\"/>.";
mTts.speak(text, TextToSpeech.QUEUE_ADD, null);

答案 1 :(得分:2)

答案似乎是“某种”。并非所有SSML标记都受支持,但使用<phoneme>标记的一些测试示例位于https://android.googlesource.com/platform/external/svox/+/89292811b7fe82e5c14fa13942779763627e26db

虽然测试示例产生了所需的语音输出,但它们也会在logcat中生成XML解析器错误消息。我在Android问题跟踪器(问题11010)上打开了有关这些看似不正确的错误消息的问题。

答案 2 :(得分:0)

看来SDK级别23的android.speech.tts支持SSML的子集。语音文本可以包含在<speak>标记中,并且<say-as>会被观察到,而<break>则不会。没有关于SSML支持的文档。