AI (Live Mode)
AI (Live Mode)
With Python APIs, you can connect CyberPi to the Internet and enable it to implement some AI functions, such as recognizing the languages of speeches and reading texts out loud.
In addition, you can use the text-to-speech (TTS) function of CyberPi in combination with the chatbot program of mkckoud to improve the intelligent level of CyberPi in voice chats.
Speech recognition
from time import sleep
import cyberpi
# Note that this interface only available for the Live mode
# To use the speech recognition function in Upload mode, use the following API
# cyberpi.speech.set_recognition_address(url = “http://msapi.passport3.makeblock.com/ms/bing_speech/interactive”)
cyberpi.set_recognition_url()
cyberpi.cloud.setkey(“34d54aef8ede48379c5bf22c19aea159”)
# This section will be automatically configured in later versions.
cyberpi.wifi.connect(“iPhone fftust”, “12345678”)
# Set the account and password to those of the Wi-Fi you can access to
while not cyberpi.wifi.is_connect():
pass
cyberpi.console.clear()
cyberpi.led.on(100, 0, 0)
cyberpi.cloud.listen(“english”, 2)
cyberpi.console.print(cyberpi.cloud.listen_result())
cyberpi.led.on(0, 0, 0)
TTS
from time import sleep
from makeblock import cyberpi
cyberpi.cloud.setkey(“34d54aef8ede48379c5bf22c19aea159”)
# setkey() is used to verify whether you have the permission to access the Makeblock cloud service
cyberpi.wifi.connect(“iPhone fftust”, “12345678”)
# Set the account and password to those of the Wi-Fi you can access to
cyberpi.led.on(0, 0, 0)
while not cyberpi.wifi.is_connect():
pass
cyberpi.led.on(100, 0, 0)
cyberpi.cloud.tts(“english”, “hello”)
Chinese-English translation (more languages will be supported)
from time import sleep
from makeblock import cyberpi
cyberpi.set_recognition_url()
cyberpi.cloud.setkey(“34d54aef8ede48379c5bf22c19aea159”)
cyberpi.wifi.connect(“iPhone fftust”, “12345678”)
# Set the account and password to those of the Wi-Fi you can access to
cyberpi.led.on(0, 0, 0)
while not cyberpi.wifi.is_connect():
pass
cyberpi.led.on(100, 0, 0)
cyberpi.console.print(cyberpi.cloud.translate(“english”, “加油中国”))