Table of Contents

speechresult()

Function Definition: speechresult()

Parameters

Description

The function reports the last text detected from the speech.

Example

Learn how to code logic for speech recognized control of Mars Rover with this example block code. You will be able to direct your own Mars Rover easily by just speaking commands.

Learn how to code logic for speech-recognized control of Mars Rover with this example block code. You will be able to direct your own Mars Rover easily by just speaking commands.

Introduction

A speech-recognized controlled Mars Rover robot is a robot that can recognize and interpret our speech, and verbal commands, given by a human. The code uses the speech recognition model that will be able to record and analyze your speech given and react accordingly on the Mars Rover.

Speech recognition robots can be used in manufacturing and other industrial settings to control machinery, perform quality control checks, and monitor equipment.

They are also used to help patients with disabilities to communicate with their caregivers, or to provide medication reminders and other health-related information.

Code

sprite=Sprite('Tobi')
import time
rover = MarsRover(4, 1, 7, 2, 6)
quarky = Quarky()
sr = SpeechRecognition()
ts = TexttoSpeech()
sr.analysespeech(4, "en-US")
command = sr.speechresult()
command = command.lower()
if 'forward' in command:
  rover.home()
  rover.setinangle(0)
  quarky.runtimedrobot("F",100,3)
elif 'back' in command:
  rover.home()
  rover.setinangle(0)
  quarky.runtimedrobot("B",100,3)
elif 'right' in command:
  rover.home()
  rover.setinangle(40)
  quarky.runtimedrobot("R",100,3)
elif 'left' in command:
  rover.home()
  rover.setinangle(40)
  quarky.runtimedrobot("L",100,3)

time.sleep(10)
sprite.stopallsounds()

Logic

  1. Firstly, the code initializes the Mars Rover pins and starts recording the microphone of the device to store the audio command of the user.
  2. The code then checks conditions whether the command included the word “Go” or not. You can use customized commands and test for different conditions on your own.
  3. If the first condition stands false, the code again checks for different keywords that are included in the command.
  4. When any condition stands true, the robot will align itself accordingly and move in the direction of the respective command.

Output

Forward-Backward Motions:

Right-Left Motions:

Read More
Learn how to code logic for speech recognized control of Mecanum with this example block code. You will be able to direct your own Mecanum easily by just speaking commands.

Learn how to code logic for speech recognized control of Mecanum with this example block code. You will be able to direct your own Mecanum easily by just speaking commands.

Introduction

A speech recognized controlled Mecanum robot is a robot that can recognize and interpret our speech, verbal commands, given by a human. The code uses the speech recognition model that will be able to record and analyze your speech given and react accordingly on the Mecanum.

Speech recognition robots can be used in manufacturing and other industrial settings to control machinery, perform quality control checks, and monitor equipment.

They are also used to help patients with disabilities to communicate with their caregivers, or to provide medication reminders and other health-related information.

Code

sprite=Sprite('Tobi')
import time
meca=Mecanum(1,2,7,8)
quarky = Quarky()
sr = SpeechRecognition()
ts = TexttoSpeech()
sr.analysespeech(4, "en-US")
command = sr.speechresult()
command = command.lower()
if 'forward' in command:
  meca.runtimedrobot("forward",100,2)
elif 'back' in command:
  meca.runtimedrobot("backward",100,2)
elif 'right' in command:
  meca.runtimedrobot("lateral right",100,2)
elif 'left' in command:
  meca.runtimedrobot("lateral left",100,2)

time.sleep(10)
sprite.stopallsounds()

Logic

  1. Firstly, the code initializes the Mecanum pins and starts recording the microphone of the device to store the audio command of the user.
  2. The code then checks conditions whether the command included the word “Go” or not. You can use customized commands and test for different conditions on your own.
  3. If the first condition stands false, the code again checks for different keywords that are included in the command.
  4. When any condition stands true, the robot will align itself accordingly and move in that direction of the respective command.

Output

Read More
Engage in interactive conversations with the AI assistant powered by ChatGPT and Sprite Tobi.

Introduction

The Chatbox with ChatGPT Extension is a versatile tool that enables developers to integrate AI-driven conversations into their applications. It leverages the power of the ChatGPT model to create interactive and intelligent chat experiences. With this extension, you can build chatbots, virtual assistants, or conversational agents that understand and respond to user inputs naturally.

The code creates a character named “Tobi” and uses speech recognition to understand spoken commands. It then asks a question to the AI assistant (ChatGPT) and displays the response on the screen, converts it into speech, and makes the character “Tobi” speak the response.

Code

sprite = Sprite('Tobi')
gpt = ChatGPT()

speech = TexttoSpeech()

sr = SpeechRecognition()
ts = TexttoSpeech()
sr.analysespeech(4, "en-US")
command = sr.speechresult()
answer = command.lower()

# sprite.input("Provide a valid word")
# answer= str(sprite.answer())


gpt.askOnChatGPT("AIAssistant", answer)
# Ask on chatGPT other OPTION "friendAI" "sarcasticAI"
result=gpt.chatGPTresult()
print(result)
speech.speak(result)

sprite.say(result,5)

Logic

  1. Open PictoBlox and create a new file.
  2. Choose a suitable coding environment for Block-based coding.
  3. We create an instance of  Speech recognition. This class allows us to convert spoken audio into text.
  4. Next, we create an instance of the ChatGPT model called gpt. ChatGPT is a language model that can generate human-like text responses based on the input it receives. 
  5. Recognize speech for 5 seconds using recognize speech for ()s in the () block.
  6. The sprite object has already been initialized.
  7. We analyze the spoken speech for 4 seconds and assume it is in the English language using analysespeech().
  8.  We store the recognized speech as text in the variable command using speechresult().
  9. We convert the recognized speech to lowercase and store it in the variable answer.
  10. We ask the AI model ChatGPT (acting as an AI assistant) a question based on the user’s input stored in the answer.
  11. We retrieve the response from the AI model and store it in the variable result using chatGPTresult().
  12. We display the response on the screen using print(result).
  13.  We convert the response into speech and play it aloud using the speech object using speak().
  14.  The character “Tobi” speaks the response for 5 seconds using say().
  15. Press the Run button to run the code.

Output

I asked ChatGPT for a joke, and it responded with an interesting response.

Read More
All articles loaded
No more articles to load