Improved audio support - #102
Open
shugyosha89 wants to merge 6 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_driversfolder.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:
audio_fieldtoword_audio_field(but maintains backward compatibility withaudio_fieldif 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.