MRCP - Audio Jukebox

MRCP - 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 MRCP server 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 enters the input either through speech or through keypad
  • IVR plays back the corresponding music
Download the source file zip download for the Speech Recognition - MRCP - Audio Jukebox

$srLanguage = "en-IN"


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  = 9

	
MAIN:
	display "Waiting for call"
	
	
	answer 1
	
	
	play "welcome.wav"

	while true
		
		display "Accept number"
		
		play "song.wav"
		wait 0
		
		
		srAcceptWords("zero", "one","two","three", "four","five","six","seven",
								"eight","nine")
		
		$Key = input(1)
		
		
		if $InputMode == "S"
			
			$Var = ExtractXmlTag($Key,"instance>","instance>")
			if $Var <> ""
				$Var = Left($Var,Find($Var,"<"))
			endif
			
			
			$Var = format("$LookupTable.%s", $Var)
			if IsVariable($Var)
				$Key = $$Var
			endif
		endif
		
		srAcceptWords("")
		
		if $Key == 0
			break
		endif
		
		
		if $Key >= 1 and $key <= 9
			play Format("Music%d.wav",$Key)
		endif
	endwhile

	
	play "thank.wav"
	hangup
	goto MAIN


ONHANGUP:
	hangup
	goto MAIN


ONSYSTEMERROR:
	log $error
	display $error
	hangup
	goto MAIN



Function srAcceptWords()
	

	
	$GrmStart = concat('<?xml version="1.0" encoding="UTF8"?> <grammar 
		version="1.0"  xml:lang="', $srLanguage, '"  mode="voice" 
		root="start"> <rule id="start" scope="public"> <one-of>')
	$GrmEnd = '</one-of> </rule> </grammar>'
	$GrmWord = ' <item>%s</item> '

	
	$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