mycroft-skills icon indicating copy to clipboard operation
mycroft-skills copied to clipboard

New Skill: CLI-Command-Skill

Open auwsom opened this issue 4 years ago • 5 comments

Moved from here: https://github.com/MycroftAI/mycroft-core/issues/2600

from mycroft import MycroftSkill, intent_file_handler
import subprocess

class SealEyeCommand(MycroftSkill):
    def __init__(self):
        MycroftSkill.__init__(self)

    @intent_file_handler('command.cli.intent')
    def handle_testa(self, message):
        utterance = message.data.get('utterance')
        if not ' '  in utterance:  
            self.speak('please say your command')
            return True
        commandL = utterance.split(' ', 1)
        #self.log.info("commandList: "+str(commandL))
        command = utterance.split(' ', 1)[1]
        #self.log.info("command: "+str(command))
        process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
        output, error = process.communicate()
        output = output.decode('UTF-8')
        self.log.info("Output: "+str(output))
        self.log.info("Error: "+str(error))
        self.speak(str(output))

def create_skill():
    return SealEyeCommand()

auwsom avatar Jun 07 '20 18:06 auwsom

How would I add custom trigger words such as 'CLI' to the speech recognizer? Is there a way to build simple acryonyms or short words from phonemes as in the hotword PocketSphinx formulation?

auwsom avatar Jun 07 '20 19:06 auwsom

Hey auwsom, the speech-to-text we currently use is Google (explanation here) so there's no way for us to change how these are transcribed unfortunately.

The work around as you've found is to see what gets transcribed and include those in your intent handler. This does get confusing in the translate platform when people wonder what you are doing with "seal eyes" but until we can get DeepSpeech up to production grade it's a hard limitation.

In terms of submitting Skills, this may be in another thread already but have you seen the docs section on how to submit Skills to the Marketplace?

If you don't have the mycroft-msk command available, you can manually activate the virtual environment and just run msk

source ~/mycroft-core/.venv/bin/activate
msk submit /opt/mycroft/skills/your-skill

krisgesling avatar Jun 08 '20 00:06 krisgesling

@krisgesling , thanks, that helps.. Im actually using Mimic locally, so I figured there would be a way to customize it. But maybe I shouldnt do that if I plan on using the Android app. It still seems there should be some at least 'hacky' ways to build up from single syllables. Maybe shortening the recognition time (and accuracy) to decrease the pausing between single letters..

Anyway, thanks for the quicky version of how to submit. I expected it to be much more involved.

PS, I mentioned this in another thread, but it would be great to sort the skills in the marketplace by 'popularity'. Maybe on the number of stars in GitHub. This would really help promote useful skills faster and let the undeveloped or old ones stop cluttering the others (which I would worry about when adding too many skills). There was already a suggestion to combine desktop skills into some kind of suite: https://github.com/MycroftAI/mycroft-skills/issues/1343#issuecomment-640286374

auwsom avatar Jun 08 '20 00:06 auwsom

No worries.

To clarify, Mimic is Text-to-speech, not speech-recognition.

Agree on Marketplace. We want to add in some different ways to display, popularity would be a great one, and maybe "desktop" needs to be a category?

krisgesling avatar Jun 08 '20 00:06 krisgesling

Re Mimic: Oh, right, it is. So then the offline local mycroft is using Google's DeepSpeech, interesting. So it just uses PocketSphinx (or Precise) for the hotword detection.. DeepSpeech does work really well, but doesnt PocketSphinx do speech rec too?

In the Marketplace, having the categories selectable in the sidebar like GMail labels would be helpful also.

auwsom avatar Jun 08 '20 18:06 auwsom