Bonjour,
Je suis actuellement en Terminale SSI et dans le cadre de mon projet j'utilise une carte Arduino et plusieurs Shields. J'aimerai faire un système de Synthèse/Reconnaissance Vocale et j'utilise pour ça le EasyVR 3.0 et le Adafruit Wave Shield 1.1. J'ai écrit mes programmes, lorsque je les teste séparément tout fonctionne mais ensemble ça ne fonctionne plus. Il n'y a aucun message d'erreur mais lorsque je l'essaye, la reconnaissance vocale ne reconnait plus aucune commande.
En me renseignant sur Internet, j'ai vu que ça pourrait surement venir d'un problème de partage de pins mais étant relativement novice en la matière je ne sais pas comment m'y prendre...
Du coup est-ce que quelqu'un saurait comment arranger ça ? Et si le problème ne vient pas des pins, pensez-vous pouvoir m'aider également ?
Merci d'avance.
Voici le code "combiné" que j'utilise :
#include "SdReader.h"
#include "FatReader.h"
#include "WaveHC.h"
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "Arduino.h"
#if !defined(SERIAL_PORT_MONITOR)
#error "Arduino version not supported. Please update your IDE to the latest version."
#endif
#if defined(SERIAL_PORT_USBVIRTUAL)
// Shield Jumper on HW (for Leonardo and Due)
#define port SERIAL_PORT_HARDWARE
#define pcSerial SERIAL_PORT_USBVIRTUAL
#else
// Shield Jumper on SW (using pins 12/13 or 8/9 as RX/TX)
#include "SoftwareSerial.h"
SoftwareSerial port(12, 13);
#define pcSerial SERIAL_PORT_MONITOR
#endif
#include "EasyVR.h"
SdReader card;
FatVolume vol;
FatReader root;
FatReader f;
WaveHC wave;
EasyVR easyvr(port);
//Groups and Commands
enum Groups
{
GROUP_0 = 0,
GROUP_1 = 1,
GROUP_2 = 2,
};
enum Group0
{
G0_MAISON = 0,
};
enum Group1
{
G1_PAIN = 0,
};
enum Group2
{
G2_CHEVEUX = 0,
};
int8_t group, idx;
void setup()
{
// setup PC serial port
pcSerial.begin(9600);
// bridge mode?
int mode = easyvr.bridgeRequested(pcSerial);
switch (mode)
{
case EasyVR::BRIDGE_NONE:
// setup EasyVR serial port
port.begin(9600);
// run normally
pcSerial.println(F("---"));
pcSerial.println(F("Bridge not started!"));
break;
case EasyVR::BRIDGE_NORMAL:
// setup EasyVR serial port (low speed)
port.begin(9600);
// soft-connect the two serial ports (PC and EasyVR)
easyvr.bridgeLoop(pcSerial);
// resume normally if aborted
pcSerial.println(F("---"));
pcSerial.println(F("Bridge connection aborted!"));
break;
case EasyVR::BRIDGE_BOOT:
// setup EasyVR serial port (high speed)
port.begin(115200);
// soft-connect the two serial ports (PC and EasyVR)
easyvr.bridgeLoop(pcSerial);
// resume normally if aborted
pcSerial.println(F("---"));
pcSerial.println(F("Bridge connection aborted!"));
break;
}
while (!easyvr.detect())
{
Serial.println("EasyVR not detected!");
delay(1000);
}
easyvr.setPinOutput(EasyVR::IO1, LOW);
Serial.println("EasyVR detected!");
easyvr.setTimeout(5);
easyvr.setLanguage(5);
group = EasyVR::TRIGGER; //<-- start group (customize)
}
void action();
void loop()
{
if (easyvr.getID() < EasyVR::EASYVR3)
easyvr.setPinOutput(EasyVR::IO1, HIGH); // LED on (listening)
Serial.print("Say a command in Group ");
Serial.println(group);
easyvr.recognizeCommand(group);
do
{
// can do some processing while waiting for a spoken command
}
while (!easyvr.hasFinished());
if (easyvr.getID() < EasyVR::EASYVR3)
easyvr.setPinOutput(EasyVR::IO1, LOW); // LED off
idx = easyvr.getWord();
if (idx >= 0)
{
// built-in trigger (ROBOT)
// group = GROUP_X; <-- jump to another group X
return;
}
idx = easyvr.getCommand();
if (idx >= 0)
{
// print debug message
uint8_t train = 0;
char name[32];
Serial.print("Command: ");
Serial.print(idx);
if (easyvr.dumpCommand(group, idx, name, train))
{
Serial.print(" = ");
Serial.println(name);
}
else
Serial.println();
// beep
easyvr.playSound(0, EasyVR::VOL_FULL);
// perform some action
action();
}
else // errors or timeout
{
if (easyvr.isTimeout())
Serial.println("Timed out, try again...");
int16_t err = easyvr.getError();
if (err >= 0)
{
Serial.print("Error ");
Serial.println(err, HEX);
}
}
}
// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) {
// call our helper to find and play this name
playfile(name);
while (wave.isplaying) {
// do nothing while its playing
}
// now its done playing
}
void playfile(char *name) {
// see if the wave object is currently doing something
if (wave.isplaying) {// already playing something, so stop it!
wave.stop(); // stop it
}
// look in the root directory and open the file
if (!f.open(root, name)) {
putstring("Couldn't open file "); Serial.print(name); return;
}
// OK read the file and turn it into a wave object
if (!wave.create(f)) {
putstring_nl("Not a valid WAV"); return;
}
// ok time to play! start playback
wave.play();
}
void action()
{
switch (group)
{
case GROUP_0:
switch (idx)
{
case G0_MAISON:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
Serial.println("Maison");
playcomplete("1.WAV");
group = GROUP_1;
break;
}
break;
case GROUP_1:
switch (idx)
{
case G1_PAIN:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
Serial.println("Boulangerie");
playcomplete("2.WAV");
group = GROUP_2;
break;
}
break;
case GROUP_2:
switch (idx)
{
case G2_CHEVEUX:
// write your action code here
// group = GROUP_X; <-- or jump to another group X for composite commands
Serial.println("Coiffeur");
playcomplete("3.WAV");
group = GROUP_0;
break;
}
break;
}
}