Premise Speech Parser throwing error when triggering SetMediaVoiceExpressions

Motorola Premise

samgreco

Active Member
Been working on SpeechParser and have lights working without issue.  But when I try to get SP to build the expressions for my media (built in Premise HD handler) I get the follow error:
 
Runtime error in script:
Error: Overflow 'sPrevWord'
Line: 120
Text:
 
Any insight?
 
Also, this is with OK Google currently.  Haven't tried the Cortana App yet.  Figured I'd get the backend working first since I know the OK G works.
 
What is happening is you have a song name with a really big number as part of its name or a name that vbscript thinks is a number but isn't.  When you have SpeechParser build the expressions, it sees a very large number and attempts to treat it as an integer (most likely).
 
You could remove the song temporarily, then have it build the rest of the library.  You can find out where SpeechParser left off by browsing your library and seeing the first song with a blank "DefaultSearch" property.  Please paste the offending song name (e.g. Title property value, DisplayName value, and Name value) here so I can debug it.
 
You can attempt to modify sys://Schema/Modules/SpeechParser/GlobalScripts/ConvertSpokenInteger
 
Go to: sys://Schema/Modules/SpeechParser/GlobalScripts/ConvertSpokenInteger  and add "sPrevWord = cdbl(sPrevWord)​" just above line 120.  This may not fix the issue, but once you provide the song name, it can be fixed.
Code:
		' handle 20 2 => 22 and 100 5 => 105 
		if isnumeric(sPrevWord) and isnumeric(sWord) then
			sPrevWord = cdbl(sPrevWord)
			if sPrevWord mod 10 = 0 then
				if sPrevWord > sWord then
					sText = trim(sText)
					sText = left(sText,len(sText)-len(sPrevWord))
					sText = trim(sText)
					sWord = sPrevWord + sWord
				end if
			end if
		end if
 
I got the error by using a fake song name like:  "This is a dumb song but I got 10000000000 fifty in my bank yo"
 
Modify sys://Schema/Modules/SpeechParser/GlobalScripts/ConvertSpokenInteger like this.  Kind of a kludge, but it will ensure the error never shows up.  It will also ensure 10000000000 stays in the DefaultSearch string too.
 
Note the new lines: 
 

if sPrevWord < 1000 then
...
end if
 
 
 
Code:
		' handle 20 2 => 22 and 100 5 => 105 
		if isnumeric(sPrevWord) and isnumeric(sWord) then
			if sPrevWord < 1000 then
			if sPrevWord mod 10 = 0 then
				if sPrevWord > sWord then
					sText = trim(sText)
					sText = left(sText,len(sText)-len(sPrevWord))
					sText = trim(sText)
					sWord = sPrevWord + sWord
				end if
			end if
			end if
		end if
 
Actually, it didn't get any of them.  But the very first Artist listed is 10cc.  Wonder if that is causing it?  I'll check it out.
 
EDIT:  I take that back.  Seems to have gotten songs, but not albums.  I'll need to get through the list to see where it failed.  Could take a while as I have some 20k songs...
 
So does it scan in the order in which Premise lists them?  And does it do songs first, then go back and do albums?  It seems to have stopped at a song (first track on the album) with the name 01 Changing of the Guards.mp3 with the display name Changing of the Guards.  The album name had the year in front of the title, but the previous dozen or so did as well and they completed just fine.
 
You should check both Name and DisplayName.  DisplayName is used instead if it is not blank.
 
Also, the issue could be the one before the song with the blank DefaultSearch, provided the one before only has a partial DefaultSearch filled in.
 
Yes, it uses recursion and sets DefaultSearch for each type separately.  Note that the order is not technically guaranteed as 123 once pointed out to me.  I didn't know you had 20,000 songs to look through; not worth it.  Had it been 100 we could figure it out!
 
If you find out which song/album is the problem, that would be useful information, but if the change fixes it, it's a mute point as I'll include the two new lines of code in module and be done with it (regardless).  
 
The code change I proposed above should fix your overflow.  Just make sure to commit the script change when you modify it (very important).  I would just modify the code, then try it again and let me know how that goes.
 
What's funny is that I never found a song with a large number in it.  It was stopping on simple song names.  I was able to narrow down quickly by jumping forward large chunks in the library until I found some that were empty and then work backwards and that helped narrow it down.
 
So I just had time to apply your patch/kludge and it seems to have gotten through the entire library.
 
Unfortunately, Premise doesn't seem to be responding to any Play commands for my media.  Since I am not using Kodi, but Premise's built in media handling, is there anything I need to change?
 
You may not see it as a large number.  For example, things like: in, and, -, etc are removed when forming the DefaultSearch string (although they are replaced with spaces).
 
If there's an overflow vbscript is seeing a large number, plus the code fixed the issue so we know there was a number somewhere causing the issue.  ;)  Using a cutoff of 1000 makes sense as the rest of the number conversions only work for numbers less than 1000 (since I wrote that code in less than an hour and never went back to improve it).
 
Are saying the sentence in this form:
Play song [song name] in the [room location name]
Did you setup a regular expression for the room location and is it mutually exclusive as shown in the video?
Did you try typing it in the test field of SpeechParser?
Does the media zone work using the AB?
Does the provider have a MediaType defined (e.g. album|song)?
Does it load the song into "NowPlaying" under the media zone?
 
There's no way for me to know how the names are setup and if you are saying things exactly, etc.  If you use KODI and set it up as the videos show, things will work. 
 
For example, I see Premise natively sets the "Name" value for a song as the actual filename.  This will never result in a match (and why would it unless you also say the track number).  The song's DefaultSearch value has to match what you said, or it will not work.
 
And...  Premise needs to use proper metadata and not rely on FileName only, otherwise the DefaultSearch would have a track number in it, file extension, etc...  If it can't read the metadata correctly, it will never work unless you manually define the match using the song's UserDefinableSearch field as the KODI video shows.
 
I'm using Windows 10, but Premise attempts to play the song navitely so I believe it would work under Windows 7 (sets NowPlaying under the media zone).  I think Windows 10 may have broken the native playback via a soundcard output feature.  Premise attempts to play the track, then immediately stops it (can't test Windows 7 right now and may never get around to it to be honest).
 
All of the above was correct.  Here is what I discovered because of your last post:  The line:
 
Play song [song name] in the [room location name]
 
Seems that the word THE needs to be in the command.  So, Play song [xyz] in Sam's Office doesn't work.  Nor does in Kitchen.  But in THE Kitchen does.  So if I say "Play the album how dare you in THE sam's office"  (which it reads as sam office) It works.  A bit awkward, but it works.
 
So lights and music now working with OK Google.  Still need to make radio stations work.  Then I'll take a look at Cortana.  And I found a small program that let's you add attention words to Cortana so it will respond to something else.
 
MyCortana
 
It works fine if room names aren't proper nouns.

If I remember later I'll show you what to modify when I get home.
 
Modify this line of sys://Schema/Modules/SpeechParser/Classes/SpeechParser/ProcessCmd_NaturalLanguage:

oRegExp.Pattern = "play.?.?.?\b\s.?.?.?.?(movie\b|song\b|album\b|song\b|channel\b|tv station\b|episode\b|series\b|season\b)(.*)\b\s.?.?(in|and|on).?.?\sthe\b(.*)"

You could just delete the\b.  Or you could just rename your office to second office ;)  Good to know everything works natively, I figured it would as I was extremely careful when I designed the KODI module to inherit from the same native classes that Premise's mSense relies on.
 
PS:  radio stations won't work without modifying SpeechParser.  I'll probably get around to adding radio stations though at some point!
 
Back
Top