Aneural Brain Code

 












// include the speech recognition library

#include <SpeechRecognition.h>


// create an instance of the speech recognition module

SpeechRecognition speech;


// define the word "hello" as a command

#define CMD_HELLO 0


// define the pin for the speech recognition module

#define SR_PIN 2


void setup() {

  // initialize serial communication

  Serial.begin(9600);

  

  // initialize the speech recognition module

  speech.init(SR_PIN);

  

  // train the module to recognize the word "hello"

  speech.train(CMD_HELLO, "hello");

}


void loop() {

  // check if the module has recognized a word

  if (speech.available()) {

    // get the command number of the recognized word

    int command = speech.getCommand();

    

    // check if the command is "hello"

    if (command == CMD_HELLO) {

      // print "hello" on the serial monitor

      Serial.println("Hello");

    }

  }

}

--------------------------------------------------------

// include the speech recognition library

#include <SpeechRecognition.h>


// create an instance of the speech recognition module

SpeechRecognition speech;


// define the pin for the speech recognition module

#define SR_PIN 2


// define the maximum number of words to recognize

#define MAX_WORDS 10


// define an array of words to recognize

const char* words[MAX_WORDS] = {"hello", "world", "arduino", "bing", "code", "fun", "cool", "yes", "no", "bye"};


// define an array of command numbers for each word

int commands[MAX_WORDS] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};


void setup() {

  // initialize serial communication

  Serial.begin(9600);

  

  // initialize the speech recognition module

  speech.init(SR_PIN);

  

  // train the module to recognize the words in the array

  for (int i = 0; i < MAX_WORDS; i++) {

    speech.train(commands[i], words[i]);

  }

}


void loop() {

  // check if the module has recognized a word

  if (speech.available()) {

    // get the command number of the recognized word

    int command = speech.getCommand();

    

    // find the index of the command in the array

    int index = -1;

    for (int i = 0; i < MAX_WORDS; i++) {

      if (command == commands[i]) {

        index = i;

        break;

      }

    }

    

    // check if the index is valid

    if (index != -1) {

      // print the corresponding word on the serial monitor

      Serial.println(words[index]);

    }

  }

}

-------------------------------------------------------

# Import the libraries
import speech_recognition as sr
from RPLCD import CharLCD

# Initialize the microphone and the recognizer
mic = sr.Microphone()
rec = sr.Recognizer()

# Initialize the LCD display
lcd = CharLCD(cols=16, rows=2, pin_rs=37, pin_e=35, pins_data=[40, 38, 36, 32, 33, 31, 29, 23])

# Loop until the user says "stop"
while True:
    # Listen to the voice input
    print("Say something...")
    with mic as source:
        audio = rec.listen(source)

    # Try to recognize the voice input
    try:
        # Use Google Speech Recognition as an example
        # You can change it to other services if you have an API key
        text = rec.recognize_google(audio)
        print("You said: " + text)

        # Display the text on the LCD
        lcd.clear()
        lcd.write_string(text)

        # Break the loop if the user says "stop"
        if text.lower() == "stop":
            break
    except:
        # Handle the errors
        print("Sorry, I could not understand you.")
        lcd.clear()
        lcd.write_string("Sorry, I could not understand you.")

# Turn off the LCD
lcd.close()

--------------------------------------------
// Import the libraries
#include <ArduinoSound.h>
#include <ArduinoCloudSpeechRecognition.h>

// Initialize the microphone and the recognizer
USBMicrophone mic;
SpeechRecognizer rec;

// Define the API key and the language for the speech recognition service
// You can change it to other services if you have an API key
#define API_KEY "your_google_api_key"
#define LANGUAGE "en-US"

void setup() {
  // Initialize the serial communication
  Serial.begin(9600);

  // Initialize the microphone and the recognizer
  mic.begin();
  rec.begin(mic, API_KEY, LANGUAGE);
}

void loop() {
  // Listen to the voice input
  Serial.println("Say something...");
  rec.listen();

  // Try to recognize the voice input
  if (rec.available()) {
    // Get the text from the recognizer
    String text = rec.readString();

    // Print the text on the serial monitor
    Serial.println("You said: " + text);

    // Stop the loop if the user says "stop"
    if (text == "stop") {
      rec.stop();
    }
  }
}








Intuitive Machines™ Biotronics™ Zoikrons Autognorics™  ELFS™ IM™ 
are original trademarks and logos
solely distributed by 
L.A.W.S.I.N. 

Comments