Anki add-on: Audio Files

A simple add-on to search for audio files matching the text in a field. It adds a button to the editor to use during note editing to search for audio data using the text in the current field. A configuration option is provided to make the search use selected text if a text selection has been made. The audio file content is uploaded to Anki and a [sound:...] element appended to the text. That can be cut& pasted into a separate field for sound if desired, making what I have found to be a quick and simple process for getting sound data into your notes. For instance, for a field containing "немножко" the result of using this add-on with the cursor in the field would be that the field contains "немножко[sound:немножко.mp3]" and the audio data is copied to Anki's media folder. It is also copied to a local working folder - by default the system location for temporary data, but the folder used can be changed via a configuration parameter. 3 sources of data are currently used, Forvo, Wiktionary and Open Russian - data sources can be separately enabled or disabled. The addon has been designed to make it easy to add code for using additional data sources. For Wiktionary the target language to search is a configuration option - it should match the code used by Wiktionary to specify locale, eg "En-uk" for UK English. The default is 'ru'. For Forvo the target language to search is a configuration option - it should match the code used by Forvo to search by language. The default is 'ru'. Accents are supported for Forvo - for instance using a code of "es_es" will search for Spanish words as spoken in Spain. Instead of using the word as the filename the data can be saved with a random filename by setting the 'filenames' configuration option to 'random'. To maximise the likelihood of finding a sound file searches will be automatically repeated using minor transformations of the text. This is configured, separately for each data source, by selecting one or more search rules. Note that at least one rule must be selected for a search to be made - by default the 'convert to lowercase' rule is selected. A simple dialog has been provided to make configuration easy. Note that configuration is per Anki profile, so if you use multiple profiles configuration changes will only affect the active profile. change log 20220730 Forvo parser fixed after broken due to Forvo website change 20220418 added support for language dialects in Forvo added rule to strip Wiktionary stress accents for Russian 20211111 fixed bug in configuring selected rules 20211110 added configuration per user profile instead of a single global configuration added text search rules to automate retrying with simple text changes fixed bug when using selected text - the filename is now appended after the selection instead of overwriting it 20201228 added configuration dialog added option to search by selected text 20191230 fixed issue if no tmp dir configured support generating random filenames 20191123 added Forvo data source

GitHub repository: r-appleton/addons
Repository description: Anki addons
Languages: Python, HTML, CSS