corus87 / kodi-neuron

1 stars 0 forks source link

Handling of repeat_action for input_action #1

Closed ghost closed 7 years ago

ghost commented 7 years ago

How does the mapping of STT recognized word like "seven" for a repeat action translate to the number "7" which is interpreted in the kodi.py code

 if repeat is not None:
            for _ in " "*int(self.repeat_action): self.kodi.Input.ExecuteAction({"action": self.input_action})
        else:    
self.kodi.Input.ExecuteAction({"action": self.input_action})

and how to handle this in another language like French, German ... We need a kind of dictionary for number 0, ..., 9 here.

corus87 commented 7 years ago

Im using google STT and German language and google has no problems to understand integers. But I didn't thought about other STT´s... Anyway I tried to make a dictionary with the file_template but it wasn't working. I think its because for the TTS only. I think it should be possible to make a Jinja2 template to get a Dictionary, but in the moment I have no clue how to do it. I just started with programming a few months ago, so if you have a idea I would appreciate any help :)

ghost commented 7 years ago

I don't have an idea yet but i know someone who should know:-) I will ask him to help out or point us to the right direction.

Sispheor commented 7 years ago

Numbers are not handled by Kalliope. Because we cannot translate it from the source language into an integer. That's it. You need to find another way to do it. Sorry guys.

ghost commented 7 years ago

It looks like one can easily handle it in your python code using a dictionary with key-value pairs for 'one': 1 and so on as a workaround.

I am not familiar with jinja2 but as a first step you can consider to support STT engines which do not deliver back the number as a string like '1' but 'one' back. I don't know how other cloud STT != google behave here?

Sispheor commented 7 years ago

Yes, but it will work only for English language. It's not really the concept idea of Kalliope.

ghost commented 7 years ago

Yes, that's true.

We need to find a way to map foreign language numbers like 'eins' in German if this language is used outside the kodi Python code to the English key word 'one' which has the value 1. But that seems to be bad practice to replace keys in a Python dictionary i guess.

corus87 commented 7 years ago

@1account This was what I had in mind, a simple dictionary like "five": 5 in template file which would be a parameter. In this file the user could define the name of the numbers. The next step would be if the repeat action is called, with a key"five", we looking for a match in the file and use the value 5 to process with it to repeat our action.

@Sispheor I thought I could use the same method like the Systemdate neuron and his file_template, but as I understand, the file_template is not handled by the neuron itself, its handled by the NeuronModule and from their it goes to the Utils where the file_template gets analyst for the TTS ? I dont see why it should not work with the right method in the kodi neuron?

Sispheor commented 7 years ago

File template is used in output. Here you need a convertion inside the neuron.

ghost commented 7 years ago

Did a quick check that one can write an own dictionary file for phonemes like the below for German

1 Q AY N S
2 TS V AY
3 D RR AY
...

which is correctly recognized by pocketsphinx and opened Request: Add variable for "pronounciation-dictionary.dict" to the list of parameters of recognize_sphinx for Pythons speech recognition module.

Once this gets implemented within the speech recognition module i would appreciate if @Sispheor can add this option to Kalliope so that we can overwrite dictionary files in neurons which would solve our 'numbers issue' in a satisfying way.

ghost commented 7 years ago

I don't think that this conversion can be done universally for all languages as most of them have their specific rules regarding counting, especially those French guys;-)

You can find some code for English conversion here

https://github.com/ghewgill/text2num/blob/master/text2num.py

I modified it for handling German integer numbers less than 100 which is sufficient for kodi but i will map those numbers within the dictionary directly to 0, 1, 2, ... and will ask Guenter, the author of the German acoustic model, what he thinks of this modification as most TTS handle integers well.

@corus87 You can close this if you want.