Can't sync media

I’m unable to sync media in my deck.

Here’s my sync preferences:
image

Here is the media log:
image

When I preview a card in Anki browser on my desktop PC, the sounds play, but they’re not there in the same cards in anki web.

I have also tried “Check Media”, followed by “Check Database”, followed by ticking “On next sync, force changes in one direction”, and then I clicked in the upload direction, and it didn’t work.

Potential complications:
The first time I imported this deck, I synced, and then deleted the deck (and synced again). I am not sure if the media was successfully synced during the first sync. I then imported again (once I realised actually this is the correct deck that I want), then synced again, and the deck appears in anki web again, but the media isn’t on the cards in anki web.

  • On AnkiWeb, what do you see where the media is supposed to be?
    • When you look at the card from the study screen, do you see a play button/audio bar?
    • When you open the note in Edit view, do you see a sound tag in that field (like [sound:98f133d2.mp3])?
  • What kind of audio file is it?
  • Have you added or removed any media from your collection since you did that first import-sync-delete-reimport sequence?

Hi Danika, thanks for the prompt reply :slight_smile:

  1. The front side of the cards are the same, since media isn’t displayed on those. But for the back, here is what I see in the anki app:

And here is what I see in anki web for the same card:

notice that the play buttons aren’t there. Also the audio plays automatically once when the backside card is revealed on in anki app, but not in anki web.

  1. the deck(s) I am referring to is called “Ankidrone Starter Pack” (I would provide a link but it’s not allowed here). You can easily google it and find details about it. They mention the “Opus” format. FYI to import this, I downloaded and then extracted the Ankidrone.zip file, then directly imported “Ankidrone Starter Pack V7.zip” into Anki.

  2. I haven’t manually added/removed any media - it’s just whatever came imported in that zip file.

  1. You didn’t answer about what is actually contained in the field(s) of the note. And now I will also need to see your card templates. I suspect this fancy template is doing something unusual to display the audio, and AnkiWeb doesn’t understand it. [If the templates are long, please be extra sure to post the text in a pre-formatted/code block.]
  2. If the audio is of an unusual format, it’s possible that AnkiWeb can’t play it. But I am not volunteering to download and install this deck to answer these questions for you. These are questions you’re going to have to answer yourself. If you have questions about where to look to answer to these questions, ask!
  3. It’s possible that the media collection on AnkiWeb is incomplete (which a one-way sync won’t fix – but I think there are many other variables here to check first.
1 Like
  1. In the card notes themselves, the field values have values like this:
    image
    image

  2. The audio is in “Opus” format. While supported by web browsers, I’m not sure if it’s supported by Ankiweb?

After looking around for a while, I can confirm that the audio files (the .ogg files) are indeed being synced properly. I can confirm this by checking links such as https://ankiuser.net/study/media/N1_0002_1.ogg, for instance; which plays all the .ogg files I checked. So this must be an issue with ankiweb not liking referencing ogg files with a simple {{field_name}}.

FYI this is the code for card (back) I am trying to fix:

<div class="wrap">
    <div class="fside">{{FrontSide}}</div>

    <div class="sent-center">
        <div class="jpsentence" lang="ja">
            {{edit:furigana:SentFurigana}}
	    {{^SentFurigana}}{{edit:furigana:SentKanji}}{{/SentFurigana}}
        </div>
        {{#SentEng}}
        <div class="ensentence" lang="en">{{hint:SentEng}}</div>
        {{/SentEng}}
    </div>

    <div class="vocab">
        {{VocabAudio}}{{SentAudio}}{{VocabPitchPattern}}
	{{^VocabPitchPattern}}{{text:kana:VocabFurigana}}{{/VocabPitchPattern}}
	{{#VocabPitchNum}}<span class="tags" id="pitchnum">{{VocabPitchNum}}</span>{{/VocabPitchNum}}
	{{#VocabKanji}}【{{text:kanji:VocabKanji}}】{{/VocabKanji}}
    </div>

    {{#VocabDef}}
    <div class="definitions">{{edit:furigana:VocabDef}}</div>
    {{/VocabDef}}
    {{#Notes}}
    <div class="notes">
        <div class="tags">Notes</div>
        <div>{{furigana:Notes}}</div>
    </div>
    {{/Notes}}
    {{#Image}}
    <div class="images">{{Image}}</div>
    {{/Image}}

    <hr />

    <footer>
        {{#SentKanji}}<a title="Translate with SimplyTranslate"
            href="https://translate.metalune.xyz/?engine=google&text={{text:kanji:SentKanji}}&sl=ja&tl=en">Translate</a><a
            href="https://jisho.org/search?keyword={{text:kanji:SentKanji}}" title="Sentence on Jisho">Jisho</a><a
            href="https://www.google.co.jp/search?q={{text:kanji:SentKanji}}&tbm=isch"
            title="Search images">Images</a>{{/SentKanji}}{{#VocabKanji}}<a
            href="http://www.weblio.jp/content/{{text:VocabKanji}}" title="Vocab on Weblio">Weblio</a><a
            href="https://wadoku.de/search/?q={{text:VocabKanji}}" title="Vocab on Wadoku">Wadoku</a>{{/VocabKanji}}
    </footer>
</div> <!-- /wrap -->

<script>
    function tweak_reveal_text() {
        const elem = document.querySelector("div.ensentence > a.hint");
        if (elem) {
            elem.innerText = "Reveal English translation";
        }
    }
    function removePitchBrackets() {
        const tags = document.getElementById("pitchnum");
        if (tags !== null) {
            tags.innerHTML = tags.innerHTML.replace(/[\[\]]/g, "");
        }
    }
    markPitch();
    removePitchBrackets();
    tweak_reveal_text();
</script>

it’s the “{{VocabAudio}}{{SentAudio}}” that don’t seem to like .ogg files.

When I replace with .mp3 files, they display and play fine, without any code changes, so it’s definitely ankiweb not liking ogg files.

So the new question is: How can I change the code above to play .ogg files in ankiweb?

I have confirmed this issue in firefox (as well as chrome). ogg files can’t be played back, but mp3 files can, when referencing audio via {{FieldName}}.

FYI, my workaround is: find and replace all the VocabAudio and SentAudio field values from “[sound:filename.ogg]” to “filename.ogg”, and then change the cards so instead of referencing {{VocabAudio}} / {{SentAudio}} directly, I create audio controls like:

    {{#VocabAudio}}
    <audio controls>
        <source src={{VocabAudio}} type="audio/ogg">
    </audio>
    {{/VocabAudio}}
    {{#SentAudio}}
    <audio controls>
        <source src={{SentAudio}} type="audio/ogg">
    </audio>
    {{/SentAudio}}

This case is closed for me now, however, a conclusion for the anki devs:
It seems that [sound: … ] embedding doesn’t work properly for ogg files in anki web, but it does in anki app (for desktop at least). When you change the sound file type from ogg to mp3, it works find in both anki web and anki app.

When you review your collection on AnkiWeb, it replaces [sound:filename.mp3] tags with <audio controls>...</audio> tags for you automatically. But for files that have .ogg extension it doesn’t do that, it just hides them. However, if you just change a file from filename.ogg to filename.mp3 (and rename it accordingly in the collection.media folder as well), they play normally. Because this trick works, it is likely that there’s no technical obstacle to having ogg files play on AnkiWeb. They must be blocklisted by AnkiWeb explicitly. I suggest removing this restriction because it causes inconvenience for no good reason. @dae could you fix it, please?

AnkiWeb used to use flash to play audio a long time ago, and this is a relic from that time. I’m not sure changing it is a good idea however, since .ogg files also don’t work on iOS. I’d rather deck authors use .mp3s - they work on all platforms, and are no longer patent-encumbered.

1 Like

If there’s a deck that contains ogg files, would it be possible to have Ankiweb render those files as <audio> tags, like it already does with mp3 files? I imagine it should work in any operating system because Ankiweb is used in a web browser. This also applies to aac files.

When we designed the deck mentioned by @ben22, we considered using aac instead of mp3. I don’t know much about iOS (I reject it because it is proprietary), but I believe it supports aac files. Basically, all operating systems support aac. But Ankiweb doesn’t, which also makes it less attractive for deck authors.

Yes, but as I mentioned above, I’m not sure I want to be encouraging deck authors to be using a format that won’t work on some platforms. mp3 is the most universally supported, and with the patent being expired, there’s no good reason to avoid it.

I see. But aac works on all platforms, right? Is there a different reason not to support aac files on Ankiweb?

As far as I’m aware, there are browsers that support .mp3 but not .aac. For example, I think Firefox can only play .aac if the OS supports it.

That’s really unfortunate. Feels like an artificial limit on systems that don’t suffer from the lack of support.

For me the biggest reason to avoid mp3 is that mp3 files are noticeably larger than opus files of the same quality. So when all files in my collection are in opus format, I can store more files in total with the same amount of disk space.

I so so agree with this. .ogg also sounds nice. I used to store all my music files in this format. I’ve given up as now I can’t find a good source and conversion is something I neither know nor have time for. Anyways, file size is a good argument and I imagine even spotify uses it for this reason.

1 Like

I think that using the ogg/opus format makes a lot of sense when using Anki for learning a foreign language, as it is optimized for speech. In my Anki collection I have many recordings of native speakers pronouncing words and sentences that I had previously learned. I mostly use Anki on GNU, and occasionally on Android, so it’s nice to have opus support available on both platforms. However, there are also people who use Ankiweb, and they would greatly benefit from having opus support implemented on that platform as well. It must be super easy to implement, coming down to just a regex that replaces [sound:file.ogg] to <audio><source...></audio> with a couple capturing groups. If it was possible to contribute to Ankiweb, I’d likely attempt to write a PR that fixes this.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.