audiobookshelf icon indicating copy to clipboard operation
audiobookshelf copied to clipboard

Audible confidence score

Open mikiher opened this issue 6 months ago • 5 comments

Brief summary

This adds a match confidence score when matching audiobooks using Audible.

Which issue is fixed?

Fixes #4277 (eventually).

In-depth Description

When returning match results from Audible, a new match confidence score is calculated based on book duration, title and subtitle, and author.

Details:

  • The duration, title, and author scores are linearly combined
    • duration is weighted 0.7, title 0.2 and author 0.1
  • Duration is given 1.0 score if diff is less than 1 minute, then the score drops linearly to 0.6 if diff is 5 mintues, and then more sharply to 0.0 when diff is 10 minutes or more.
  • The title score is calculated by comparing the book title to the actual title query.
    • If the title query seems to have a subtitle, we compare it to the book title + subtitle
  • The author score is calculated by comparing the book author to the actual author query
    • If the book author has multiple authors (separated by commas), we try to compare against each of the authors and take the maximum score
  • if the title is an ASIN, a 1.0 match confidence score is returned (the duration, title, and author scores are not calculated).

The combined score is written to the result record.

I added some code to display it in BookMatchCard.vue (only so you can easily check it - this is not necessarily how we want to display it)

At this point, I haven't yet added the quick match dialog support. This is just for you to comment on the confidence score.

How have you tested this?

Added extensive unit testing, and ran through many books to see what kinds of scores we get. It looks like a threshold of 0.85-0.9 could be used to skip the intended quick match approval dialog.

mikiher avatar May 21 '25 08:05 mikiher

Again, at this point please don't merge, this is just to review confidence score calculation.

mikiher avatar May 21 '25 08:05 mikiher

I'm playing around with this but I don't have good real-world test data. The biggest benefit I can see from implementing this is preventing quick match from matching with a book with a low confidence score.

advplyr avatar Jun 01 '25 21:06 advplyr

Yes, I wanted to get your input on the score itself. I will finish implementing the quick match reject dialog for low confidence scored audiobooks when I get back from vacation next week.

mikiher avatar Jun 01 '25 22:06 mikiher

https://github.com/advplyr/audiobookshelf/pull/4383 introduced fusejs that I just tested out and it works very well at fuzzy matching. I included the basic build which is probably a better option than levenshtein

advplyr avatar Jun 13 '25 22:06 advplyr

It's a bit hard to assess which matching score is better since the search algorithms don't work the same, but I would hazard to say that, when searching over book provider search results, they likely return the same ordering in most cases except extreme ones.

The reason is that the search itself (on the provider side) is usually done by more "stupid" algorithms that don't use fuzzy matching, which is why I need to sometime run a few searches to even get any results. The search and sorting over the result set returned by the provider can probably slightly benefit from the fuse.js search, but not much, since those results probably all exactly match the search query (due to the provider's "stupid" search algorithm), and so the fuzzy matching advantages of fuse.js bitap algorithm are probably not realized.

Overall, I'd say that fuse.js is likely more suitable to cases in which the set over which it searches is unfiltered (like the list of podcast episodes, for example).

Also, in the case of Audible results, most of the score is determined by the duration diff, which is something that fuse.js matching doesn't know how to consider.

I need to set parameters and test extensively before I consider switching, and will not do this as part of this PR.

mikiher avatar Jun 16 '25 09:06 mikiher

I updated the confidence score to be inside a badge. The badge is green when the score is > 95% and blue otherwise. I chose that number from the tests on my dev library. We can fine tune it down the road.

image image

advplyr avatar Jul 21 '25 21:07 advplyr

Thanks!

advplyr avatar Jul 21 '25 22:07 advplyr