ironicgull68
Posts: 20
Joined: Sun Jan 22, 2017 3:49 pm

Making a raspberry pi A.I.

Mon Jan 23, 2017 1:59 pm

Ok, so i wouldnt call myself a beginner, i code websites and make software, however i have a question...

My project is to create a pi system that can control and open things on my devices, like an all powerful siri or Cortana, etc.

My question is is this even possible, and if so would i just need third party software?

Also, this is supposed to be like a siri, or more so alexa, is there a way to change the coding of alexa, which i already have installed, and change the "wake words"?

Thanks!!

SynAckFin
Posts: 4
Joined: Fri Jan 27, 2017 4:14 pm

Re: Making a raspberry pi A.I.

Fri Jan 27, 2017 4:59 pm

I'm planning to do a similar thing.

As a starter I installed Amazon's Alexa just to understand the pitfalls of talking to a machine.

My current plan is to modify Alexa's wakeWordAgent so that it understands more trigger words and acts accordingly. So, for example, if I say "Alexa" it activates Alexa and if I say "home control" it activates my own system.

For speech to text I'm thinking of Google's Cloud Speech API which looks cheap enough. If it proves to expensive then I'll use CMU Sphinx and train it to my voice.

I'll post details later on how I plan to modify the wakeWordAgent to handle more wake words.

SynAckFin
Posts: 4
Joined: Fri Jan 27, 2017 4:14 pm

Re: Making a raspberry pi A.I.

Mon Jan 30, 2017 10:31 am

Here's how you add more wake words to alexa:

1. Goto https://snowboy.kitt.ai/ and create your wake words.

For the purposes of this I'll assume you are adding 2 code words called Alpha and Beta

2. cd into the wakeWordAgent source directory.

This is usually located in alexa-avs-sample-app/samples/wakeWordAgent/src

3. Copy your newly created wake word files here.

4. Open KittAiSnowboyWakeWordEngine.cpp in an editor


Look for the following code section:

Code: Select all

static const std::string  RESOURCE_FILE  = "../ext/resources/common.res";
static const std::string  MODEL_FILE     = "../ext/resources/alexa.umdl";
static const std::string  SENSITIVITY    = "0.5";
static const float        AUDIO_GAIN     = 1.0;
static const bool         APPLY_FRONTEND = true;
static const int          MICROSECONDS_BETWEEN_SAMPLES = 100000;
and change it to:

Code: Select all

static const std::string  RESOURCE_FILE  = "../ext/resources/common.res";
static const std::string  MODEL_FILE     = "../ext/resources/alexa.umdl,Alpha.pmdl,Beta.pmdl";
static const std::string  SENSITIVITY    = "0.5,0.5,0.5";
static const float        AUDIO_GAIN     = 1.0;
static const bool         APPLY_FRONTEND = true;
static const int          MICROSECONDS_BETWEEN_SAMPLES = 100000;
Only MODEL_FILE and and SENSITIVITY have been changed. There must be a sensitivity value for each wake word. This value is from 0.0 to 1.0. If your wake word isn't getting triggered then increase it and if it is getting false triggers decrease it.
If you remove the alexa.umdl entry and only have pmdl files then set APPLY_FRONTEND to false

5. Find the KittAiSnowboyWakeWordEngine::mainLoop() function

Change

Code: Select all

    if( (!paSamples.empty()) &&
        m_detector->RunDetection(paSamples.data(), paSamples.size()) > 0) {

      log(Logger::INFO, "KittAiSnowboyWakeWordEngine: Wake Word Detected");
      wakeWordDetected();
    }
to

Code: Select all

    if( (!paSamples.empty()) ) {
      int n = m_detector->RunDetection(paSamples.data(), paSamples.size());
      switch(n) {
        case -2:        // Silence
        case -1:        // Error
        case 0:         // No Event
          break;
        case 1:         // Alexa
          log(Logger::INFO, "KittAiSnowboyWakeWordEngine: Alexa Wake Word Detected");
          wakeWordDetected();
          break;
        case 2:         // Alpha
          log(Logger::INFO, "KittAiSnowboyWakeWordEngine: Alpha Wake Word Detected");
          // Do Your stuff here
          break;
        case 3:         // Beta
          log(Logger::INFO, "KittAiSnowboyWakeWordEngine: Beta Wake Word Detected");
          // Do Your stuff here
          break;
        default: break;
      }
    }
This is just a starting point. If you want to access the microphone then you will have to use KittAiSnowboyWakeWordEngine::pause() and KittAiSnowboyWakeWordEngine::resume() to release and re-aquire. You should also change the state to WAKE_WORD_PAUSED so that it doesn't attempt to re-aquire the mic until you are finished with it. The source code seems fairly straight forward so this shouldn't present to much of a problem.

ironicgull68
Posts: 20
Joined: Sun Jan 22, 2017 3:49 pm

Re: Making a raspberry pi A.I.

Wed Feb 01, 2017 1:05 am

ok thanks all, I will give that a try
:D

peterlite
Posts: 720
Joined: Sun Apr 17, 2016 4:00 am

Re: Making a raspberry pi A.I.

Wed Feb 01, 2017 1:32 am

You could decode speech direct on the Pi.
http://cmusphinx.sourceforge.net/2016/0 ... cmusphinx/

It might be slow on a smaller model Pi.
You: "I graduated. Find me a job"
Pi (after a while): "Job found"
Your grandkid: "Too late, Gramps retired"
:D

Return to “Beginners”