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:
The tricky part of this code is the code for looping through each item in the ‘words’ list, which is achieved with this code:
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…
…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].