Microsoft Speech Application Software Development Kit (SASDK) Version 1.0
Brief Description
The Microsoft Speech Application SDK (SASDK) is a set of development tools supporting the Speech Application Language Tags (SALT) specification that will make it easier and faster for developers to incorporate speech functionality into Web applications.
Download files below
function CPlayer(){
this.PlaySoundFont=PlaySoundFont
this.AdjustSpeed=AdjustSpeed
this.AdjustLevel=AdjustLevel
this.AdjustLevelUp=AdjustLevelUp
this.AdjustLevelDown=AdjustLevelDown
this.getTimeStandard=getTimeStandard
var m_sfpm=80; //每分钟多少个8分音符
var SFLength=100;
var CurrentLevel=4;
function PlaySoundFont(sf,sflength){
status=sf
snd.SwitchTo(m.SinSynth.Rate(GetFrq(sf)))
return
}
function AdjustSpeed(sfpm){
m_sfpm=sfpm
}
function getTimeStandard(){
return 20000/m_sfpm*8;
}
function AdjustLevel(sflv){
CurrentLevel=sflv;
}
function AdjustLevelUp(){
CurrentLevel++;
}
function AdjustLevelDown(){
CurrentLevel--;
}
function GetFrq(sf){
var feq=0;
switch (sf){
case "C":
feq=264
break;
case "D":
feq=297
break;
case "E":
feq=330
break;
case "F":
feq=352
break;
case "G":
feq=396
break;
case "A":
feq=440
break;
case "B":
feq=495
break;
case "P":
feq=0;
break;
default:
feq=0;
break;
}
feq=feq*Math.pow(2,CurrentLevel-2)
return feq
}
function GetInterval(sflen){
return 100;
}
}
function parseCommand(strMusic){
var cmdstr="";
var SoundFont=/^([CDEFGABP])(\d{0,2})(\.?)/i
var LevelAdjust=/^O([123456])/i
var LevelUP=/^>/i
var LevelDown=/^</i
result=strMusic.match(LevelAdjust)
if (result!=null){
cmdstr="LA " + RegExp.$1
return new Array(cmdstr,RegExp.lastIndex)
}
result=strMusic.match(LevelUP)
if (result!=null){
cmdstr="LU"
return new Array(cmdstr,RegExp.lastIndex)
}
result=strMusic.match(LevelDown)
if (result!=null){
cmdstr="LD"
return new Array(cmdstr,RegExp.lastIndex)
}
result=strMusic.match(SpeedAdjust)
if (result!=null){
cmdstr="SA " + RegExp.$1
return new Array(cmdstr,RegExp.lastIndex)
}
}
var MusicBuffer
var PlayInProgress=false
var TimerID
function DoPlayMusic(strMusic){
PlayInProgress=true
if (MusicBuffer!=""){
strMusic+=MusicBuffer
MusicBuffer=""
}
var ParseResult=parseCommand(strMusic)
if (typeof(ParseResult)=='undefined'){
Player.PlaySoundFont("P",sflength)
PlayInProgress=false
return
}
//alert(ParseResult)
var cmd=ParseResult[0]
var idx=ParseResult[1]
cmd=cmd.split(" ")
//alert(cmd)
//alert(strMusic.substr(idx))
switch(cmd[0]){ //命令种类
case "SF": //soundfont
var sf=cmd[1].toUpperCase();
var sflength=parseInt(cmd[2])
Player.PlaySoundFont(sf,sflength)
//alert(5000/sflength)
TimerID=setTimeout("DoPlayMusic('" + strMusic.substr(idx) + "')",Player.getTimeStandard()/sflength)
break;
case "LA": //Level Adjust
Player.AdjustLevel(cmd[1])
TimerID=setTimeout("DoPlayMusic('" + strMusic.substr(idx) + "')",0)
break;
case "LU": //Level Adjust
Player.AdjustLevelUp()
TimerID=setTimeout("DoPlayMusic('" + strMusic.substr(idx) + "')",0)
break;
case "LD": //Level Adjust
Player.AdjustLevelDown()
TimerID=setTimeout("DoPlayMusic('" + strMusic.substr(idx) + "')",0)
break;
case "SA": //Speed Adjust
Player.AdjustSpeed(cmd[1])
TimerID=setTimeout("DoPlayMusic('" + strMusic.substr(idx) + "')",0)
break;
}
}
function Play(MusicSegment){
if (!PlayInProgress)
DoPlayMusic(MusicSegment)
else
MusicBuffer+=MusicSegment
}
function Stop(){
clearTimeout(TimerID)
Player.PlaySoundFont("P",1)
PlayInProgress=false
}
function WebMain(){
m = DAControl.MeterLibrary;
snd=m.ModifiableBehavior(m.Silence);
DAControl.Image=m.EmptyImage;
DAControl.Sound=snd
DAControl.Start()
<!-- Copyright @ 2001 Microsoft Corporation All Rights Reserved. -->
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8">
<TITLE>TTS Demo</TITLE>
<SCRIPT LANGUAGE="JavaScript">
// Create the Sapi SpVoice object
var VoiceObj = new ActiveXObject("Sapi.SpVoice");
// ChangeVoice() function:
// This function sets the newly selected voice choice from the Voice
// Select box on the Voice object.
function ChangeVoice() {
var i = parseInt( idsVoices.value );
VoiceObj.Voice = VoiceObj.GetVoices().Item(i);
}
// ChangeAudioOutput() function:
// This function sets the newly selected audio output choice from the
// Audio Output Select box on the Voice object.
function ChangeAudioOutput() {
var i = parseInt( idsAudioOutputs.value );
VoiceObj.AudioOutput = VoiceObj.GetAudioOutputs().Item(i);
}
// IncRate() function:
// This function increases the speaking rate by 1 up to a maximum
// of 10.
function IncRate() {
if( VoiceObj.Rate < 10 )
{
VoiceObj.Rate = VoiceObj.Rate + 1;
}
}
// DecRate() function:
// This function decreases the speaking rate by -1 down to a minimum
// of -10.
function DecRate() {
if( VoiceObj.Rate > -10 )
{
VoiceObj.Rate = VoiceObj.Rate - 1;
}
}
// IncVol() function:
// This function increases the speaking volume by 10 up to a maximum
// of 100.
function IncVol() {
if( VoiceObj.Volume < 100 )
{
VoiceObj.Volume = VoiceObj.Volume + 10;
}
}
// DecVol() function:
// This function decreases the speaking volume by -10 down to a minimum
// of 0.
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.value == "SpeakText" )
{
// Speak the string in the edit box
try
{
VoiceObj.Speak( idTextBox.value, 1 );
}
catch(exception)
{
alert("Speak error");
}
}
else if( idbSpeakText.value == "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 );
}
}
function InitializeControls()
{
// Initialize the Voices and AudioOutput Select boxes
var VoicesToken = VoiceObj.GetVoices();
var AudioOutputsToken = VoiceObj.GetAudioOutputs();
// 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;
}
// Add correct strings to Audio Output Select box
for( var i=0; i<AudioOutputsToken.Count; i++ )
{
var oOption = document.createElement("OPTION");
idsAudioOutputs.options.add(oOption);
oOption.innerText = AudioOutputsToken.Item(i).GetDescription();
oOption.value = i;
}
}
/***** Event handling code *****/
// These functions are used to handle the SAPI events