2014-02-22 83 views
9

Web Speech API specification正確的方式說:使用SSML與網絡語音API

文本屬性
該屬性指定發言的這段話要合成的文本和 。這可以是純文本,也可以是完整的格式良好的SSML文檔。對於不支持SSML的語音合成引擎 ,或者僅支持某些標籤,代理或語音引擎必須剝離它們不支持的標籤 並說出文字。

它沒有提供使用text和SSML文檔的示例。

我試着在Chrome 33以下:

var msg = new SpeechSynthesisUtterance(); 
msg.text = '<?xml version="1.0"?>\r\n<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US">ABCD</speak>'; 
speechSynthesis.speak(msg); 

它沒有工作 - 語音試圖講述的XML標記。這段代碼是否有效?
我必須提供XMLDocument對象嗎?

我想了解Chrome是否違反規範(應該將其報告爲錯誤),或者我的代碼是否無效。

+0

你有沒有解決過這個問題?我可以在SSML和chrome上找到的最接近的東西是Chrome插件語音合成的文檔https://developer.chrome.com/extensions/tts – ElDog

+0

您還在使用Linux。因爲看起來可能有問題https://code.google.com/p/chromium/issues/detail?id=88072 – ElDog

+0

@ElDog我發現的只是那個bug(我在那裏評論過) - 順便說一句我閱讀了它在Mac/Win中沒有實現的描述。 –

回答

4

在Chrome 46中,當語言設置爲en時,XML被正確解釋爲XML文檔;在Windows中,但是,我沒有看到任何證據表明標籤實際上在做任何事情。我聽到了<emphasis>和非<emphasis>版本這個SSML的沒有區別:

var msg = new SpeechSynthesisUtterance(); 
msg.text = '<?xml version="1.0"?>\r\n<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US"><emphasis>Welcome</emphasis> to the Bird Seed Emporium. Welcome to the Bird Seed Emporium.</speak>'; 
msg.lang = 'en'; 
speechSynthesis.speak(msg); 

<phoneme>標籤也完全忽略了,這使我試圖講IPA失敗。

var msg = new SpeechSynthesisUtterance(); 
msg.text='<?xml version="1.0" encoding="ISO-8859-1"?> <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"> Pavlova is a meringue-based dessert named after the Russian ballerina Anna Pavlova. It is a meringue cake with a crisp crust and soft, light inside, usually topped with fruit and, optionally, whipped cream. The name is pronounced <phoneme alphabet="ipa" ph="p&aelig;v&#712;lo&#650;v&#601;">...</phoneme> or <phoneme alphabet="ipa" ph="p&#593;&#720;v&#712;lo&#650;v&#601;">...</phoneme>, unlike the name of the dancer, which was <phoneme alphabet="ipa" ph="&#712;p&#593;&#720;vl&#601;v&#601;">...</phoneme> </speak>'; 
msg.lang = 'en'; 
speechSynthesis.speak(msg); 

儘管這是一個事實,即Microsoft語音API 確實正確處理SSML。這裏是一個C#片段,適用於LinqPad

var str = "Pavlova is a meringue-based dessert named after the Russian ballerina Anna Pavlova. It is a meringue cake with a crisp crust and soft, light inside, usually topped with fruit and, optionally, whipped cream. The name is pronounced /pævˈloʊvə/ or /pɑːvˈloʊvə/, unlike the name of the dancer, which was /ˈpɑːvləvə/."; 
var regex = new Regex("/([^/]+)/"); 
if (regex.IsMatch(str)) 
{ 
    str = regex.Replace(str, "<phoneme alphabet=\"ipa\" ph=\"$1\">word</phoneme>"); 
    str.Dump(); 
} 
SpeechSynthesizer synth = new SpeechSynthesizer(); 
PromptBuilder pb = new PromptBuilder(); 
pb.AppendSsmlMarkup(str); 
synth.Speak(pb); 
+0

這裏同樣的問題。 – Griffork

+0

使用目前的Chrome 55.0,它甚至不識別XML。我的發言(味精)是說像「不足問題標誌的電子版本相等報價一分零報價...」 –

+0

我不認爲SSML支持:( – Shu

4

這個問題目前用Chromium打開有bug。

  • 88072:擴展TTS API平臺的實現需要支持SSML
  • 428902 speechSynthesis.speak()不會刪除無法識別的標籤 此bug已被固定在Chrome爲2016年九月的
+1

和428902倒退:/它仍然在這裏。 – Qix