Game Lab Documentation

playSpeech()

Category:Game Lab

This block uses Microsoft Azure’s Speech Service to read out text in a student’s program in a specific gender and language.

Examples

A character saying hello

Click Here to View this Example

//playSpeech Example
var bg = createSprite(200, 200);
bg.setAnimation("background_landscape07_1");
var bird = createSprite(250, 100);
bird.scale = 0.25;
bird.setAnimation("birdside_07_1");
var daniela = createSprite(150, 300);
daniela.setAnimation("green_shirt_wave2_1");
daniela.scale = 0.6;
drawSprites();
playSpeech("Hello! I'm Daniela! Check out this cool bird!", "female", "English");

Syntax

playSpeech(text, gender, language)

Parameters

NameTypeRequired?Description
textString

Text to read out loud

genderString

Gender of the voice that reads the text out loud

languageString

The language that the text is read in. You can use a dropdown menu to select from available languages. If no language is given, it will default to English.

Returns

No return value. Reads the text only.

Tips

  • You can select from a list of languages using a drop-down menu
  • It may take a few seconds for the sound to play, even when other code and animations have loaded. Please be patient!

Found a bug in the documentation? Let us know at support@code.org.