Anki Audio Binaries
raw JSON → 0.1.0 verified Sun Apr 12 auth: no python
Anki-audio is a Python package that bundles and distributes essential audio binaries (mpv and LAME) required by the Anki spaced repetition software for playing and recording audio. This library ensures that Anki has access to the necessary tools for multimedia functionality. The current version is 0.1.0, and releases are tied to Anki's development and binary requirements.
pip install anki-audio Common errors
error Sound and video on cards will not function until mpv or mplayer is installed. ↓
cause Anki requires mpv or mplayer to play audio and video content, and neither is installed or recognized.
fix
Install mpv or mplayer on your system. For example, on Ubuntu, run: sudo add-apt-repository universe; sudo apt update; sudo apt install mplayer mplayer-gui.
error Couldn't record audio. Have you installed 'lame'? ↓
cause Anki relies on the 'lame' encoder for recording audio, and it is either not installed or not accessible.
fix
Ensure 'lame' is installed and accessible. On macOS, you can install it using Homebrew: brew install lame.
error Exception in thread Thread-3: Traceback (most recent call last): File "threading.py", line 551, in __bootstrap_inner File "anki\sound.py", line 255, in run File "thirdparty\pyaudio.py", line 705, in open File "thirdparty\pyaudio.py", line 387, in __init__ OSError: [Errno -9999] Unanticipated host error ↓
cause Anki encounters an unexpected error when attempting to access the audio recording device, possibly due to microphone access issues or conflicts with other applications.
fix
Ensure no other applications are using the microphone, set the microphone as the default recording device, and restart your computer.
error mpv timed out, restarting ↓
cause Anki's media player, mpv, is unresponsive or has crashed, leading to timeouts during media playback.
fix
Restart Anki and ensure that mpv is properly installed and functioning on your system.
error An error occurred. Please use Tools > Check Database to see if that fixes the problem. ↓
cause Anki has encountered an unspecified error, potentially due to database corruption or issues with add-ons.
fix
Use the 'Check Database' feature under the Tools menu in Anki to identify and fix potential issues.
Warnings
gotcha Anki may fail to play or record audio if `mpv` or `lame` executables are not found on the system's PATH or if conflicting versions are present. Ensure the environment is correctly configured after installing `anki-audio`. ↓
fix Verify that `mpv` and `lame` are discoverable by checking your system's PATH. On Windows, manually replacing `mpv.exe` in the Anki installation folder with a known working version or checking its log file can help diagnose issues.
gotcha On Windows, `mpv.exe` might have issues playing audio files with UTF-8 characters in their filenames, even if other players like VLC handle them correctly. This can lead to silence during playback within Anki. ↓
fix Try changing Windows' administrative language settings to 'Beta: Use Unicode UTF-8 for worldwide language support' and rebooting. As a workaround, avoid non-ASCII characters in audio filenames.
breaking Major Anki updates can sometimes disrupt audio playback. For instance, Anki 25.02 introduced changes (e.g., DOMPurify sanitization) that broke HTML tags related to audio embedding in some card templates, or altered MPV integration behavior. ↓
fix Check Anki's official forums or release notes for specific workarounds related to your Anki version. This might involve adjusting card templates or, as a temporary measure, reverting to an older Anki version.
gotcha Users frequently report audio playback issues in Anki, such as stuttering, cutting off, or complete silence. These can be caused by various factors including outdated audio drivers, Bluetooth device interference, specific `mpv` versions, or system performance bottlenecks. ↓
fix Troubleshoot by updating audio drivers, disconnecting Bluetooth devices, checking Anki's debug console for `mpv` logs, or experimenting with different `mpv` versions. Consider temporary workarounds like playing background music or using different video output drivers in Anki's settings.
Quickstart
import shutil
import os
print("Checking for Anki audio binaries after installation:")
mpv_path = shutil.which("mpv")
lame_path = shutil.which("lame")
if mpv_path:
print(f"mpv executable found at: {mpv_path}")
else:
print("mpv executable NOT found on PATH. Anki audio playback may fail.")
if lame_path:
print(f"lame executable found at: {lame_path}")
else:
print("lame executable NOT found on PATH. Anki audio recording/processing may fail.")
print("\nFor Anki to use these, ensure Anki is configured to find them or that they are correctly on your system's PATH.")
print("Typically, Anki automatically detects these if they are installed correctly via 'anki-audio'.")