Is your feature request related to a problem? Please describe.
It is possible to use TTS from JavaScript API, but the voice is not native. Also, sometimes AnkiDroidJS.ankiTtsSpeak is not defined for some reasons.
I can indeed use AwesomeTTS to generate audio files, but syncing large media folder is quite problematic, as well as it is impossible to do in large batch with gTTS. Instead, I chose to run gTTS on demand on an external server, but of course, it is not uploaded to AnkiDroid that way.
HTML5 Audio element can be created, but autoplay doesn't work. Clicking via JavaScript doesn't work either unless there is an actual click.
Describe the solution you'd like
AnkiDroidJS.ankiPlayAudio to play audio on Java/Kotlin side would pretty much be the surefire way.
Describe alternatives you've considered
I can also trap the first click, so this works.
<script>
(function() {
function doAutoplay() { document.querySelector('[autoplay]').click(); document.removeEventListener('click', doAutoplay) }
document.addEventListener('click', doAutoplay)
})()
</script>
Additional context
TTS / audio files in Anki are a very big culprit of sync size, especially on the first sync. I think it is always better to allow online shared resources.
Is your feature request related to a problem? Please describe.
It is possible to use TTS from JavaScript API, but the voice is not native. Also, sometimes
AnkiDroidJS.ankiTtsSpeakis not defined for some reasons.I can indeed use AwesomeTTS to generate audio files, but syncing large media folder is quite problematic, as well as it is impossible to do in large batch with gTTS. Instead, I chose to run gTTS on demand on an external server, but of course, it is not uploaded to AnkiDroid that way.
HTML5 Audio element can be created, but autoplay doesn't work. Clicking via JavaScript doesn't work either unless there is an actual click.
Describe the solution you'd like
AnkiDroidJS.ankiPlayAudioto play audio on Java/Kotlin side would pretty much be the surefire way.Describe alternatives you've considered
I can also trap the first click, so this works.
Additional context
TTS / audio files in Anki are a very big culprit of sync size, especially on the first sync. I think it is always better to allow online shared resources.