itkach / aard2-android

Aard2 for Android, a simple dictionary app
GNU General Public License v3.0
458 stars 97 forks source link

Added Text to Speech feature #100

Closed bpanthi977 closed 1 year ago

bpanthi977 commented 5 years ago

Hello! I have tried to add text to speech feature to the app. I guess requires some finishing touch but it works. A "Text to Speech" option is added to the activity bar and on clicking that the TTS api of android is used to read out the text. The speech can be cancled by clicking the button again.

francwalter commented 5 years ago

Could you create a apk-file of it, so I could test it? I have not the time to create it myself at the moment, thanks. Frank

bpanthi977 commented 5 years ago

This is the debug build I tested on. debug.zip

itkach commented 5 years ago

This is an interesting proof of concept, but there are issues that would need to be resolved before it can be seriously considered for addition. The biggest one is TTS language and language selection. Just setting it to English doesn't cut it. TTS language needs to be set to that of the content. For HTML content, language can be specified with lang attribute for the entire document and/or individual elements. So to read it correctly, all the parts in various languages have to be fed into corresponding TTS engine instances (one per language) in the order in which they should be read. For plain text content tts language would have to come from somewhere else, maybe a tag in the dictionary that explicitly specifies content language. All the dictionary converters would need to be updated to mark html articles with lang attribute and/or include a dictionary tag specifying content language (and then all the dictionaries recompiled). TTS language probably also needs to be user-selectable, per dictionary, for the cases where it can't be determined from the content or the dictionary. User experience would also need to be improved: starting reading from the beginning each time after speech is cancelled only useable for very short text.

bpanthi977 commented 5 years ago

I agree with you. I will surely get back to it after my exams are over. Moreover each language can have multiple voices installed, so I guess we will have to implement interface to select voice also.

On 19 Aug 2019 9:15 a.m., "itkach" notifications@github.com wrote:

This is an interesting proof of concept, but there are issues that would need to be resolved before it can be seriously considered for addition. The biggest one is TTS language and language selection. Just setting it to English doesn't cut it. TTS language needs to be set to that of the content. For HTML content, language can be specified with lang attribute for the entire document and/or individual elements. So to read it correctly, all the parts in various languages have to be fed into corresponding TTS engine instances (one per language) in the order in which they should be read. For plain text content tts language would have to come from somewhere else, maybe a tag in the dictionary that explicitly specifies content language. All the dictionary converters would need to be updated to mark html articles with lang attribute and/or include a dictionary tag specifying content language (and then all the dictionaries recompiled). TTS language probably also needs to be user-selectable, per dictionary, for the cases where it can't be determined from the content or the dictionary. User experience would also need to be improved: starting reading from the beginning each time after speech is cancelled only useable for very short text.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/itkach/aard2-android/pull/100?email_source=notifications&email_token=AEGM7K4SUKZPVAX3X2BHSUTQFIHXDA5CNFSM4IMRDFY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4RSVMA#issuecomment-522398384, or mute the thread https://github.com/notifications/unsubscribe-auth/AEGM7K575KBTZBIJW7D4UBTQFIHXDANCNFSM4IMRDFYQ .