speech application

S

sara

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="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Leggi Libro</title>

<SCRIPT LANGUAGE="JavaScript">

// Create the Sapi SpVoice object
var VoiceObj = new ActiveXObject("Sapi.SpVoice");

function ChangeVoice() {
var i = parseInt( idsVoices.value );
VoiceObj.Voice = VoiceObj.GetVoices().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
SpeechVoiceSpeakFlags
// enumerated type.
function SpeakText() {
if( idbSpeakText.text == "Leggi" )
{
// Speak the string in the edit box
try
{
VoiceObj.Speak( idTextBox.text, 1 );
}
catch(exception)
{
alert("Speak error");
}
}
else if( idbSpeakText.text == "Stop" )
{
// Speak empty string to Stop current speaking. The value "2" for
// the second parameter corresponds to the SVSFPurgeBeforeSpeak
// value in the SpeechVoiceSpeakFlags enumerated type.
VoiceObj.Speak( "", 2 );
}
}

</SCRIPT>

<SCRIPT FOR="window" EVENT="OnQuit()" LANGUAGE="JavaScript">
// 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><%=Paragraph %></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">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;&nbsp;

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="return ChangeVoice();"
style="FONT-FAMILY: serif; HEIGHT: 21px; WIDTH: 179px"> </SELECT>
&nbsp; &nbsp;&nbsp;

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="JavaScript">
// Code in the BODY of the webpage is used to initialize controls and
// to handle SAPI events

/***** Initializer code *****/
InitializeControls();

function InitializeControls()
{
// Initialize the Voices Select boxes
var VoicesToken = VoiceObj.GetVoices();

// Add correct strings to Voice Select box
for( var i=0; i<VoicesToken.Count; i++ )
{
var oOption = document.createElement("OPTION");
idsVoices.options.add(oOption);
oOption.innerText = VoicesToken.Item(i).GetDescription();
oOption.value = i;
}

}

/***** Event handling code *****/
// These functions are used to handle the SAPI events

// Handle StartStream event
function VoiceObj::StartStream() {
idbSpeakText.text = "Stop";
}

// Handle EndStream event
function VoiceObj::EndStream() {
idbSpeakText.text = "Leggi";

</SCRIPT>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top