Anki-android: Feature request: Compatibility with Anki 2.1.20 TTS field feature

Created on 6 Mar 2020  路  13Comments  路  Source: ankidroid/Anki-Android

Hello,

this is my feature request to add compatibility to the new Anki 2.1.20 TTS support. Please note that it was done in a rush since I have a deadline approaching.

https://apps.ankiweb.net/docs/manual.html#text-to-speech
https://github.com/ankitects/anki/search?q=tts&unscoped_q=tts

Please note that my card does not make use of the tts voice/speed settings, which would ideally be included as well.

Reproduction Steps
  1. Use Test.apkg.zip

    • test card employing the use of a {{tts en_GB:Front}} to on-the-fly generate a TTS with the contents of the front field

Expected Result

According to https://apps.ankiweb.net/docs/manual.html#text-to-speech, there should be a play audio button, the text in the {{tts en_GB:Field}} will not be shown and the audio is automatically played when reviewing.

image

Actual Result
  • it doesn't generate an audio button
  • it doesn't automatically play the TTS
  • it shows the content of the field, which it isn't supposed to do
Research

[ x ] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid

[ x ] I have checked the manual and the FAQ and could not find a solution to my issue

[ x ] I have searched for similar existing issues here and on the user forum

Accepted Anki Ecosystem Compatibility Audio Blocked by dependency Help Wanted Keep Open

All 13 comments

Thanks @p4nix I appreciate your taking the time to log this

One could convert the new 2.1.20 TTS syntax into the old syntax. Essentially, {{Front}}{{tts de_DE:Front}} becomes {{Front}}<tts service="android" voice="de_DE">Front</tts>.

As I understand it, one could grab a string surrounded by {{tts and ending in }}, interpret the first characters (ending before a colon: or a space ) as the old syntax "voice". Characters after the colon : would be the field name, which must be passed as a string e.g. Front, NOT {{Front}}. All other characters (if included, e.g. voices=Apple_Otoya,Microsoft_Haruka) would be ignored, as they have information pertaining to MacOS or Windows.

Thanks for looking into this issue!
I myself have downloaded the AnkiDroid sourcecode to look into this, but I am afraid my limited knowledge of coding and limited amount of time I could spend for it didn't allow me to find a solution. Please note that your solution would only be a "dirty fix" (no offense, it would help me out personally with that issue) - but ideally, it should generate the standard voice button by saving the audio temporarily, as I understand it works on Anki desktop. Otherwise it wouldn't really be ecosystem compatibility :)

Basic flow:


Notes

A worrying method is temp_file_for_tag_and_voice, but this appears unused. It seems easiest to ignore this in our implementation and let our TTS engine handle caching.

How do I unsuspend my greendot card i found

@david-allison-1
Would that also yield a play button similar to how the Anki 2.1.20 does?
I find it useful being able to break up the sound playback, instead of always getting the audio for the full text. Hence the question and request :)

@EmilRehnberg Haven't looked into the implementation, but the initial change will almost certainly mirror how Anki Desktop does it.

Hello 馃憢, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like _still searching for solutions_ and if you found one, please open a pull request! You have 7 days until this gets closed automatically

I'm planning on supporting the Anki 2.1.20 TTS {{tts}} functionality within AwesomeTTS (as opposed to the previously used tag). This would allow on-the-fly TTS to support a fallback mechanism on AnkiMobile (iOS). Ideally AnkiDroid would also support this syntax, so that the fallback works on AnkiDroid as well.

I'm getting the initial stages of the Rust conversion into AnkiDroid 2.14, after then we'll be able to use the Anki Desktop TTS code.

That sounds like a good idea, will you be able to share a large proportion of code with Anki at that point ? I did notice the code which parses the {{tts}} tag is in rust (.rs file - I know nothing about rust).

That sounds like a good idea, will you be able to share a large proportion of code with Anki at that point ? I did notice the code which parses the {{tts}} tag is in rust (.rs file - I know nothing about rust).

We'll be compiling the rust as a native library for Android, none of the Python sadly

Was this page helpful?
0 / 5 - 0 ratings

Related issues

homocomputeris picture homocomputeris  路  5Comments

snowtimeglass picture snowtimeglass  路  5Comments

OoDeLally picture OoDeLally  路  4Comments

noamraph picture noamraph  路  3Comments

david-allison-1 picture david-allison-1  路  4Comments