Rascalov / Anki-Simple-Forvo-Audio

Simple anki 2.1+ addon to get forvo audio into your cards for free. No Forvo account needed
https://ankiweb.net/shared/info/560814150
GNU General Public License v3.0
33 stars 3 forks source link

MP3 audio can not be played on my ipad #17

Open ZhangYan2580 opened 1 year ago

gragistfun commented 1 year ago

The addon calls the downloaded file *.mp3 but a closer inspection reveals

> file testing.mp3
testing.mp3: Ogg data, Vorbis audio, stereo, 44100 Hz, ~160000 bps

*.ogg files are not supported under iOS. You can convert the files using ffmpeg

cd /path/to/anki/media
for i in *.mp3; do
    if (($(file "$i" | grep -wic Ogg))); then
        mv "$i" "${i%.*}.ogg" 
    fi
done

for i in *.ogg; do ffmpeg -i "$i" "${i%.*}.mp3"; done
Rascalov commented 1 year ago

Yep, the mp3 extension is in name only, as this (somehow) fixed the issue for anki web not playing the audio. As for IOS, I don't own devices to test it on.

I wish I knew how I could easily do conversions to the desired format, I am familiar with ffmpeg, but using it in the addon is (to my knowledge) another beast. I believe I would have to package it separately for all operating systems if it is not already made available in anki itself. I had to switch scraping libraries to one that anki supports out of the box for that same reason.

Looking back at it now, I see some extensions do seem to use ffmpeg for more complex tasks: https://github.com/kamui-fin/yt-to-anki

I might look into their implementation as it looks like windows users do not need to install ffmpeg seperately for the addon (although linux and mac users are told to do so)

hu3rror commented 10 months ago

Hi, I've also run into issues playing audio downloaded by this plugin on iPad and iPhone. I found another similar plugin, https://github.com/realmayus/anki_forvo_dl, where the audio downloaded from Forvo does play properly in iOS. This might be a good reference for fixing the issue! I really like the simplicity of your downloader so I hope you can try to address this problem. Appreciate it!

Rascalov commented 10 months ago

Thank you, I skimmed the repository and it seems Anki itself has a function to add media files, I assume they do the necessary conversions there. I can look in depth and create a solution on Tuesday, but I have no IOS devices to test it on. I could make a branch with the fix and maybe someone could use that version to get the audios and test on their IOS device.

Rascalov commented 10 months ago

A new branch has been published with an untested fix for the issue. I will only publish if someone with Anki for IOS confirms that the audios added with this version will play. Until then I can't put this in the main release.

hu3rror commented 10 months ago

A new branch has been published with an untested fix for the issue. I will only publish if someone with Anki for IOS confirms that the audios added with this version will play. Until then I can't put this in the main release.

I just tested your new branch by cloning locally and making a new plugin folder. Audio downloads successfully and on desktop the downloads play fine. But still does not play on iOS. Let me know if any other debugging details would be helpful!

Rascalov commented 10 months ago

Thank you for testing, I think I will need more time to look over the repository and see what exactly is being done there to make ogg files work. Debugging info is not needed (yet :3) In the mean time, could you try setting the file extension to ogg in the addon config? image

More "in depth" of what I tried and why that might be the solution: Initially I noticed the repo used Anki's built-in method for adding downloaded audio to the media collection (throughout making this addon, I always miss built-in functionality that could've saved me so much work ><). So I did the same. I did not see any conversions before that point and figured anki did the conversions in the background using that method. I skimmed Anki source code for a bit but lord knows I'm not competent enough to make much sense out of all of it.

I think it did not work because of one of these reasons:

  1. The method doesn't do conversions
  2. The file was already named .mp3, so conversion was not deemed necessary.

If it's the latter, I would be in luck, if not I'll have to dig deeper.

I'll have some time at the end of the week to look through it all

hu3rror commented 10 months ago

I realized iOS does not support the .ogg format - it gives an error saying .mp3 is required.

Rascalov commented 10 months ago

yup, which is why I hoped I could make a conversion to mp3 somehow. Bottom line is, All audios of Forvo are available in ogg and some in mp3 format I just took another look at the addon you linked earlier, it seems theirs works partially because they ignore results that only have ogg as format. While I could do this, it would make a lot of audios unavailable, and setting this as the standard option will mean those audios are also unavailable to android users where ogg is supported.

I will continue to look for a conversion solution, but I might keep this option as a last resort.

BGiraffe14 commented 8 months ago

Hi there, Has there been any update to this? The only option I've found is to go into the media folder and force covert them all to mp3. I absolutely love the ease of this addon and would hate to have to go back to doing it the old fashioned way. Lmk if I can help with testing at all I have IOS devices as well as PC. Thanks!