Asked

How To Write The Code To Enable Speech Recognition In Python

Hi,

I have attempted to write a random Python code that includes various stories. Occasionally, the code repeats a story and takes a minute to do so. Meanwhile, the ARC "Speech Recognition" feature pauses to prevent interference with other commands.

Now, I want to implement a voice command to stop the code when the robot is speaking. How can I write the code to enable "Speech Recognition" when speaking?

Thank you in advance!

This is the code as below:

import time import random

def SayWait(text): Audio.Say(text)

Story 1

def story1(): SayWait("long story testing 1")

Story 2

def story2(): SayWait("long story testing 2")

Randomly choose a story

chosen_story = random.choice(["story1", "story2"])

if chosen_story == "story1": story1() print("\n--- Story 1 Ends ---\n") elif chosen_story == "story2": story2() print("\n--- Story 2 Ends ---")


ARC Pro

Upgrade to ARC Pro

Synthiam ARC Pro is a new tool that will help unleash your creativity with programming robots in just seconds!