2013-10-05 39 views
1

我在Windows 7中創建了文本到語音的代碼並安裝了Microsoft Speech SDK。當我在Internet Explorer中打開此代碼時,沒有任何反應。在Internet Explorer中的文本到語音

<html> 
    <head> 
    </head> 
    <body> 
    <input type="text" name="textinput" size="30"> 
    <script type="text/vbscript"> 
    Sub SpeakIt 
     Dim msg, sapi 
     msg= textinput.Value 
     Set sapi=CreateObject("sapi.spvoice") 
     sapi.Speak msg 
    End Sub 
    </script> 
    <input type="button" value="speak" onClick="SpeakIt"> 
    </body> 
</html> 
+0

此代碼將使用安裝在用戶計算機上的桌面SR引擎,而不是顯然安裝的服務器SR引擎(Microsoft Speech SDK是服務器SR引擎)。你想在服務器端完成TTS嗎?然後你需要將腳本標記爲'runat = server'(我相信)。 –

回答

2

你需要一個呼籲讀字功能brakets講按鈕 那麼試試這個:

<html> 
<head> 
</head> 
<body> 
    <input type="text" name="textinput" size="30"> 
    <script type="text/vbscript"> 
    Sub SpeakIt 
     Dim msg, sapi 
     msg= textinput.Value 
     Set sapi=CreateObject("sapi.spvoice") 
     sapi.Speak msg 
    End Sub 
</script> 
<input type="button" value="speak" onClick="SpeakIt()"> 
</body> 
</html> 

當然,用戶將被警告的頁面上運行ActiveX腳本。

0

爲了以防萬一,我必須證明可以使用另一個已安裝的語音。

<script type="text/vbscript" language="VBScript"> 
      Sub SpeakIt 
       Dim msg, sapi 

       msg = "Stackoverflow is the best website to find solutions!" 

       Set sapi=CreateObject("sapi.spvoice") 
       ' Use it to see installed voices 
       'For Each Voice In sapi.getvoices 
       ' I = I + 1 
       ' msgbox "" & (I - 1) & " - " & Voice.GetDescription 
       'Next 

       with sapi 
        Set .voice = .getvoices.item(1) ' I use second installed voice 
        .Volume = 100 
        .Rate = -4 
       end with 

       sapi.Speak msg 
      End Sub 

      Sub OnLoad 
       SpeakIt 
      End Sub 
    </script> 
</head> 
<body onload="OnLoad()" scroll="no">