This is a aspx (2005) page. It should make my PC to speak, but it
does't work. Can anybody help me to make it work? Please!
<%@ Page Language="VB" AutoEventWireup ="false" CodeFile="Leggi .aspx.vb"
Inherits="_Defa ult" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Leggi Libro</title>
<SCRIPT LANGUAGE="JavaS cript">
// Create the Sapi SpVoice object
var VoiceObj = new ActiveXObject(" Sapi.SpVoice");
function ChangeVoice() {
var i = parseInt( idsVoices.value );
VoiceObj.Voice = VoiceObj.GetVoi ces().Item(i);
}
function IncRate() {
alert("Sono in incrate");
if( VoiceObj.Rate < 10 )
{
VoiceObj.Rate = VoiceObj.Rate + 1;
}
}
function DecRate() {
if( VoiceObj.Rate > -10 )
{
VoiceObj.Rate = VoiceObj.Rate - 1;
}
}
function IncVol() {
if( VoiceObj.Volume < 100 )
{
VoiceObj.Volume = VoiceObj.Volume + 10;
}
}
function DecVol() {
if( VoiceObj.Volume > 9 )
{
VoiceObj.Volume = VoiceObj.Volume - 10;
}
}
// SpeakText() function:
// This function gets the text from the textbox and sends it to the
// Voice object's Speak() function. The value "1" for the second
// parameter corresponds to the SVSFlagsAsync value in the
SpeechVoiceSpea kFlags
// enumerated type.
function SpeakText() {
if( idbSpeakText.te xt == "Leggi" )
{
// Speak the string in the edit box
try
{
VoiceObj.Speak( idTextBox.text, 1 );
}
catch(exception )
{
alert("Speak error");
}
}
else if( idbSpeakText.te xt == "Stop" )
{
// Speak empty string to Stop current speaking. The value "2" for
// the second parameter corresponds to the SVSFPurgeBefore Speak
// value in the SpeechVoiceSpea kFlags enumerated type.
VoiceObj.Speak( "", 2 );
}
}
</SCRIPT>
<SCRIPT FOR="window" EVENT="OnQuit() " LANGUAGE="JavaS cript">
// Clean up voice object
delete VoiceObj;
</SCRIPT>
</head>
<body>
<form name="form1">
<div>
<center><font size= "5" face="Verdana"> BOOK READER<br
/></font></center>
<br />
<P align="center">
<TEXTAREA name=TEXTAREA1 COLS=50 ROWS=10><%=Para graph %></TEXTAREA>
</P>
<P align="center">
Velocità
<INPUT id=idbIncRate name=button1 type=button onclick="return
IncRate();" value=" + ">
<INPUT id=idbDecRate name=button2 type=button onclick="return
DecRate();" value=" - " style="LEFT: 237px; TOP: 292px">
Volume
<INPUT id=idbIncVol name=button3 onclick="return IncVol();"
style="LEFT: 67px; TOP: 318px" type=button value=" + ">
<INPUT id=idbDecVol name=button4 onclick="return DecVol();" type=button
value=" - " style="LEFT: 134px; TOP: 377px">
</P>
<br />
<P align="center">
<INPUT id=idbSpeakText onclick="return SpeakText();" value= "Leggi"
style=" LEFT: 363px; TOP: 332px; height: 24px;" type=button size="" >
</P>
<br />
<P align="center">
Voce
<SELECT id=idsVoices name=Voices onchange="retur n ChangeVoice();"
style="FONT-FAMILY: serif; HEIGHT: 21px; WIDTH: 179px"> </SELECT>
Paragrafo
<asp:Button ID="indietro" runat="server" Height="24px" Text="
<< " Width="60px" />
<asp:Button ID="avanti" runat="server" Height="24px" Text=">>
" Width="60px" />
</P>
<br />
<P align="center">
<asp:Button ID="esci" runat="server" Height="24px" Text="Esci"
Width="80px" />
<br />
</P>
</div>
</form>
<SCRIPT LANGUAGE="JavaS cript">
// Code in the BODY of the webpage is used to initialize controls and
// to handle SAPI events
/***** Initializer code *****/
InitializeContr ols();
function InitializeContr ols()
{
// Initialize the Voices Select boxes
var VoicesToken = VoiceObj.GetVoi ces();
// Add correct strings to Voice Select box
for( var i=0; i<VoicesToken.C ount; i++ )
{
var oOption = document.create Element("OPTION ");
idsVoices.optio ns.add(oOption) ;
oOption.innerTe xt = VoicesToken.Ite m(i).GetDescrip tion();
oOption.value = i;
}
}
/***** Event handling code *****/
// These functions are used to handle the SAPI events
// Handle StartStream event
function VoiceObj::Start Stream() {
idbSpeakText.te xt = "Stop";
}
// Handle EndStream event
function VoiceObj::EndSt ream() {
idbSpeakText.te xt = "Leggi";
</SCRIPT>
</body>
</html>