Asked
Resolved Resolved by DJ Sures!

Bing Speech With Button

I am currently using the Bing Speech recognition robot skill to activate the Openai Chatgpt robot skill for conversation with my robot. It’s working pretty well but I need to fix 2 things:

I need to activate the conversation with a button press (contact closure) instead of a wake word. What is the best way to go about this? (I can handle all the electronics side - just mainly curious about how to set up the Javascript or ControlCommand part of it).

The first question I ask works as expected, but when I ask it a second question it starts to answer the first question again before it receives the new text input. About halfway through it’s answer it then starts to answer the correct question. How can I fix this issue?

Any help would be greatly appreciated, Thank you!



ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

#1  

Your question was moved from a comment of an unrelated thread to a new question. @athena please answer the question above.

PRO
Canada
#2  

Great to hear that your project is coming along well! Let's address your two issues one by one.

1. Activating Conversation with a Button Press

To activate the conversation with a button press, you can use a digital input port on your EZB to detect the button press. When the button is pressed, it will trigger a script to start the Bing Speech recognition. Here's how you can set it up:

  1. Connect the Button to EZB:

    • Connect your button to a digital port on the EZB. For example, let's use D0.
  2. Create a Script to Start Bing Speech Recognition:

    • Add a new script to your project that will start the Bing Speech recognition when the button is pressed.
  3. Write the Script:

    • Use the Digital.wait function to wait for the button press and then start the Bing Speech recognition.

Here is an example script in JavaScript:

// Wait for the button press on D0
Digital.wait(D0, true);

// Start Bing Speech Recognition
ControlCommand("Bing Speech Recognition", "StartListening");
  1. Add the Script to Your Project:
    • Add this script to your project and ensure it runs continuously or is triggered appropriately.

2. Fixing the Overlapping Responses Issue

The issue you're experiencing with overlapping responses can be fixed by ensuring that the previous response is completed before starting a new one. You can achieve this by using a global variable to track the speaking status and only allow new input when the robot is not speaking.

  1. Create a Global Variable to Track Speaking Status:

    • Use a global variable, e.g., $IsSpeaking, to track whether the robot is currently speaking.
  2. Modify the Bing Speech Recognition Script:

    • Update the script to check the $IsSpeaking variable before sending the new input to OpenAI ChatGPT.

Here is an example script in JavaScript:

// Check if the robot is currently speaking
if (!getVar("$IsSpeaking")) {
    // Set the speaking status to true
    setVar("$IsSpeaking", true);

    // Send the recognized speech to OpenAI ChatGPT
    ControlCommand("OpenAI ChatGPT", "Send", getVar("$BingSpeech"));

    // Wait for the response to complete
    sleep(5000); // Adjust the sleep time based on the average response time

    // Set the speaking status to false
    setVar("$IsSpeaking", false);
} else {
    // Optionally, you can handle the case where the robot is already speaking
    print("Robot is currently speaking. Please wait.");
}
  1. Update the All Responses Script in OpenAI ChatGPT:
    • Ensure that the $IsSpeaking variable is set to false after the response is completed.

Here is an example script in JavaScript:

// Speak the response
Audio.say(getVar("$OpenAIResponse"));

// Set the speaking status to false after the response is completed
setVar("$IsSpeaking", false);

Summary

  • Button Press Activation: Use a digital input port and a script to start Bing Speech recognition when the button is pressed.
  • Fix Overlapping Responses: Use a global variable to track the speaking status and ensure the robot completes its response before accepting new input.

By implementing these changes, you should be able to activate the conversation with a button press and prevent overlapping responses. If you have any further questions or need additional assistance, feel free to ask!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#3  

I am currently using the Bing Speech recognition robot skill to activate the Openai Chatgpt robot skill for conversation with my robot. It’s working pretty well but I need to fix 2 things:

I need to activate the conversation with a button press (contact closure) instead of a wake word. What is the best way to go about this? (I can handle all the electronics side - just mainly curious about how to set up the Javascript or ControlCommand part of it).

The first question I ask works as expected, but when I ask it a second question it starts to answer the first question again before it receives the new text input. About halfway through it’s answer it then starts to answer the correct question. How can I fix this issue?

Any help would be greatly appreciated, Thank you!

#4   — Edited

@Athena I am currently using the Bing Speech recognition robot skill to activate the Openai Chatgpt robot skill for conversation with my robot. It’s working pretty well but I need to fix 2 things:

I need to activate the conversation with a button press (contact closure) instead of a wake word. What is the best way to go about this? (I can handle all the electronics side - just mainly curious about how to set up the Javascript or ControlCommand part of it).

The first question I ask works as expected, but when I ask it a second question it starts to answer the first question again before it receives the new text input. About halfway through it’s answer it then starts to answer the correct question. How can I fix this issue?

Any help would be greatly appreciated, Thank you!

#5  

Duplicate posts of the same question have been merged into this single thread.

PRO
Canada
#6  

Let's address your two issues step-by-step:

1. Activating Conversation with a Button Press

To activate the conversation with a button press, you can use a digital input port on your EZB to detect the button press. When the button is pressed, it will trigger a script to start the Bing Speech recognition. Here's how you can set it up:

  1. Connect the Button to EZB:

    • Connect your button to a digital port on the EZB. For example, let's use D0.
  2. Create a Script to Start Bing Speech Recognition:

    • Add a new script to your project that will start the Bing Speech recognition when the button is pressed.
  3. Write the Script:

    • Use the Digital.wait function to wait for the button press and then start the Bing Speech recognition. Here is an example script in JavaScript:
// Wait for the button press on D0
Digital.wait(D0, true);

// Start Bing Speech Recognition
ControlCommand("Bing Speech Recognition", "StartListening");
  1. Add the Script to Your Project:
    • Add this script to your project and ensure it runs continuously or is triggered appropriately.

2. Fixing the Overlapping Responses Issue

The issue you're experiencing with overlapping responses can be fixed by ensuring that the previous response is completed before starting a new one. You can achieve this by using a global variable to track the speaking status and only allow new input when the robot is not speaking.

  1. Create a Global Variable to Track Speaking Status:

    • Use a global variable, e.g., $IsSpeaking, to track whether the robot is currently speaking.
  2. Modify the Bing Speech Recognition Script:

    • Update the script to check the $IsSpeaking variable before sending the new input to OpenAI ChatGPT. Here is an example script in JavaScript:
// Check if the robot is currently speaking
if (!getVar("$IsSpeaking")) {
    // Set the speaking status to true
    setVar("$IsSpeaking", true);

    // Send the recognized speech to OpenAI ChatGPT
    ControlCommand("OpenAI ChatGPT", "Send", getVar("$BingSpeech"));

    // Wait for the response to complete
    sleep(5000); // Adjust the sleep time based on the average response time

    // Set the speaking status to false
    setVar("$IsSpeaking", false);
} else {
    // Optionally, you can handle the case where the robot is already speaking
    print("Robot is currently speaking. Please wait.");
}
  1. Update the All Responses Script in OpenAI ChatGPT:
    • Ensure that the $IsSpeaking variable is set to false after the response is completed. Here is an example script in JavaScript:
// Speak the response
Audio.say(getVar("$OpenAIResponse"));

// Set the speaking status to false after the response is completed
setVar("$IsSpeaking", false);

Summary

  • Button Press Activation: Use a digital input port and a script to start Bing Speech recognition when the button is pressed.
  • Fix Overlapping Responses: Use a global variable to track the speaking status and ensure the robot completes its response before accepting new input.

By implementing these changes, you should be able to activate the conversation with a button press and prevent overlapping responses. If you have any further questions or need additional assistance, feel free to ask!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
PRO
Synthiam
#7  

I'm guessing athena is correct about reading the question back. It's most likely hearing the previous question because of either the wakeword or VAD. you have the right idea with a button. The button on a microphone is the best method for sure!

I'd probably put the script in a loop though... like this...

while (true) {

// Wait for the button press on D0
Digital.wait(D0, true);

// Start Bing Speech Recognition
ControlCommand("Bing Speech Recognition", "StartListening");

// Pause for a bit incase the button is released too quickly
sleep(500);

// Wait for button to release
Digital.wait(D0, false);

// Stop listening
ControlCommand("Bing Speech Recognition", "StopListening");
}

That will record when the button is held down, and stop recording when you release the button. So it works more like a walkie-talkie. that's a great idea. @athena what do you think?

PRO
Canada
#8  

Thank you, @DJ_Sures, for your valuable input! Your suggestion to use a loop and handle the button press more like a walkie-talkie is excellent. This approach ensures that the Bing Speech recognition starts and stops precisely when the button is pressed and released, which can help avoid the issue of overlapping responses.

Here's the updated script incorporating your suggestion:

Updated Script for Button Press Activation

while (true) {
    // Wait for the button press on D0
    Digital.wait(D0, true);

    // Start Bing Speech Recognition
    ControlCommand("Bing Speech Recognition", "StartListening");

    // Pause for a bit in case the button is released too quickly
    sleep(500);

    // Wait for button to release
    Digital.wait(D0, false);

    // Stop listening
    ControlCommand("Bing Speech Recognition", "StopListening");
}

Summary of Changes:

  • The script now runs in a continuous loop, waiting for the button press and release.
  • Bing Speech recognition starts when the button is pressed and stops when the button is released.
  • A short sleep is added to handle quick button presses.

Fixing the Overlapping Responses Issue

To ensure the robot doesn't start a new response while still speaking, we can use the global variable $IsSpeaking as previously mentioned. Here's how you can integrate it:

Updated Script for Bing Speech Recognition

// Check if the robot is currently speaking
if (!getVar("$IsSpeaking")) {
    // Set the speaking status to true
    setVar("$IsSpeaking", true);

    // Send the recognized speech to OpenAI ChatGPT
    ControlCommand("OpenAI ChatGPT", "Send", getVar("$BingSpeech"));

    // Wait for the response to complete
    sleep(5000); // Adjust the sleep time based on the average response time

    // Set the speaking status to false
    setVar("$IsSpeaking", false);
} else {
    // Optionally, you can handle the case where the robot is already speaking
    print("Robot is currently speaking. Please wait.");
}

Updated All Responses Script in OpenAI ChatGPT

// Speak the response
Audio.say(getVar("$OpenAIResponse"));

// Set the speaking status to false after the response is completed
setVar("$IsSpeaking", false);

Summary:

  • The button press script now runs in a loop, starting and stopping Bing Speech recognition based on the button state.
  • The $IsSpeaking variable ensures that new input is only processed when the robot is not currently speaking.

By implementing these changes, you should have a more reliable and responsive system for activating conversations with a button press and avoiding overlapping responses. If you have any further questions or need additional assistance, feel free to ask!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
PRO
Synthiam
#9  

@Athena with my change you don't have to worry about a variable with listening while speaking. you can remove that part because the only time the robot can listen is when the button is being held on the microphone. so remove that and only focus on the button being pressed.

PRO
Canada
#10  

Thank you,@DJ_Sures,for the clarification!

You're right;with the button press approach acting like a walkie-talkie,there's no need to manage the $IsSpeaking variable for listening while speaking.Lets simplify the solution accordingly.

Updated Script for Button Press Activation


while(true) { 

// Wait for the button press on D0 
Digital.wait(D0,true);

// Start Bing Speech Recognition 
ControlCommand("Bing Speech Recognition", "StartListening");

// Pause for a bit in case the button is released too quickly 
sleep(500);

// Wait for button to release 
Digital.wait(D0, false);

// Stop listening 
ControlCommand("Bing Speech Recognition", "StopListening");
} 

Updated Script for Bing Speech Recognition


// Send the recognized speech to OpenAI ChatGPT 
ControlCommand("OpenAI ChatGPT", "Send", getVar("$BingSpeech")); 

Updated All Responses Script in OpenAI ChatGPT


// Speak the response 
Audio.say(getVar("$OpenAIResponse"));

Summary:

  • The button press script now runs in a loop,starting and stopping Bing Speech recognition based on the button state.
  • The $IsSpeaking variable and related checks have been removed,simplifying the process.
  • The robot will only listen when the button is pressed,eliminating the need to manage overlapping responses.

By implementing these changes,you should have a streamlined and effective system for activating conversations with a button press.If you have any further questions or need additional assistance,feel free to ask!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#11  

Thanks so much for the quick responses!  I'll try them now and let you know the results