Audio playback delay when flipping card/replaying (Linux)

Hello!

On my Linux desktop every audio playback is delayed by about 2-5 seconds. This gets pretty annoying considering it lengthens my reviews by up to 30%.

I do have mpv installed and I saw Anki starting it in the process manager.

Anybody else encountering this or knows a fix to this?

Thank you!

Anki/System info:
Version 2.1.35 (84dcaa86)
Python 3.9.1 Qt 5.15.2 PyQt 5.15.2
Manjaro 20.2 Nibia / x86_64 Linux 5.10.2-2-MANJARO
KDE 5.77.0 / Plasma 5.20.4 / KWin
Intel Core i7-4790K / GeForce GTX 970 / 16GB RAM

Please use mpv in the command line to play a file - do you get the same delay, or does the issue only exist in Anki? If the issue is not limited to Anki and happens with mpv from the command line, perhaps people on your distro’s forums can give you some hints about how to fix the issue.

There doesn’t seem to be any delay at all when playing the same media files via mpv from the command line.

If there’s a delay between two files, maybe run something similar in the Debug Console in Anki.

https://docs.ankiweb.net/#/misc?id=debug-console

from aqt.sound import av_player
av_player.play_file(filename="audio1.mp3")
av_player.insert_file(filename="audio2.mp3")

If there’s a delay, maybe check the audio files with Audacity, maybe there’re a few seconds of silence at the end.


You could also create mpv.conf in Anki2 folder with something similar to

log-file=C:\Users\Nickolay\Desktop\mpv.log.txt

https://docs.ankiweb.net/#/files?id=file-locations
https://mpv.io/manual/master/#options-log-file

then restart Anki, review a few cards, if you notice a delay, take a look at mpv.log.txt. It will contain something like

[  80.451][cplayer] Run command: loadfile
[  80.497][cplayer] Starting playback
...
[  80.548][v][cplayer] starting audio playback

In this case the delay is about 97 ms. But since you couldn’t reproduce the delay by playing the audiofile directly with mpv, it’s likely that the delay will be about the same or less, and mpv.log.txt probably won’t be very helpful.


Maybe try to temporarily uninstall mpv and install mplayer.

2 Likes

I’m having the same problem since 2.1.35 or even earlier. It seems to be a long running problem. It only happens with on-the-fly tts. Not with generated mp3’s or cached on-the-fly mp3’s.