playSpeech()

Category:UI Controls

This block uses Microsoft Azure’s Speech Service to read out text in a student’s program in a specific gender and language. It does not translate any text into different languages, but rather will read the text from the first argument as written.

Examples

When the user clicks on the question mark, they are asked for a question.

                            
textLabel("directions", "Click the Question Mark");
image("questionMark", "icon://fa-question");
setProperty("questionMark", "icon-color", "purple");
onEvent("questionMark", "click", function( ) {
  playSpeech("What is your question?", "female", "English");
});



                        

Syntax

playSpeech(text, gender, language);

Parameters

Name Type Required? Description
text String Text to read out loud
gender String Gender of the voice that reads the text out loud
language String 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.

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