Git Product home page Git Product logo

cozmo-voice-commands's Introduction

Cozmo voice Commands (CvC)

Issue multiple voice commands to Cozmo, and watch him execute all of them sequentially: highly customizable, you can add new commands with ease. Recognizes English, Italian, French, German, Dutch but it's very easy to add new languages!

IMPORTANT!

Unfortunately Cozmo and Cozmo SDK are no longer supported or updated by their developers so, as time goes by, they will be no longer compatible with newer Python versions and libraries.
Cozmo SDK works well with Python 3.6, so what I sugget is to create a Python virtual environment with that specific version, then let this app run inside it.

I suggest to use Miniconda, because it's easy to specify a custom Python version on the fly.
First create the virtual environment and name it as you like (here I use cvc for simplicity):
conda create -n cvc python=3.6
then activate it:
conda activate cvc
and then you can install CvC package as described below:
pip install --upgrade git+https://github.com/rizal72/Cozmo-Voice-Commands then run it, typing:
cvc

*note: remeber that you will still need portaudio to be installed on your system as described in the installation section below.

Description

You can say "Cozmo, forward 20 THEN right 90", or "Hello Cozmo, my little friend, could you please drive forward for 3 seconds THEN rotate left 90 degrees THEN dance THEN drive back to your charger?", and Cozmo will execute the commands in both cases: the application will always dynamically match the recognized spoken words with the code methods and arguments, it even parses verbs in their different conjugations, and numbers as arguments of the action to perform.

Tested on macOS, Windows and Linux

Two steps installation

Assuming that you've already performed the Cozmo SDK Setup, specific for your platform:

  1. CvC requires portaudio:
  • on MacOS (see Homebrew if you don't know what brew is):
    brew install portaudio

  • on Linux:
    sudo apt-get install flac portaudio19-dev python-all-dev python3-all-dev && pip3 install --user PyAudio

  • on Windows:
    you only need to install git as it is not included by default.

  1. install cvc package:
    pip install --upgrade git+https://github.com/rizal72/Cozmo-Voice-Commands
  • If you are having permission issues (happens mainly on Linux) try:
    pip install --upgrade --user git+https://github.com/rizal72/Cozmo-Voice-Commands

note: to update CvC, repeat step 2.

Usage

  • run command cvc from the Terminal application.
    • Optional arguments:
      --version[-V]: print version and exit
      --no-wait[-N]: enable deprecated continuous listening mode
      --log[-L]: enable verbose logging
  • choose speech recognition language and press enter.
  • press SHIFT when you are ready, then issue your commands by voice (you have 5 seconds to start talking before it Timeouts), not too far from your PC, taking care to include the words "Cozmo" or "Robot" before any command you'll say: "Ok COZMO, my friend, would you enjoy DANCING?"
    You can issue multiple commands at once: use the word "THEN" ("POI" in Italian, "ALORS" in French, "DAARNA" in Dutch, and so on...), to separate them. Right now these commands will be executed in a sequence. I plan to make some of them to be executed in parallel in the near future.
  • A list of supported commands and arguments is provided at runtime.

Customization

From version 0.6 you can now add new languages and commands with ease: inside cvc/languages folder you'll find one .json file for each language (i.e. en.json). To add a new command just duplicate one of the existing commands inside the .json, changing its parameters with the desired ones (be careful to keep the same structure):

  • DO NOT FORGET to change the id number, that decides language order (it's the first parameter).
  • 'action' is the name of the method/function you are going to create in voice_commands.py
  • 'words' are the recognized words
  • 'usage' is a description/usage of your command

then open voice_commands.py and create the new method/function for your command, just copying an existing one, taking care to use the same name you set in the 'action' parameter, inside the .json.
You can even add new words to existing commands, only be careful to not use the same words in different commands.
To add a new language, duplicate one of the included .json language files, using the same naming, and translate its contents. Your new language will be automatically loaded on startup, and a new language menu item automatically generated ;)

Note for Developers:

If you want to just run the App without installing the package, you need to execute ./cvc.py from the root folder, after you have cloned/downloaded the repository content.

Todo next

  • Allow more commands at once, to be executed in parallel, using the word "and".

Please note: Cozmo does not have built-in microphone, so you should talk with your computer ;)

If you want the code, get it here: https://github.com/rizal72/Cozmo-Voice-Commands

cozmo-voice-commands's People

Contributors

dbmtrde avatar ireallydontexist avatar maxkub avatar rizal72 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cozmo-voice-commands's Issues

Colored text in Windows Shell

Hello,

i have been using you Cozmo Voice Commands and I had problems with the collored text when i start the cvc.py under the windows shell. I found out that there is something missing (at least at my PC). I inserted the following two lines to the file "cozmo_voice_commands.py"

import colorama colorama.init()

right after

#!/usr/bin/env python3
'''
Cozmo Voice Commands (CvC)
Author: Riccardo Sallusti - http://riccardosallusti.it
Description: Issue complex voice commands to Cozmo, and watch him execute them.
More informations: https://github.com/rizal72/Cozmo-Voice-Commands
License: GNU
'''
import sys
import os
import asyncio
import operator
import glob
import json

and now it is working. Everything is colored now.
shell after
shell bevor

When I run the "cvc" command I get an error

When I run the "cvc" command, I get the following error

Cozmo-Voice-Commands (CvC) - Version 0.7.0 - Riccardo Sallusti (http://riccardosallusti.it)
2023-04-08 12:33:52,146 cozmo.general INFO App connection established. sdk_version=1.4.10 cozmoclad_version=3.4.0 app_build_version=00003.00004.00000
2023-04-08 12:33:52,150 cozmo.general INFO Found robot id=1
2023-04-08 12:33:52,171 cozmo.general INFO Connected to Android device serial=QBK6R20623003937
2023-04-08 12:33:52,960 cozmo.general INFO Robot id=1 serial=45a22ffc initialized OK

loading languages files...
2023-04-08 12:33:52,991 cozmo.general INFO Shutting down connection
2023-04-08 12:33:52,993 cozmo.general INFO Android serial=QBK6R20623003937 disconnected.
Traceback (most recent call last):
File "C:\Users\14B\AppData\Local\Programs\Python\Python37-32\Scripts\cvc-script.py", line 11, in
load_entry_point('cvc==0.7.0', 'console_scripts', 'cvc')()
File "c:\users\14b\appdata\local\programs\python\python37-32\lib\site-packages\cvc\cozmo_voice_commands.py", line 50, in main
cozmo.run_program(run)
File "C:\Users\14B\AppData\Roaming\Python\Python37\site-packages\cozmo\run.py", line 849, in run_program
connect(wrapper, conn_factory=conn_factory, connector=connector)
File "C:\Users\14B\AppData\Roaming\Python\Python37\site-packages\cozmo\run.py", line 605, in connect
return _connect_sync(f, conn_factory, connector)
File "C:\Users\14B\AppData\Roaming\Python\Python37\site-packages\cozmo\run.py", line 530, in _connect_sync
f(base.SyncProxy(coz_conn))
File "C:\Users\14B\AppData\Roaming\Python\Python37\site-packages\cozmo\run.py", line 835, in wrapper
f(robot)
File "c:\users\14b\appdata\local\programs\python\python37-32\lib\site-packages\cvc\cozmo_voice_commands.py", line 81, in run
load_jsons()
File "c:\users\14b\appdata\local\programs\python\python37-32\lib\site-packages\cvc\cozmo_voice_commands.py", line 110, in load_jsons
languages.append(json.load(json_file))
File "c:\users\14b\appdata\local\programs\python\python37-32\lib\json_init
.py", line 293, in load
return loads(fp.read(),
File "c:\users\14b\appdata\local\programs\python\python37-32\lib\encodings\cp1254.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9e in position 257: character maps to

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.