III.2.6 - Creating a dialogue between two characters

To create a dialogue between characters, we must create more than one sprite, and they have to be visible (shown) and placed in their appropriate positions.

Each of the sprites has to be programmed, that is, you have to create the sequence of phrases that they will say and determine exactly when they will say them.

Normally to program a dialogue, we will follow a structure like this one:

– We place the characters in their positions (“go to”).

– We make them appear (“show”).

– We make them talk and pause following the texts we have prepared (“say” and “wait”).

Synchronizing a text dialogue

All the sprites participating in the dialogue will be acting at the same time (their programs will be running in parallel). To make them work in parallel, all characters must start with the same event block (orange menu), such as the green flag block.

To get the dialog properly synchronized, and to make sure that the sentences of one and the other don’t overlap, we have to use the “wait” instructions properly. If we have two characters and one of them starts talking with the instruction “Say ‘Hello’ for 3 seconds”, the other must wait with the instruction “wait 3 seconds”. And so on. The “say” block is in the look menu, and the “wait” block is in the control menu (yellow).

In the following example we see a small dialogue between Ulysses and Penelope, and how to program it.

Ulysses:

Penelope:

 

Ulysses:

Penelope:

 

Adding text to speech

Scratch has Text to Speech Extension. It has three blocks (“Speak”, “Set voice to”, “Set language to”) and it allows projects which use it to output synthesized speech. The service is provided by Amazon Web Services.

We first have to press the “Add extension” button (blue button in the bottom-left corner). Then choose “Text to Speech Extension”. After that we will have a new menu for blocks, containing the new ones.

There are five voices that can be selected with the “Set voice to” block:

Alto: standard female voice.

Tenor: standard male voice.

Squeak: high-pitched female voice.

Giant: deep male voice.

Kitten: just repeatedly says “meow”.

Supported Languages: Arabic, Chinese (Mandarin), Danish, Dutch, French, German, Hindi, Icelandic, Italian, Japanese, Korean, Norwegian, Polish, Portuguese (Brazilian), Portuguese (European), Romanian, Russian, Spanish (European), Spanish (Latin American), Swedish, Turkish and Welsh.

In the following example, Ulysses says to Penelope the same sentence than in the previous example, but now using text to speech.


Recording our own voices

The Sound Editor in Scratch allows a user to edit and remix sounds. We can import and export sounds and music and edit them. There is also a library with pre-defined sounds.

To do it, we to go “Sounds” tab, then “Choose a sound / Record”, and we will be able to use our microphone (Scratch will ask permission to use it) to record sounds or out own voices.

This is how a recorded sound looks: 

Then we can edit the sound:


And finally, we can use it in our programs: