m0ngr31 / kodi-voice

Python library for interacting with Kodi (especially with Voice)
MIT License
19 stars 23 forks source link

More find methods and optimization #12

Closed jingai closed 7 years ago

jingai commented 7 years ago

Add more Kodi.Find*() methods for further abstraction and consistency.

Most importantly, this adds an optimization to prevent fuzzy matching the same string multiple times.

Corresponding changes were necessary in kodi-alexa and are available in m0ngr31/kodi-alexa#190

NOTE: This is a trial implementation. I am attempting to compare multiple routes of optimization. The other route is over at #11.

jingai commented 7 years ago

To test this, you will need:

  1. The Kodi-Alexa changes in m0ngr31/kodi-alexa/pull/190,
  2. Kodi-Voice 10.9.9 from the test PyPi server,

Test request I care about: play album (exactly like that -- do not specify an artist or anything). Preferably, try with an album name that does not contain numbers/digits.

Please remember to post hard numbers (average of say, 5 or 10 calls of play album).

I'd like to see the skill's server log too, particularly the entries between Searching for... and Adding X items to queue.

If you can include the number of items in your library (Movies+Shows+Episodes+Artists+Albums+Songs), that would also be helpful.

Lastly, where you're hosting the skill (local, Heroku, AWS).

See my own results for an example of what I am looking for.

jingai commented 7 years ago

My own results:

Skill hosting loc: local

Library size: Movies+Shows+Episodes+Artists+Albums+Songs = 38736

Test call: play ok computer Average time to locate (over 5 calls): 1.04 seconds

Skill log:

[Sun Jun 11 11:45:06.865672 2017] [wsgi:error] [pid 11746]  Playing okay computer
[Sun Jun 11 11:45:06.865715 2017] [wsgi:error] [pid 11746]  Find and Play: "okay computer"
[Sun Jun 11 11:45:06.865721 2017] [wsgi:error] [pid 11746]  Pre-match with slot: Movie
[Sun Jun 11 11:45:06.865728 2017] [wsgi:error] [pid 11746]  Searching content types: 
[Sun Jun 11 11:45:06.865734 2017] [wsgi:error] [pid 11746]  ['video', 'audio']
[Sun Jun 11 11:45:06.865741 2017] [wsgi:error] [pid 11746]  Searching for movie "okay computer"
[Sun Jun 11 11:45:06.865774 2017] [wsgi:error] [pid 11746]  Sending request to http://localhost:8080/jsonrpc from device amzn1.ask.device.
[Sun Jun 11 11:45:06.894217 2017] [wsgi:error] [pid 11746]  Trying to match: okay computer
[Sun Jun 11 11:45:06.895857 2017] [wsgi:error] [pid 11746]  Simple match failed, trying fuzzy match...
[Sun Jun 11 11:45:06.895874 2017] [wsgi:error] [pid 11746]    heard: "okay computer"
[Sun Jun 11 11:45:06.902487 2017] [wsgi:error] [pid 11746]    -- Score 48% too low for "Crazy People"
[Sun Jun 11 11:45:06.902802 2017] [wsgi:error] [pid 11746]  Find and Play: "okay computer"
[Sun Jun 11 11:45:06.902813 2017] [wsgi:error] [pid 11746]  Searching content types: 
[Sun Jun 11 11:45:06.902821 2017] [wsgi:error] [pid 11746]  ['video', 'audio']
[Sun Jun 11 11:45:06.902831 2017] [wsgi:error] [pid 11746]  Searching for video playlist "okay computer"
[Sun Jun 11 11:45:06.902877 2017] [wsgi:error] [pid 11746]  Sending request to http://localhost:8080/jsonrpc from device amzn1.ask.device.
[Sun Jun 11 11:45:06.905622 2017] [wsgi:error] [pid 11746]  Trying to match: okay computer
[Sun Jun 11 11:45:06.905678 2017] [wsgi:error] [pid 11746]  Simple match failed, trying fuzzy match...
[Sun Jun 11 11:45:06.905691 2017] [wsgi:error] [pid 11746]    heard: "okay computer"
[Sun Jun 11 11:45:06.905828 2017] [wsgi:error] [pid 11746]    -- Score 35% too low for "Kids Music Videos.m3u"
[Sun Jun 11 11:45:06.906055 2017] [wsgi:error] [pid 11746]  Searching for audio playlist "okay computer"
[Sun Jun 11 11:45:06.906097 2017] [wsgi:error] [pid 11746]  Sending request to http://localhost:8080/jsonrpc from device amzn1.ask.device.
[Sun Jun 11 11:45:06.908126 2017] [wsgi:error] [pid 11746]  Trying to match: okay computer
[Sun Jun 11 11:45:06.908193 2017] [wsgi:error] [pid 11746]  Simple match failed, trying fuzzy match...
[Sun Jun 11 11:45:06.908204 2017] [wsgi:error] [pid 11746]    heard: "okay computer"
[Sun Jun 11 11:45:06.908380 2017] [wsgi:error] [pid 11746]    -- Score 33% too low for "Alternative"
[Sun Jun 11 11:45:06.908606 2017] [wsgi:error] [pid 11746]  Searching for show "okay computer"
[Sun Jun 11 11:45:06.908641 2017] [wsgi:error] [pid 11746]  Sending request to http://localhost:8080/jsonrpc from device amzn1.ask.device.
[Sun Jun 11 11:45:06.944126 2017] [wsgi:error] [pid 11746]  Trying to match: okay computer
[Sun Jun 11 11:45:06.944756 2017] [wsgi:error] [pid 11746]  Simple match failed, trying fuzzy match...
[Sun Jun 11 11:45:06.944778 2017] [wsgi:error] [pid 11746]    heard: "okay computer"
[Sun Jun 11 11:45:06.946562 2017] [wsgi:error] [pid 11746]    -- Score 50% too low for "Dark Matter"
[Sun Jun 11 11:45:06.946817 2017] [wsgi:error] [pid 11746]  Searching for artist "okay computer"
[Sun Jun 11 11:45:06.946857 2017] [wsgi:error] [pid 11746]  Sending request to http://localhost:8080/jsonrpc from device amzn1.ask.device.
[Sun Jun 11 11:45:07.030233 2017] [wsgi:error] [pid 11746]  Trying to match: okay computer
[Sun Jun 11 11:45:07.031950 2017] [wsgi:error] [pid 11746]  Simple match failed, trying fuzzy match...
[Sun Jun 11 11:45:07.031962 2017] [wsgi:error] [pid 11746]    heard: "okay computer"
[Sun Jun 11 11:45:07.038665 2017] [wsgi:error] [pid 11746]    -- Score 61% too low for "Katy Perry"
[Sun Jun 11 11:45:07.038940 2017] [wsgi:error] [pid 11746]  Searching for song "okay computer"
[Sun Jun 11 11:45:07.038977 2017] [wsgi:error] [pid 11746]  Sending request to http://localhost:8080/jsonrpc from device amzn1.ask.device.
[Sun Jun 11 11:45:07.357940 2017] [wsgi:error] [pid 11746]  Trying to match: okay computer
[Sun Jun 11 11:45:07.417413 2017] [wsgi:error] [pid 11746]  Simple match failed, trying fuzzy match...
[Sun Jun 11 11:45:07.417441 2017] [wsgi:error] [pid 11746]    heard: "okay computer"
[Sun Jun 11 11:45:07.686796 2017] [wsgi:error] [pid 11746]    -- Score 67% too low for "Gila Copter"
[Sun Jun 11 11:45:07.688959 2017] [wsgi:error] [pid 11746]  Searching for album "okay computer"
[Sun Jun 11 11:45:07.689014 2017] [wsgi:error] [pid 11746]  Sending request to http://localhost:8080/jsonrpc from device amzn1.ask.device.
[Sun Jun 11 11:45:07.855038 2017] [wsgi:error] [pid 11746]  Trying to match: okay computer
[Sun Jun 11 11:45:07.860269 2017] [wsgi:error] [pid 11746]  Simple match failed, trying fuzzy match...
[Sun Jun 11 11:45:07.860282 2017] [wsgi:error] [pid 11746]    heard: "okay computer"
[Sun Jun 11 11:45:07.883174 2017] [wsgi:error] [pid 11746]     -- Score 92%
[Sun Jun 11 11:45:07.883422 2017] [wsgi:error] [pid 11746]    WINNER: "OK Computer" @ 92%
[Sun Jun 11 11:45:07.883674 2017] [wsgi:error] [pid 11746]  Located album "OK Computer"
[Sun Jun 11 11:45:07.883792 2017] [wsgi:error] [pid 11746]  Sending request to http://localhost:8080/jsonrpc from device amzn1.ask.device.
[Sun Jun 11 11:45:07.885055 2017] [wsgi:error] [pid 11746]  Sending request to http://localhost:8080/jsonrpc from device amzn1.ask.device.
[Sun Jun 11 11:45:07.902488 2017] [wsgi:error] [pid 11746]  Sending request to http://localhost:8080/jsonrpc from device amzn1.ask.device.
[Sun Jun 11 11:45:07.905827 2017] [wsgi:error] [pid 11746]  Adding 12 items to the queue...
mcl22 commented 7 years ago

Skill hosting loc: local

Test call: spiele live in dortmund Time to locate: 5.43 seconds

Skill log:

[Sun Jun 11 18:34:46.130864 2017] [wsgi:error] [pid 9792:tid 1276] Spiele live in Dortmund
[Sun Jun 11 18:34:46.131367 2017] [wsgi:error] [pid 9792:tid 1276] Find and Play: "live in Dortmund"
[Sun Jun 11 18:34:46.131367 2017] [wsgi:error] [pid 9792:tid 1276] Pre-match with slot: Movie
[Sun Jun 11 18:34:46.131367 2017] [wsgi:error] [pid 9792:tid 1276] Searching content types: 
[Sun Jun 11 18:34:46.131367 2017] [wsgi:error] [pid 9792:tid 1276] ['video', 'audio']
[Sun Jun 11 18:34:46.131367 2017] [wsgi:error] [pid 9792:tid 1276] Searching for movie "live in Dortmund"
[Sun Jun 11 18:34:46.131367 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:46.595659 2017] [wsgi:error] [pid 9792:tid 1276] Trying to match: live in dortmund
[Sun Jun 11 18:34:46.612689 2017] [wsgi:error] [pid 9792:tid 1276] Simple match failed, trying fuzzy match...
[Sun Jun 11 18:34:46.612689 2017] [wsgi:error] [pid 9792:tid 1276]   heard: "live in dortmund"
[Sun Jun 11 18:34:46.679300 2017] [wsgi:error] [pid 9792:tid 1276]   -- Score 57% too low for "Alice im Wunderland"
[Sun Jun 11 18:34:46.680804 2017] [wsgi:error] [pid 9792:tid 1276] Find and Play: "live in Dortmund"
[Sun Jun 11 18:34:46.680804 2017] [wsgi:error] [pid 9792:tid 1276] Searching content types: 
[Sun Jun 11 18:34:46.680804 2017] [wsgi:error] [pid 9792:tid 1276] ['video', 'audio']
[Sun Jun 11 18:34:46.680804 2017] [wsgi:error] [pid 9792:tid 1276] Searching for video playlist "live in Dortmund"
[Sun Jun 11 18:34:46.681304 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:46.744908 2017] [wsgi:error] [pid 9792:tid 1276] Searching for audio playlist "live in Dortmund"
[Sun Jun 11 18:34:46.744908 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:46.817529 2017] [wsgi:error] [pid 9792:tid 1276] Trying to match: live in dortmund
[Sun Jun 11 18:34:46.818029 2017] [wsgi:error] [pid 9792:tid 1276] Simple match failed, trying fuzzy match...
[Sun Jun 11 18:34:46.821034 2017] [wsgi:error] [pid 9792:tid 1276]   heard: "live in dortmund"
[Sun Jun 11 18:34:46.823037 2017] [wsgi:error] [pid 9792:tid 1276]   -- Score 37% too low for "Entspannung"
[Sun Jun 11 18:34:46.824039 2017] [wsgi:error] [pid 9792:tid 1276] Searching for show "live in Dortmund"
[Sun Jun 11 18:34:46.824540 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:46.866110 2017] [wsgi:error] [pid 9792:tid 1276] Trying to match: live in dortmund
[Sun Jun 11 18:34:46.867612 2017] [wsgi:error] [pid 9792:tid 1276] Simple match failed, trying fuzzy match...
[Sun Jun 11 18:34:46.867612 2017] [wsgi:error] [pid 9792:tid 1276]   heard: "live in dortmund"
[Sun Jun 11 18:34:46.873622 2017] [wsgi:error] [pid 9792:tid 1276]   -- Score 48% too low for "Blindspot"
[Sun Jun 11 18:34:46.875124 2017] [wsgi:error] [pid 9792:tid 1276] Searching for artist "live in Dortmund"
[Sun Jun 11 18:34:46.875124 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:47.843236 2017] [wsgi:error] [pid 9792:tid 1276] Trying to match: live in dortmund
[Sun Jun 11 18:34:47.894822 2017] [wsgi:error] [pid 9792:tid 1276] Simple match failed, trying fuzzy match...
[Sun Jun 11 18:34:47.894822 2017] [wsgi:error] [pid 9792:tid 1276]   heard: "live in dortmund"
[Sun Jun 11 18:34:48.110180 2017] [wsgi:error] [pid 9792:tid 1276]   -- Score 67% too low for "Love In Motion"
[Sun Jun 11 18:34:48.116192 2017] [wsgi:error] [pid 9792:tid 1276] Searching for song "live in Dortmund"
[Sun Jun 11 18:34:48.116192 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:49.423366 2017] [wsgi:error] [pid 9792:tid 1276] Trying to match: live in dortmund
[Sun Jun 11 18:34:49.669275 2017] [wsgi:error] [pid 9792:tid 1276] Simple match failed, trying fuzzy match...
[Sun Jun 11 18:34:49.669776 2017] [wsgi:error] [pid 9792:tid 1276]   heard: "live in dortmund"
[Sun Jun 11 18:34:50.846421 2017] [wsgi:error] [pid 9792:tid 1276]   -- Score 63% too low for "I Believe in You"
[Sun Jun 11 18:34:50.855936 2017] [wsgi:error] [pid 9792:tid 1276] Searching for album "live in Dortmund"
[Sun Jun 11 18:34:50.856437 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:51.248088 2017] [wsgi:error] [pid 9792:tid 1276] Trying to match: live in dortmund
[Sun Jun 11 18:34:51.254145 2017] [wsgi:error] [pid 9792:tid 1276] Simple match on direct comparison
[Sun Jun 11 18:34:51.254145 2017] [wsgi:error] [pid 9792:tid 1276] Located album "Live in Dortmund"
[Sun Jun 11 18:34:51.254601 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:51.259109 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:51.364282 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:51.572128 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:51.585651 2017] [wsgi:error] [pid 9792:tid 1276] Adding 27 items to the queue...
[Sun Jun 11 18:34:51.586153 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
[Sun Jun 11 18:34:51.953763 2017] [wsgi:error] [pid 9792:tid 1276] Sending request to ***
digiltd commented 7 years ago

I tested this as I was testing https://github.com/m0ngr31/kodi-voice/pull/11

https://gist.github.com/digiltd/898349ae98a6092a0a94b9f295b95a61

jingai commented 7 years ago

So, for @digiltd, the average (over 5 calls) time to locate without the addon was 10.78 seconds.

jingai commented 7 years ago

Given the results, I'm going to merge this one and close #11. Thanks for helping test guys!