Dicio assistant app for Android
Dicio is a free and open source voice assistant running on Android. It supports many different skills and input/output methods, and it provides both speech and graphical feedback to a question. It uses Vosk for speech to text. It has multilanguage support, and is currently available in these languages: English, French, German, Greek, Italian, Russian, Slovenian and Spanish. Open to contributions :-D
Currently Dicio answers questions about:
Dicio uses Vosk as its speech to text (STT
) engine. In order to be able to run on every phone small models are employed, weighing ~50MB
. The download from here starts automatically whenever needed, so the app language can be changed seamlessly.
Dicio's code is not only here! The repository with the compiler for sentences language files is at dicio-sentences-compiler
, the code taking care of input matching and skill interfaces is at dicio-skill
and the number parser and formatter is at dicio-numbers
.
When contributing keep in mind that other people may have needs and views different than yours, so please respect them. For any question feel free to contact the project team at @Stypox.
ircs://irc.libera.chat:6697/dicio
) is available to get in touch with the developers. Click here for webchat!If you want to translate Dicio to a new language you have to follow these steps:
Translate the sentences used by Dicio to identify a user's request and to feed it to the correct skill. To do this open the repository root and navigate to app/src/main/sentences/
. Copy-paste the en
folder (i.e. the one containing English translations) and call the new folder with the 2- or 3-letter name of your language (in particular, any ISO-639
-compliant language ID is supported). Then open the newly created folder: inside there should be some files with the .dslf
extension and in English language. Open each one of them and translate the English content; feel free to add/remove sentences if their translation does not fit into your language and remember those sentences need to identify as better as possible what the user said. Do NOT edit the name of the copied files or the first line in them (i.e. the ID: SPECIFICITY
line, like weather: high
): they should remain English. To learn about the Dicio sentences language syntax, please refer to the documentation and the example in dicio-sentences-compiler
. Hopefully in the future a custom translation system will be used for sentences.
Once both the Weblate and the sentences translations are ready, add the new language to the app's language selector. You can do so by editing this file:
pref_language_entry_values
. You must respect the alphabetic order. You can find the language code with Weblate: click on a language to translate, and the language code is in the last part of the URL. For example, English is https://hosted.weblate.org/projects/dicio-android/strings/en
, and English language code is en
.pref_language_entries
. It must be placed at the same index as language code. For instance, if en
is the 3rd on the language code array, then it's the 3rd on the language name array, too.Then update the app descriptions so that people know that the language you are adding is supported. The files you should edit are README.md (i.e. the file you are currently viewing) and fastlane/metadata/android/en-US/full_description.txt (the English description for F-Droid).
Open a pull request containing both the translated sentences files, the language selector addition and the app descriptions updates. You may want to take a look at the pull request that added German, #19, and if you need help don't hesitate to ask :-)
A skill is a component that enables the assistant to understand some specific queries and act accordingly. While reading the instructions, keep in mind the skill structure description on the dicio-skill
repo, the javadocs of the methods being implemented and the code of the already implemented skills. In order to add a skill to Dicio you have to follow the steps below, where SKILL_ID
is the computer readable name of the skill (e.g. weather
).
Create a file named SKILL_ID.dslf
(e.g. weather.dslf
) under app/src/main/sentences/en/
: it will contain the sentences the skill should recognize.
SKILL_ID: SPECIFICITY
(e.g. weather: high
) on the first line, where SPECIFICITY
can be high
, medium
or low
. Choose the specificity wisely: for example, a section that matches queries about phone calls is very specific, while one that matches every question about famous people has a lower specificity.dicio-sentences-language
's syntax.SECTION_NAME: SPECIFICITY
to the same file (check out the calculator skill for why that could be useful). For style reasons, always prefix the section name with SKILL_ID_
(e.g. calculator_operators
).InputRecognizer
. If you do so, replace any reference to StandardRecognizer
with your recognizer and any reference to StandardResult
with the result type of your recognizer, while reading the steps below..dslf
file.Create a subpackage that will contain all of the classes you are about to add: org.stypox.dicio.skills.SKILLID
(e.g. org.stypox.dicio.skills.weather
).
Create a class named SKILL_IDOutput
(e.g. WeatherOutput
): it will contain the code that talks, displays information or does actions. It will not contain code that fetches data from the internet or does calculations.
Data
and add to that class some public
fields representing the input to the output generator, i.e. all of the data needed to provide an output.OutputGenerator<Data>
(e.g. WeatherOutput implements OutputGenerator<WeatherOutput.Data>
)generate()
method and implement the output behaviour of the skill. In particular, use SpeechOutputDevice
for speech output and GraphicalOutputDevice
for graphical output.Create a class named PROCESSOR_NAMEProcessor
(e.g. OpenWeatherMapProcessor
): it will contain the code needed to turn the recognized data into data ready to be outputted. Note that the name of the class is not based on the skill id but on what is actually being done.
IntermediateProcessor<StandardResult, SKILL_IDOutput.Data>
(e.g. OpenWeatherMapProcessor implements IntermediateProcessor<StandardResult, WeatherOutput.Data>
). StandardResult
is the input data for the processor, generated by StandardRecognizer
after having understood a user's sentence; SKILL_IDOutput.Data
, from 3.2, is the output data from the processor to feed to the OutputGenerator
.process()
method and put there any code making network requests or calculations, then return data ready to be outputted. For example, the weather skill gets the weather information for the city you asked for.Create a class named SKILL_IDInfo
(e.g. WeatherInfo
) overriding SkillInfo
: it will contain all of the information needed to manage your skill.
super
with the skill id (e.g. "weather"
), a human readable name, a description, an icon (add Android resources for these last three) and finally whether the skill will have some tunable settings (more on this at point 5.4)isAvailable()
method and return whether the skill can be used under the circumstances the user is in (e.g. check whether the recognizer sentences are translated into the user language with isSectionAvailable(SECTION_NAME)
(see 1.1) or check whether context.getNumberParserFormatter() != null
, if your skill uses number parsing and formatting).build()
method. This is the core method of SkillInfo
, as it actually builds a skill. You shall use ChainSkill.Builder()
to achieve that: it will create a skill that recognizes input, then passes the recognized input to the intermediate processor(s) which in turn provides the output generator with something to output.
.recognize(new StandardRecognizer(getSection(SectionsGenerated.SECTION_NAME)))
as the first function. SECTION_NAME
is SKILL_ID
, if you followed the naming scheme from 1.1, e.g. SectionsGenerated.weather
..process(new PROCESSOR_NAMEProcessor())
: add the processor you built at step 4, e.g. new OpenWeatherMapProcessor()
.getPreferenceFragment()
(return null
otherwise). Create a subclass of SKILL_IDInfo
named Preferences
extending PreferenceFragmentCompat
(Android requires you not to use anonymous classes) and override the onCreatePreferences()
as you would do normally. getPreferenceFragment()
should then return new Preferences()
. Make sure the hasPreferences
parameter you use in the constructor (see 5.1) reflects whether there are preferences or not.Under org.stypox.dicio.Skills.SkillHandler
, update the SKILL_INFO_LIST
by adding add(new SKILL_IDInfo())
; this will make your skill visible to Dicio.
skillContext
is provided in many places and can be used to access resources and services, similarly to Andorid's context
.cleanup()
method.SKILL_IDOutput
implement OutputGenerator<StandardResult>
.