ScratchX Spelling Test

There are some situations in which the experimental ScratchX ‘speak’ block (see previous post) would be useful, and one of those is a spelling test. In a spelling test, you cannot display the word to spell, and so previous spelling tests I’ve made in Scratch have involved recording the sound of me saying every word in the test.

With a ‘speak’ block, you can simply loop through all of the items in a ‘words’ list, speak the word and then ask the user to spell it. You can then use a decision to let the user know if they got the spelling right, and even update a score if they got it right.

Here’s how the code could look:

SpellingCode.pngWordList.png

The tricky part of this code is the code for looping through each item in the ‘words’ list, which is achieved with this code:

repeat.png

This means that the code is repeated 3 times for my list of 3 words. To speak each word in the list in turn, an ‘index’ variable is initially set to 1, which means that the code…

SpellingCode

…will speak the word at position 1 – the first word in the list. Adding 1 to the ‘index’ variable will set it to 2, meaning that next word 2 will be spoken. This continues for each word in the list.

Here’s the spelling test in action [download link]:

From what I can tell, the ScratchX extension makes use of the WebKit Speech Synthesis API. This shows that it’s also possible to create webpages that can speak the phrases given to them. One possible use for this is a screenreader for the partially sighted.

Here’s a sample Trinket showing a speaking webpage. This will work on all WebKit browsers (Chrome, Safari and Opera) [Trinket link].

 

 

 

Advertisements

A Talking ChatBot using ScratchX

I had a great time at the Bett show last week, running a workshop on how to use Scratch to code an interactive talking ChatBot.

The ChatBot asks you questions, and then personalises a conversation with you, based on your responses. This is done using variables (to store information about you) and decisions (so that the ChatBot can decide what to say next).

ChatBot.png

Here’s how to code the beginnings of a ChatBot:

ChatBot code.png

I had a conversation at the workshop, in which someone commented that it’s a shame the ChatBot doesn’t actually speak.

Well with ScratchX, it can! ScratchX is a place to tinker with experimental Scratch extensions that connect with external hardware (such as electronic devices and robotics) and online resources (including web data and web services).

One of these is a text to speech extension, that includes a new ‘speak’ block to speak text that’s given to it. Clicking the ‘Text to Speech’ extension on the ScratchX homepage opens up the Scratch environment with the additional block in the ‘more blocks’ section. The new ‘speak’ block can then be added to the ChatBot’s code, so that it speaks text before  displaying it on the screen.

Here’s how the ChatBot works with the additional ‘speak’ blocks:

There are other extensions available, including ones to track the position of the ISS or to integrate tweets into Scratch projects!

ISS.png