Halocode Speech recognition in Python


#1

Hi
I’m trying to use Halocode Speech recognition in Python.
this code
halo.speech_recognition.start(halo.speech_recognition.SERVER_MICROSOFT, halo.speech_recognition.LAN_ENGLISH, 3)
halo.speech_recognition.get_error_message() reports “http client error”.

I also tried to include those line at the beginning, as stated in the docs, but I get the same error.
halo.speech_recognition.set_recognition_url(halo.speech_recognition.SERVER_MICROSOFT, “http://msapi.passport3.makeblock.com/ms/bing_speech/interactive”)
halo.speech_recognition.set_token(halo.speech_recognition.SERVER_MICROSOFT, “ed8xubrmidv”)

Any help welcome :slight_smile:

Jean-David


#2

Hi domisol,

By passing directly from the Halocode. You seem to go through the “Sprite” and the “Cognitive Service” extension

import event, halo, time
halo.speech_recognition.set_recognition_address(url = “{NAVIGATEURL}”)
halo.speech_recognition.set_access_token(token = “{ACCESSTOKEN}”)

@event.start
def on_start():
halo.wifi.start(ssid = ‘SSID???’, password = ‘PW???’, mode = halo.wifi.WLAN_MODE_STA)
while not halo.wifi.is_connected():
pass

halo.led.show_ring('white white black black black white black black black white white white')

@event.button_pressed
def on_button_pressed():
halo.led.show_all(211, 145, 32)
halo.speech_recognition.begin(1, ‘english’)
halo.led.off_all()
if str(halo.speech_recognition.get_result_code()).find(str(‘blue’)) > -1:
halo.led.show_all(4, 164, 255)
else:
if str(halo.speech_recognition.get_result_code()).find(str(‘red’)) > -1:
halo.led.show_all(253, 0, 0)

time.sleep(1)
halo.led.off_all()

In graph


#3

Thank you Crackel for time to have a look at my problem and help me.

However, I gave it a try, and the returned error is now “response timeout”.

To be clear, I’m using python in “https://python.mblock.cc/”, not the typical block system, because my program uses other python funcionalities which have nothing to do with speech recognition.
The tokens {NAVIGATEURL} and {ACCESSTOKEN} are also managed by the python system ?

Thanks

Jean-David


#4

Hi domisol,

I tried https://python.mblock.cc/ but I only saw the Cyberpi device so I left out. I don’t know how you use the Halocode but you seem more advanced than me …

Note: I grant you the python is more powerful with the blocks.


#5

Well, really, it doesn’t matter if you use a halocode, and not a cyberpi, for me it works perfectly. If you need to escape from the block system, and have more freedom with python, give it a try, it’s not complicated.
Thanks again for your help


#6

up :slight_smile:
I hope anyone from tech_support can have a look at this matter.

thanks!


#7

(up) any help from support?