New Homepage Forums Bug Reports Incompatibility between Mic and Voice Recognizer shields ?

This topic contains 1 reply, has 2 voices, and was last updated by avatar Amr 7 months, 3 weeks ago. This post has been viewed 116 times

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #178777
    avatarlincolnbsouza
    Participant

    Hi !
    I am trying to begin voice recognition from a sound trigger (like saying “OK” loud). I don’t want to push a button or depend on a time loop. So I decided to use the “Mic.getValue()” function and checking if is more than 70. Then my problems begun… please see code below:
    1. The loop works fine if I put “71” in place of “Mic.getvalue()” – this is basically a know example
    2. If I put “Mic.getValue()” as in the code below, the voice recoginition doesn’t works and a “NETWORK ERROR” comes rapidly
    3. If I get back to use “71”, recompile and reload, it continues to get “NETWORK ERROR” until I close 1Sheeld application on mobile, AND restart my mobile phone.. It seems that only closing 1Sheeld application is not enough… some thing seems to go wrong in the mobile phone network connection…
    4. Extra info: this happens using the same good WiFi connection, mobile Samsung S9+, Android 9, 1Sheeld Firmware 1.6, Arduino Nano
    So, is there any incompatibility between Mic and Voice Recognizer shields ? Or there are some hints to make the code below work properly ?
    Thanks !

    #define CUSTOM_SETTINGS
    #define INCLUDE_TERMINAL_SHIELD
    #define INCLUDE_VOICE_RECOGNIZER_SHIELD
    #define INCLUDE_MIC_SHIELD

    #include <OneSheeld.h>

    char commandReceived[300]; // maximum voice command characters are 300

    void setup()
    {
    OneSheeld.begin(); // Começar comunicação com o 1Sheeld
    VoiceRecognition.setOnError(error); // Tratar erros de Voice Recognition
    }
    void loop ()
    {
    if (Mic.getValue() > 70)
    {
    VoiceRecognition.start();
    if (VoiceRecognition.isNewCommandReceived())
    {
    strcpy(commandReceived , VoiceRecognition.getLastCommand());
    Terminal.print(“Command: “);
    Terminal.println(commandReceived);
    }
    /* delay before listening again to process the received command */
    OneSheeld.delay(5000);
    }
    }

    #193274
    avatarAmr
    Keymaster

    Hi,
    Actually, you got it right since both voice recognition shield and mic shield use the same phone hardware resource; the MIC! This makes the conflict so you CAN’T use both shields at the same time.

    Sorry for this but I have forward the issue to the App development team and they will work on it.

    By the way, your code has some issues you should take care of:

    – you are not making the strings compare properly, as you need to use the “!” before the strcmp(commandReceived, VoiceRecognition.getLastCommand()) function and put it inside an if condition like this:
    if (!strcmp(commandReceived, VoiceRecognition.getLastCommand()))

    – the commandReceived variable hasn’t been initialized yet so it will hold garbage characters and the code will not know what you are comparing with!

    – VoiceRecognition.setOnError(error); makes an error so I guess you deleted the “error()” function before you upload the code here.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.