SAPI - Audio Jukebox

SAPI - Audio Jukebox

Nowadays, people can listen to their favorite music live through telephones and other communication media. Entertainment firms require the Jukebox systems to play the music as per the subscriber's choice. The IVR script mentioned here is a simple approach to implement audio jukebox using SAPI engine that plays the patron's selection from a self-contained list.

Download the evaluation version of Xtend IVR and install the telephony application in your system. Run the sample script from the Script Editor. Click here to refer the code.

The automated attendant will work as given below:

  • IVR waits for the call
  • Accepts the call and plays the Welcome message
  • IVR prompts the user to enter a number between 0 and 9
  • Caller has to give the input either by entering the number via keypad
    or speak out the number
  • IVR plays back the corresponding music
Download the source file zip download for the Speech Recognition - SAPI - Audio Jukebox


srKeepGrammar(true)


$LookupTable.zero  = 0
$LookupTable.one   = 1
$LookupTable.two   = 2
$LookupTable.three = 3
$LookupTable.four  = 4
$LookupTable.five  = 5
$LookupTable.six   = 6
$LookupTable.seven = 7
$LookupTable.eight = 8
$LookupTable.nine  = 0

	
MAIN:
	display "Waiting for call"
	
	
	answer 1
	
	
	srAcceptWords("one","two","three","four","five","six","seven","eight","nine")
	
	
	play "welcome.wav"
	
	
	display "Accept number"
	$Key = accept("song.wav", 1, 3)
	
	
	if $InputMode == "S"
		
		$Var = format("$LookupTable.%s", $Key)
		$Key = $$Var
	endif
	
	
	if $Key >= 1 and $key <= 9
		play Format("Music%d.wav",$Key)
	endif
	
	
	play "thank.wav"
	hangup
	goto MAIN


ONHANGUP:
	hangup
	goto MAIN


ONSYSTEMERROR:
	log $error
	display $error
	hangup
	goto MAIN


Function srAcceptWords()
	
	
	
	$GrmStart = '<GRAMMAR LANGID="409"> <DEFINE> <ID NAME="RID_Language" VAL="409"/> 
			</DEFINE> <RULE ID="RID_Language" TOPLEVEL="ACTIVE">
			<LIST PROPID="RID_Language"> '
	$GrmEnd = ' </LIST> </RULE> </GRAMMAR>'
	$GrmWord = ' <P>%s</P> '
	
	
	$Grm = $GrmStart
	$Ctr = 1
	while $Ctr <= $PluginParamCount
    
		
		$Var = format("$PluginParam%d",$Ctr)
		
		
		$Tag = format($GrmWord,$$Var)
		
		
		$Grm = concat($Grm, $Tag)
		
		
		$Ctr += 1
	endwhile
	$Grm = concat($Grm, $GrmEnd)
	
	
	srGrammar($Grm)
return