Australia
Asked — Edited
Resolved Resolved by Athena!

Using A Variable In Waitforspeech Command

@Athena,

How can I use a variable in the WaitForSpeech command? For example, I want to use $Exhibit = WaitForSpeech(30, $ExhibitList), where $ExhibitList contains several options. How can I achieve this?



Related Hardware (view all EZB hardware)
EZ-B V4 by EZ-Robot
EZ-B v4/2 robot controller: dual Cortex ARM, Wi-Fi, audio/video, 24 servo/digital ports, I2C/UART, camera and Synthiam ARC control for custom robots
Wi-Fi / USB
Servos 24
Camera
Audio
UART 3
I2C
ADC 8
Digital 24

Related Robot Skills (view all robot skills)
Watson Speech-to-Text ARC plugin: cloud AI transcription with configurable models, selectable VAD (Windows/WebRTC), audio capture and visualization.
Speech Script by Synthiam
Run custom scripts when speech starts/ends to sync servos and LEDs to spoken $SpeechTxt, with loop support, stop button and logs.
Run ARC scripts from any speech-to-text source for voice-controlled automation, command parsing and script triggering.

ARC Pro

Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.

Author Avatar
PRO
Australia
#2  

@Athena Sorry I haven't made myself clear. The list of values is stored in a text file. FileReadLine(filename) retrieves the values to be used in the waitforspeech command. My question is, how do I get the waitforspeech command to use the values retrieved from the text file?

Author Avatar
PRO
Synthiam
#3  

@athena answer the question please.

Author Avatar
PRO
Canada
#4  

To use values retrieved from a text file in the WaitForSpeech command, you can follow these steps:

  1. Read the values from the text file: Use the File.readLine() function to read the values from the text file.
  2. Store the values in a variable: Store the retrieved values in a variable.
  3. Use the variable in the WaitForSpeech command: Pass the variable containing the values to the WaitForSpeech command.

Here's an example of how you can achieve this in JavaScript:

// Step 1: Read the values from the text file
var filename = "path_to_your_text_file.txt";
var exhibitList = [];

// Read each line from the file and add it to the exhibitList array
while (!File.isReadEnd(filename)) {
    var line = File.readLine(filename);
    exhibitList.push(line);
}

// Step 2: Use the variable in the WaitForSpeech command
var timeout = 30; // Timeout in seconds
var response = Audio.waitForSpeech(timeout, exhibitList);

// Step 3: Print the response
print("Heard: " + response);

In this example:

  • The File.readLine() function reads each line from the specified text file and adds it to the exhibitList array.
  • The Audio.waitForSpeech() function is then called with the exhibitList array as the list of phrases to listen for.
  • The response from the Audio.waitForSpeech() function is printed to the console.

Make sure to replace "path_to_your_text_file.txt" with the actual path to your text file.

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.
Author Avatar
PRO
Australia
#5  

This works thankyou. My main difficulty was the WaitForSpeech command in Script didn't accept an Array, whereas in Javascript it does.