DillonWall / generate-batch-audio-anki-addon

An addon that downloads and attaches audio to flashcards in bulk from URLs. Made for Anki, an SRS flashcard application
https://ankiweb.net/shared/info/1156270186
Apache License 2.0
14 stars 6 forks source link

Wrong audio for some words with multiple readings with Local Audio Server for Yomichan #12

Closed morning-paradigm closed 7 months ago

morning-paradigm commented 1 year ago

I've recently switched to Local Audio Server for Yomichan and used your add-on to update my decks' audio. So far so good, but I seldom get a wrong audio.

For example, instead of 石灰[せっかい] I get the audio for 石灰[いしばい]. The audio file I get also gets named 石灰[せっかい] despite being the audio for 石灰[いしばい]. Another example I've encountered is 最中[さなか].

Card example ![Y-08-03 16-56-21](https://github.com/DillonWall/generate-batch-audio-anki-addon/assets/39773982/c8a1b201-647d-4908-8c8c-87fcf61cac60)
Settings ![Bulk Generate Audio for Selected Notes 2023-08-03 16-55-20](https://github.com/DillonWall/generate-batch-audio-anki-addon/assets/39773982/bd69a065-9cef-4441-b214-91983350390b)

So far I've tried:

  1. Checking media and deleting unused files and then regenerating audio, but I get the same result
  2. Disabling duplicate to empty fields
  3. Putting kana only instead of filtering the field (石灰[せっかい] -> せっかい)
  4. http://127.0.0.1:5050/?sources=jpod&term={石灰}&kana={せっかい} as a source, this just skips it.

There's no such issue in Yomichan, it plays the right audio.

DillonWall commented 1 year ago

Hello and thank you for using my addon,

After some investigating into this issue, I found that your 4th attempt is close, but would actually need to be http://127.0.0.1:5050/?sources=jpod&term=石灰&kana=せっかい without the curly braces.

Putting this into my browser, I get the following return from the Local Audio Server for Yomichan addon: image

As you can see, there are actually 2 audio sources which my addon does not handle (it always takes the first source from the list). As you might expect, the first audio file is the いしばい reading, and the second file is your desired せっかい reading.

For a temporary work around, you could just paste the URL for these audio files that aren't found correctly into your browser and manually copy the link (in this case: http://localhost:5050/jpod/media\\1a4203a8cd8a32cba24d57c4eb6a2301.opus), right-click and download the audio file, and paste it onto your audio field in your card. Of course, this is very tedious, but if this doesn't occur for very many cards, at least it would let you fix the couple that do fail in this way.

For a long term fix, I am inclined to ask @Aquafina-water-bottle if the local audio server should filter using the kana field or not, and if does, why might we see the いしばい reading here? I assume what's going on currently is that we are just being returned all matches to the term field, and if this is the case, maybe there should be some sort of field in the return JSON with information about the kana reading (and possibly other information such as term, etc?) in order to distinguish between different readings (so long as this is possible without breaking functionality with Yomichan of course).

Thank you @morning-paradigm for posting the issue here; I hope the temporary fix works okay for you in the meantime, and for the future we will be looking into a more permanent fix for this issue.

DillonWall commented 7 months ago

Going to close this as not planned for now. If the local audio server provides a way to filter for the correct audio source in the future, then we can add this feature.