 Hello world, it's The Surfing Scratcher here, teacher, surfer, programmer, and on this channel, I help curious learners just like you along on their learning journeys. In this video, we're going to continue with our From Scratch to Python series to get you up and running in a text-based programming language. So far, we've imported a list of lines that include both a word and a sentence where that word is in that sentence. We're splitting these words and sentences based on the colon character into two further lists, a words list and a sentences list. In this tutorial, we're going to get the computer to speak to us using the Google text speech engine. The only thing that I've done different is I've just got our dot character here. So you can go into the sprites and search for dot. You can use anything else you want, but I'm using dot. Okay, let's get stuck into it. Okay, so I've just gone ahead and hidden our lists here. And this is what we need to do. We need to store some user input. We're going to put up a prompt here where a user is going to make their spelling attempt. And we need to repeat this until our list of results. We're going to create a list here is equal to the list of words. The sequence of instructions to prompt the user to spell a word is to first say the words. A dot's going to say the word. Dot is then going to say the word in a sentence. We'll prompt the user to spell that word, and then we're going to check the result. And after all that, we want to show the results to the user. So let's go ahead and create a new list. And we're going to call this list results. I'm just going to make it for this sprite only. That way it's only going to belong to dot. To start, I'm just going to work in a when the green flag is clicked half block, but we'll probably turn this into a custom block down the track. Okay, let's grab out a delete all of list block here. And we're going to delete all of the results because we want to reset them. Next thing we want to do is grab out a repeat and till block. And we want to repeat until the length of our results is equal to the length of the words that we're trying to spell. So we can get an equal to operator here. And then down in your list, we can get the length of, it can be lines as well. It doesn't really matter here because we know that they're 10. And we're going to be counting up. So when the length of words is equal to the length of the results, I'd actually like that around the other way when how length of results is equal to the length of the words. Now the cool thing about using a results list is that currently it's equal to zero. So we can kind of use it as a counting variable as well. Because we're going to go through and we need to extract the words and the sentences here. So we can use the length of the results to iterate through this list. I'll show you what I mean. So if we click here, the length of results is equal to zero. And we know if we get item one of words, well, that is equal to dash. So we can get a plus operator block here and add one to the current length of results. And that's now going to be one. And we can get this block and we can insert it inside the item block here. And if you click it, we're still going to get dash. Now every time that we add something to results, and I'm just going to do that quickly here. So let's just add a thing to results. Now the length of results is one. So we're going to get the length of results and add one to it, which is going to be two now. And we're going to get the second word. So that's how we can use it as a counting variable. I'm just going to go through and delete our results now. Now this block is probably the most important. We can use this block to say the current word. So if we do this, we can get dot to say the current word. I'm not going to be able to see that because I've got all this business up here on the screen, but you can see dot here is now saying dash. Now to get this working for text to speech, we need to go into the extensions. So let's click the extensions. And let's grab the text to speech extension here. So make your projects talk. Great. Now you can go ahead and set different voices and set your languages. Going to drag out this speak block. I'm going to duplicate that code block. And now we're going to speak that word as well. Now if I click these two blocks, now with any luck, and I've set up my output of my speakers to be the way they should be, I'll click this and you should be able to hear dot say dash dash. There we go. Dot just said dash. Okay, we could just get these two code blocks and whack it in here. But we know that this does something specific. So I'm going to go ahead and make a custom block for this. And what this custom block does, it just says the word. So let's just use our custom blocks here to group a set of instructions. We'll connect that up. And now we can just say the word. The last thing I want to do is just give the user a second to wait here. So we're going to display the word for a second. And then we want to move on to say that word in a sentence. That's going to be pretty easy. We can just duplicate this code block. And instead of using our words here, we can use our sentences. Look at how easy that is. If I click this code block, we'll now hear dot say dash in a sentence. And that's exactly what we're looking for. So while we're at it, let's go and make a custom block to wrap up those sets of instructions. We want to say the sentence now. Cool. And let's connect all of that up. Let's drag it out of the way and connect it up. So we say the word and then we say the sentence. I'm just going to make that two seconds because we want to give the user some time there. Now we want to prompt the user to actually spell the word. So to do that, I'm just going to duplicate our code block again. I'm going to get rid of the way block here. And I'm not going to say this anymore. We're going to say something like get ready to spell. And then we want dot to speak the word again because we want the user to hear the word that they need to spell. Then we need to go into our sensing category here and we need to ask and wait. And what we want to ask for is this. How do you spell the word you just heard? Then we wait. So let's just test this out. How do you spell the word you just heard? And then we can go in and we're going to get some input here as an answer. So if we click that boom and over here on the left hand side, we've got an answer reporter block and that will be equal to answer because that was the input that we gave it. Okay. So let's wrap this up in a custom block now and we're asking user. We're asking user to spell the word. Okay. So let's just connect all that up. There we go. I placed that inside of its custom block and we want to ask the user to spell the word after we've said the word and the sentence. The next thing we need to do is we need to check their answer, their input against the word. The way we'll do that is using this answer reporter block. We'll need an equal to operator and we're going to check to see if the answer is equal to the current word that we're trying to spell. So see how we're just repeating this block over and over again here. We're checking to see the current word. Now this isn't going to be case sensitive. So I think an uppercase D for dash will just work with a lowercase D for dash. But if you include a space in answer, then that's also going to be problematic. Okay. So I'm just going to get an if and else block. So if the answer is equal to the current word that we're trying to spell, then I'm just going to say correct. Otherwise it's incorrect. And this is just some feedback for the user. You can go through and add some sounds in here if you wanted to as well. I just went ahead and made a collect and up sound just from the sounds tab here. Last thing we want to do is add our answer to the results list because that's how we're going to increment our list. We're going to add a value to our results here. And the simplest thing you can do is just add the answer directly in, but I'm going to format this a little bit differently to help me out here. I'm just going to be using a few join blocks. I'm just going to duplicate a couple here. It's going to get nice and gnarly very quickly. Okay. And I want to say the original word that we had. So the original word was this one here. And then we need more join blocks. Okay. So this is the current word that we were trying to spell. And then we want the answer. And I'll just duplicate the answer block and pop that in there. And you can see our formatted answer here. So the current word was dash and our answer was answer. So this wouldn't actually be correct. Now we're going to add this into our results. And we're going to attach that to the end of the if else block. The last thing I want to do is wrap this in a custom block. This block is going to be called check result. And we can adjust attach it to the code block there. The last thing that we need to do inside of our repeat until block is we need to check the result after we've asked for the input. And with any luck, that's how it's going to work. Okay. Let's test it out. I'm going to click the green flag. We just heard dash. Should she try to make a dash for the car? Dash. Okay. We just heard the word dash again. So now I'm going to type it into the input. I've just got it all lowercase here and now I'm going to hit enter. Boom. That was correct. Okay. So now I'm going to do an uppercase B A T H and you can see the case doesn't affect it. Okay. So this is a good one to demonstrate. It's something that might be wrong. So I'm going to spell apologize in the American English here with the Z, but we actually wanted it with the S here. So let's hit return or enter and you can see that we are incorrect. Okay. So just quickly, I'm going to create a variable here and I'm going to call it correct and it's going to count the number of correct words that we spell. So whenever we create something, it's always good practice to set it when we initialize. So when the green flag is clicked, let's set our correct to zero and then when we check the result, if we get it correct, then we need to change it by one. So we're going to change correct by one. Great. Now the last thing we're going to do is show a bit of feedback once we've gone through our whole word list here. We're going to add a new item to our results and we want to show the overall results. We'll do that just by connecting a whole heap of join blocks again. So we want to get our results and let's just duplicate that join block when we need a few more. And now we're going to get that variable that we just created. We're going to get our number that were correct. We're going to need another join block and I'm just going to get rid of that correct variable. And now we want to join a forward slash character. I might even just give it a little bit of space on either side. And the last thing we want is the length of lines because that's how many we're trying to spell. Remember that could be words or sentences as well because they're all going to be the same. And that's the thing that we want to add to our results. That's going to show our overall results. Now we can display this on the screen. So if I just tick our results here, we can make this a little bit bigger. So we can see it. We can put it in the center of the screen if we want to do that. And if we want to do that programmatically, then we want to show the list of results. And we want to make sure that when we start this, we hide that same list. Cool. So what I'm going to do now is just quickly go through and play this game. I'll get to the ninth and then we will see it happen just as a bit of a demo. Okay, so I'm just here in the last word. I purposefully spelled apologize wrong again. Last word I need to spell is lunch. I'm going to hit return or enter in a second and hopefully we will see the results shoot up on the screen and we'll see that final result in the results list. And there we go. Let's just make it a little bit bigger so we can see all of that. And you can see down there we've got the results nine out of 10. And the neat thing about doing this is if we right click this list, we can actually export it as well. So then we've got some feedback or we can track how we've been going with our spelling too. So that's just kind of a nice way to export or output the work that we have done. And just to show you what that looks like, we can go results. I might even date this as well. So today's date is August 30. And I can put my results list there. And now you can see it here in my final window. I'm just going to open it. And there you go. We just opened up that text file and we've got an output printed of our results. The last thing I do just back in our sprite here where we split up our lines into words and sentences is on a green flag click. We just want to make sure that we are extracting the words and the sentences from the line. So that way, if we want to import a new list of lines with words and sentences, we're going to get that new list in here. And that's it. That's the project that we're going to use to make a Python project now. I'm also going to have a couple of scratch videos to show how you can use this to create lives in a game. So I'm going to use a game that I built previously. And that'll take a couple of videos. But if you're not interested in that and you want to get straight into Python, then you can go check out the next video in the series, which is going to be asked getting familiar with Python. We're going to install it. And then we're going to replicate the work that we've done here in scratch in Python to learn a little bit about Python. But awesome job. If you've made it this far and I look forward to seeing you in the next video, be it the scratch version or us into Python. I'll see you then.