dicio-android icon indicating copy to clipboard operation
dicio-android copied to clipboard

Skill: Definitions lookup

Open GoogleIsEvil opened this issue 1 year ago • 7 comments

"I cannot complete your request"

It would be nice if Dicio could give us the meaning of words(and read them back).

E.g., if I'm reading a book and don't know a definition it would be nice if I could quickly look it up as fast as possible. Also, for multiple languages:

E.g.,: "Definition in French beaucoup" and it recites the definition out loud.

GoogleIsEvil avatar Jan 28 '25 15:01 GoogleIsEvil

This is a duplicate of #200. I am currently working on coding this skill and hope to have a pull request out sometime soon. 🤞

Inhishonor avatar Jan 28 '25 17:01 Inhishonor

Ok, Hopefully have a slimmed down version just for quick definition lookups.

The entire point for me is to have a hands free way to simply ask for a definition very quickly as I'm reading. Ideally it would work with foreign words.

I have many dictionaries but having to take the time to type in and read the words slows down the entire process of reading the book. I'm not sure if something like one of those can be integrated into dicio itself where it can simply look up the word and say it's definition(s).

E.g., maybe one can install a definitions text(e.g., one of the free ones such as from freedict: https://freedict.org/) or use an online source(e.g., http://freedictionary.org/)

Then one can change the language with a command such as: "Set Dictionary English <to French>" and then "Definition " and it will take the English word and give the definition in French(There are TTS libraries that might help with pronunciation them correctly. The best I've seen is the ReadEra TTS which are based off the google TTS stuff IIRC but one can download them)

GoogleIsEvil avatar Jan 29 '25 23:01 GoogleIsEvil

I was planning on using the https://dictionaryapi.dev/ API. Mainly, so that it is lightweight. (And easy to implement. 😀 ) Unfortunately, it is only for English. I have looked into other languages, but not much luck yet... Having a dictionary that is downloaded is a good idea, but I think it may be a tad to difficult to implement, and/or, not really what this project is for. Not sure though, someone else might know better. Good idea, regarding switching languages. I will do that. The TTS is a tad out of my wheelhouse, but I could look into it.

Inhishonor avatar Jan 30 '25 01:01 Inhishonor

@Stypox Do you have anything to add to this? Does it sound good to you? Thanks!

Inhishonor avatar Jan 30 '25 01:01 Inhishonor

I have something to add that may not be directly related:

You should be able to add custom commands relatively easy: Basically STT->Match to custom command->Execute command.

I'm not sure how useful it is with android but you could enable launching activities, opening files, etc. I haven't thought about it much but just thought it might be a useful generality for the app which if it could be done well might be quite useful.

In general, it would be nice to potentially have some way to automate things and then launch them with STT commands. Again, I don't know enough about android to know how useful this could be.

But say, you could enable launching python, bash, java, or kotlin scripts/code that take arguments which are passed to it through STT. Then one can write these scripts to do whatever they way more or less. This enables much more generalization of the app than having to hard code everything(which will never be able to satisfy everyone's needs/desires).


The downloadable dictionary stuff should be easy:

E.g., with freedict you can download many language files. This is from eng->pol and is in the .dict format which is just plain text that looks like:

abominable /əˈbɒmɪnəbəl/ I. <Adj> straszny II. <N Comp>Abominable Snowman /ɐbˈɒmɪnəbəl snˈəʊmən/ yeti abominably /əˈbɒmɪnəblɪ/ <Adv> okropnie abort /əˈbɔ:t/ I. <V> 1. poronić, przerwać ciążę 2. przerwać [przed zakończeniem] II. <N> [komp] abort, przerwanie zadania abortion /əˈbɔ:ʃən/ <N> aborcja, poronienie abortive /əˈbɔ:tɪv/ <Adj> nieskuteczny abound /əˈbaʊnd/ <V> być w obfitości, obfitować (with sth - w coś) (in sth - w coś) about /əˈbaʊt/ <Prep>

  1. o
  2. z
  3. około
  4. wokoło

So basically you just look up the word in English(that is not indented) and then the definitions come afterwards which you would just read with TTS. [to speed up searching you can use a binary search since obviously the file terms are in alphabetical order]

So the basic idea is:

  1. Get in and out languages(probably set up either with some STT command or settings) which correspond to some freedict file usually in the format - (so might have to have a map say "English->eng, Polish->pol", etc to match to the file)
  2. Search for the term in the list and extract the definitions. This is easy and standard lookup and text stuff.
  3. Say the definitions using TTS. [This might be a little work but shouldn't be too bad E.g: https://www.geeksforgeeks.org/how-to-convert-text-to-speech-in-android-using-kotlin/

import android.speech.tts.TextToSpeech

tts!!.speak(text, TextToSpeech.QUEUE_FLUSH, null,"")

So basically it's pretty simple but just a lot of wiring up.

With the TTS you can then do more like even have it read back articles and such and even go into more like using voice to navigate sorta like screen readers. E.g., "Search google for " then it returns the search and you can read off the headers and then "Stop and open" and it will open the last one it spoke and then open that site and start reading it or read the summary google gives or whatever.

Using the TTS should be pretty simple for definitions though. You already have the ability to convert the STT so it's really just all plumbing and then polishing.

You could even then add an AI feature where you wrap some AI and let one put in the prompt using STT then read the AI output using TTS and basically have something like Siri but more useful. Maybe use deepseek.

GoogleIsEvil avatar Jan 31 '25 20:01 GoogleIsEvil

@Inhishonor sorry for the late reply. I think using an API is fine as an initial implementation, however it would be good if it supported multiple languages. The dictionary-files implementation could come as a community-maintained skill once there will be a way to install skills as plugins.

One issue I see with this skill is that the STT will not be able to understand a word in another language, so users will have to type it in manually.

To make the skill more powerful, you could compile a list of all possible language names and their variations (e.g. English, French, German, Italian, ...), so that the assistant is able to understand "what is the definition of ... in French".

Stypox avatar Feb 26 '25 16:02 Stypox

I will work on this and see what I can do. Thanks!

Inhishonor avatar Mar 01 '25 04:03 Inhishonor