Skip to content

Improved audio support - #102

Open
shugyosha89 wants to merge 6 commits into
Ajatt-Tools:masterfrom
shugyosha89:feat/audio_drivers
Open

Improved audio support#102
shugyosha89 wants to merge 6 commits into
Ajatt-Tools:masterfrom
shugyosha89:feat/audio_drivers

Conversation

@shugyosha89

Copy link
Copy Markdown

Hi, thanks for this plugin, it's great and I started using it recently for reading in Japanese.

This change wasn't requested but I wanted to add better support for audio so I thought I'd share what I came up with.

The current code only supports Forvo for audio retrieval, which can be unreliable (#93). It also only supports getting audio for the word, not for the context sentence.

This PR refactors audio to a driver based system. This means that in addition to Forvo (the default), people can contribute their own audio drivers to retrieve or generate audio from various sources. Audio can be retrieved for both the word and the context sentence.

Drivers are stored in the audio_drivers folder.

I have included a driver for generating audio using VoiceVox (can be self-hosted for generating free AI Japanese audio).

Each audio driver can specify its own driver settings (in VoiceVox's case things like server URL & speaker/voice ID).

Driver can be configured for the word & context sentence independently (e.g. retrieve the word from Forvo, the sentence from VoiceVox).

The audio driver is passed the full note data so any fields like KanaReading or PitchNum that might be helpful for generating the audio can be used (the VoiceVox driver makes use of this).

Drivers are expected to return a filename and either a URL to an audio file (like for Forvo) or a base64 string of the audio data.

The PR also includes these minor changes:

  • Increased timeout when creating a note in AnkiConnect (prevents unnecessary timeout errors displaying)
  • Update the "Add to Anki" button text to "Adding..." and "Added to Anki" to show visual confirmation to the user
  • Renamed audio_field to word_audio_field (but maintains backward compatibility with audio_field if not present)

I think there should be no breaking changes. It defaults to the same behaviour: Forvo for word audio and nothing for sentence audio.

If you'd like me to make any changes, please let me know. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant