Cyborgscode / Personal-Voice-Assistent

Building a fully featured and localized voice assistant for Linux
141 stars 6 forks source link

Setup PVA to french #14

Open didli opened 1 year ago

didli commented 1 year ago

Hi, and thank you for PVA !

I'm a bit confused as to what exactly is needed in order to get PVA works in french. I've installed PVA from the repo (fedora user here).

I have a working mbrola (tested a few voices and pho files). Regarding mbrola, I read this in the tutorial : "(...)don't forget to translate the responses in /etc/pva/conf.d/* ;)" - Can someone please confirm I have to translate these 5 files to french ? 00-test.conf, 01-default.conf, 02-number-deutsch.conf, 21-model-german-small.conf, 22-model-en-us-small.conf

Next, I've downloaded 4 vosk french model files (2 big and 2 small). vosk-model-small-fr-0.22 # this is the one I intended to use vosk-model-fr-0.22 vosk-model-small-fr-pguyot-0.3 vosk-model-fr-0.6-linto-2.2.0 I think I need to unzip the archive I want, rename the folder to "model", remove the link already existing in /usr/share/pva/ (it's linked to the us model for now) and link the new model to /usr/share/pva/ ? - Is that it ?

Thank you for your help !

Cyborgscode commented 1 year ago

To use it in french, you need AFAIK

a) Change this SYMLINK /usr/share/pva/model to your frenchmodeldirectory. b) change all german phrases to french. (no idea if deepl.com will leave the config file intact if you try to mass translate it there in one row ;))) ) (re)start pva c) change all the say-scripts to your prefered voice.

e volia

Pls let me know if you encounter any problem.

didli commented 1 year ago

It seems I was on the right path. I will start translating in a few days and report my experience here.

change all the say-scripts

Glad I asked, i had no idea there were several "say" scripts !

Thank you @Cyborgscode ^^

Cyborgscode commented 1 year ago

how are you doing?

didli commented 1 year ago

Fine, thank you. But this is way too much ... unexpected work (the translation part). I'm using "trans" for now (https://www.makeuseof.com/translate-text-from-one-language-to-another-in-linux/) Initially, I was just checking about the voice assistant app progress in Linux.
So I'm not too sure if I'm going to continue. Thank you for asking though.

Denis4l commented 1 year ago

HI, Can we share the load may be ?.... If you explain me clearly what to do, I will take time to do it.

Cyborgscode commented 1 year ago

It's easy: All you need to to do is..

conf:"lang","fr_FR" conf:"lang_short","fr"

and you should be fine.

I'm pretty sure, it is not that easy on some phrases to correctly place the placeholders, but that is just finetuning.

TO MAKE IT EASIER: you can start PVA manually like this : "env DEBUG=3 start.sh" and watch the logs filling up with aaaaaaaaaaaa looooooot of useful debug infos how pva parses what you said.

Example:

command:"halt|die|klappe","SHUTUP",""

means "Halt die Klappe" a rude way in german to tell one to keep his mouth shut ;) With the above syntax "Klappe die halt" ( makes no sense in german ) would ALSO be valid. This allows to compensate for variations people would use. It basically means: "all of these words in no specific order" but keep an eye on the space, as "die" can be part many other german words as well, but standalone ( spaces before and after ) it's the exact article for the subject "klappe".

command:"REGEXP:^nochmal$","REPEATLASTCOMMAND",""

"nochmal" => "again" and the rest is required, as that word can be used in normal sentences and we don't want to repeat the last command, if it's accidently in a normal sentence. "REGEXP:^exact this pattern$"

command:"ich |möchte|sprechen","MAKEPHONECALL","anrufen|sprechen|möchte|reden|rufe|mit|ich|an|mobil|arbeit|festnetz"

The sentence to match would be: "ich möchte charles sprechen" with the exact position of "sprechen" at the end, as " sprechen " ( watch the spaces here ) is a mid-sentence appearing and should be filtered out, same as the other words that may be used in conjunction with desired base-content of the sentence.

command:"ich |möchte|sehen","PLAYVIDEO","","netflix| auf | in | im "

"ich möchte Rick and Morty sehen" => "i want to watch Rick and Morty"

As you can see here, positions of verbs are different per language and they use more or less words.

"netflix| auf | in | im " -> The 4th argument is a blocker term, means, even if the pattern "ich |möchte|sehen" matches, it shall not be detected if the words "netflix" " auf " " in " " im " are used. That's because we have a Netflix plugin, where you also would say "Ich möchte auf Netflix Rick and Morty sehen" -> "I wanne watch Rick and Morty on Netflix" .

We also have a Cluster plugin, which redirects videoplayback to other devices, so "auf" "in" and "im" are also blocking the "local" videoplayback command and process the command in the correct plugin. "auf" "in" and "im" in common can refer to locations or devices in german.

I strongly suggest to do the easy stuff first, get in touch with the patterns, get used to it and then take on the more complex ones. Trust me here, it's logical and easy if you got it ;)

The most complex commands are used in the user section. Check the /home/username/.config/pva/conf.d/07-usercommands.conf or plugin configs as things get complicated here by directly integrating config options and wildcard patterns to archive very cool things.

To understand what the german text means, besides the literally translated words, there is a section in the readme.md file, which explains each trigger sentence. Many patterns work with ".*" as placeholders, so the parser knows that there is the argument, he shall extract for the command. This can be a number or a name or a list of titles , whatever makes sense in the context of the command.

Feel free to ask for help.

Denis4l commented 1 year ago

@didli have you done some work of translating and implementing french commands since ?

rseward commented 9 months ago

Not directly related to a French translation, but I am playing with an English translation. @Cyborgscode how do you see integrating translations into this project? It would seem to me you want to create configuration specific to a particular language. Maybe in files like:

I am in the middle of translating this for use in English. It has been a fair amount of fun hacking, but can't see a non-programmer taking this on at the moment. Personally my translation effort has been conflated with an effort to make PVA do things I want it to do. So maybe I am doing things a bit more complicated than most users or that you intended?

I like the project. I am a bit skeptical of it being written mostly in Java. I am sure you have your reasons. There is a strong temptation for me to port all of this into a purish python project. But I truly like the structure of the project so far. And I am dusting off my Java coding skills which I haven't used in a while. I do find it annoying to recompile and restart the java component. Is there a convenient way around that? It would be super if there was a restart command that triggers a recompile and than a restart. But honestly that isn't my main complaint about the Java components. I have forgotten how verbose Java is, and I really would like to get back to a more stream lined python coding style. But I think I will continue on for a while and see if the java code grows on me.

I am very interested in understanding the vision for integrating other languages in a way that would be convenient for an average user to select.

I also am interested to see how the plugin system works. I am thinking some of my personal needs could be handled via plugins. It would be really great to see a rich set of PVA plugins that can be optionally integrated into this so that users could easily add functionality from a package manager like thing or from a plugin git repo or something.

Excellent work on this! I look forward to see the project progresses!

Thank you, Rob

Cyborgscode commented 9 months ago

Not directly related to a French translation, but I am playing with an English translation. @Cyborgscode how do you see integrating translations into this project? It would seem to me you want to create configuration specific to a particular language. Maybe in files like:

* german-commands.conf

* french-commands.conf

* english-commands.conf

more or less: yes

I suggest to use "02-default-english.conf"

The leading number is needed to sort the config files , so 01-default will be read first, and all you put in 02-default-english will be overwriting the content of 01-default.

You can do that in your user config directory and copy it later to the /etc/pva/conf.d/ directory, when it's finished. A packager would then create the "german" based main package and put your 02-default-english.conf in an optional package.

Same for the "numbers" package.

I am in the middle of translating this for use in English. It has been a fair amount of fun hacking, but can't see a non-programmer taking this on at the moment. Personally my translation effort has been conflated with an effort to make PVA do things I want it to do. So maybe I am doing things a bit more complicated than most users or that you intended?

If you wanne just use whats build already, nothing more than translating the text phrases and a bit of adjusting the config values to your language of choice is required.

I like the project. I am a bit skeptical of it being written mostly in Java. I am sure you have your reasons. There is a strong

I like Java :DDD and i like to know up front, that parts on my code a wrong, not just when i wanne use them.

temptation for me to port all of this into a purish python project. But I truly like the structure of the project so far. And I am dusting off my Java coding skills which I haven't used in a while. I do find it annoying to recompile and restart the java component. Is there a convenient way around that? It would be super if there was a restart command that triggers a

I'm afraid not, except your are building a plugin. Those a loaded via a selfmade classloader and therefor can be unloaded. If you do so, you need to tell java to forget the class in the class-cache and then you can use a new version.

I have that running for another java project (commercial) and there we just ship the new classes, a process checks the directory for new dated classfiles and reloads them without a restart. It's tricky but working fine

recompile and than a restart. But honestly that isn't my main complaint about the Java components. I have forgotten how verbose Java is, and I really would like to get back to a more stream lined python coding style. But I think I will continue on for a while and see if the java code grows on me.

I am very interested in understanding the vision for integrating other languages in a way that would be convenient for an average user to select.

1) Translate the phrases 2) change config values 3) start adding new functions via the knowledge you learned from 1+2. via config

for 3) i suggest checking the 07-usercommands.conf .

Coding your own plugins should only be necessary, if you need a real programming language, instead of just using a shell script. I had planned to refactor functionality out of the main class into plugins step by step, when i change code there. Get away from the monolithic monster it started out as. Some of this work has already been done, and if parts need changes, it's always an option to refactor them out. Configs should be untouched by this, so users won't notice this, but later we may be able to have alternative plugins for the same task i.e. a different weather plugin.

BTW: as a user you can of course change and delete all in your ~/.config/pva/conf.d/ directory anytime and start from scratch. There is no need to keep auto generated german files hanging around and overwrite them in seperate configs. For /etc it is necessary, otherwise you can't package language specific rpm's and dep's.

IF your translation is working i will place such a package into the PVA repo as a demonstration, so add a nice note about the author in your files ;)

I also am interested to see how the plugin system works. I am thinking some of my personal needs could be handled via plugins. It would be really great to see a rich set of PVA plugins that can be optionally integrated into this so that users could easily add functionality from a package manager like thing or from a plugin git repo or something.

see above. What you wanne know exactly?

An easy plugin to understand is the SpeechGuard. It has a watchdog process running to do time depended work, it has easy commands to handle and simple code , perfect to make a copy start your own plugin.

All you need in addition is to to define the commands required in a config file in your user directory.

Excellent work on this! I look forward to see the project progresses!

Thanks. It was great fun to do it and i have a new feature planned for a lot of Linux EVE Online Gamers .. that will be hilarious :D