Issue with audio files

After I used the editing add-on; some of my audio files turned into a black circle, which give a hereunder error when I’m trying to play the audio:
Error
An error occurred. Please use Tools > Check Database to see if that fixes the problem.
If problems persist, please report the problem on our support site. Please copy and paste the information below into your report.
Anki 2.1.35 (84dcaa86) Python 3.8.0 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=False sv=2
Add-ons, last update check: 2020-10-06 16:33:08

Caught exception:
Traceback (most recent call last):
File “aqt\webview.py”, line 37, in cmd
File “aqt\webview.py”, line 123, in _onCmd
File “aqt\webview.py”, line 547, in _onBridgeCmd
File “aqt\clayout.py”, line 370, in _on_bridge_cmd
File “aqt\sound.py”, line 640, in play_clicked_audio
IndexError: list index out of range

How can I solve this issue related to the audio files?

I’m afraid, it’s not easily fixable and it’d very likely require some manual work.

The audio files should still be in the collection.media folder but the field doesn’t contain enough information to automatically restore the filename.

  1. If not many cards were affected, use the card browser to find all the cards, e.g. using “pycmd__play” as a search string, and mark or flag them.

  2. Select them (Ctrl-A) and use Notes - Find and Replace (Ctrl-Alt-F).

    Find: <a class="replay-button[\s\S]*?</a>

    Replace With: [sound:_]

    In: All Fields

    Treat input as regular expression: Yes

  3. From the main window use Tools - Check Media to get a list of unused audio files.

  4. From the card browser find marked or flagged cards, or use “[sound__]” as a search string, and replace [sound:_] with the correct filename, e.g. [sound:filename.mp3].

  5. Then run Tools - Check Media again to confirm that there’re no unused audio files.

As an alternative, maybe upload somewhere one of your backups from the day, week or month ago if they contain the correct sound tags, and your current collection, and I’ll try to fix it.

Introduction - Anki Manual
Introduction - Anki Manual

2 Likes

Thank you so much; it worked.

1 Like

I think it’s safe to assume some people will miss your warning. Maybe the add-on should just do a simple text scan of the fields/template for cloze:/sound:/latex and refuse to run in such cases?

1 Like

Yes, will do.

1 Like