# Speech Blocks

## Overview

Speech blocks allow you to incorporate spoken language or text-to-speech functionality into your app. You can use these blocks to make your app speak specific messages, responses, or user inputs aloud, enhancing accessibility and interaction for users who prefer or require auditory cues. By utilizing speech blocks, you enable your app to communicate verbally with users, providing information or instructions in a spoken format.

## Text-to-Speech

The "say \[text] in \[language]" block reads a piece of text aloud in a specified language.

**Regular Block**

<div align="left"><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MJWkxfX4gze6PVxiJfU%2F-MJWlJ6DAw7qvBMEARB8%2Fimage.png?alt=media&#x26;token=851a8cb0-8b76-4405-acff-7f304a915196" alt="" width="375"></div>

**Advanced Block**

To access the advanced version of a block:

1. Drag and drop the regular block into your workspace.
2. Right-click on the block.
3. Select **Show advanced block**.

#### Inputs

| Input    | Description                                                                                                                                                                                                                        |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| text     | Text to generate speech.                                                                                                                                                                                                           |
| language | A parameter that specifies the preferred language for the generated speech. Please refer to [IETF BCP 47](https://en.wikipedia.org/wiki/IETF_language_tag) for the valid codes.                                                    |
| pitch    | A parameter that defines the baseline pitch the speech synthesizer uses when speaking the utterance. Set this property to a value within the range of `0.5` for lower pitch to `2.0` for higher pitch. The default value is `1.0`. |
| rate     | A parameter that defines the rate the speech synthesizer uses when speaking the utterance. Lower values correspond to slower speech, and higher values correspond to faster speech.                                                |

#### **Outputs**

| Output | Description                                                                                      |
| ------ | ------------------------------------------------------------------------------------------------ |
| error  | If an error is encountered while making the API call, the error block returns the error message. |

**Note**

* The sound plays automatically by the "say \[text] in \[language]" block. It is not possible to pause or stop the sound.

### Video Tutorial

#### How to Create a Text-to-Speech App in Thunkable

Incorporating text-to-speech functionality brings written words to life by converting them into spoken audio. In this tutorial, we’ll add text-to-speech functionality to a translation app.

{% embed url="<https://youtu.be/5eGLS2ZPVsA>" %}

**Template app:**&#x20;

1. Click: [https://x.](https://x.thunkable.com/projectPage/64e4f871bd8fd77d3628f694)
2. [thunkable.com/projectPage/64e4f871bd8fd77d3628f694](https://x.thunkable.com/projectPage/64e4f871bd8fd77d3628f694)&#x20;
3. Click **Copy Project** in the upper right.

## Translation

The "translate" block translates text from one language to another. It is powered by Google Translate.&#x20;

<div align="left"><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MJWkxfX4gze6PVxiJfU%2F-MJWlPVMbVsz8b73sm_f%2Fimage.png?alt=media&#x26;token=bc169415-3e69-4084-90c1-cd34542e01b0" alt="" width="563"></div>

### Video Tutorial

#### How to Build a Translation App in Thunkable

In this tutorial, we’ll build a translation app that translates the user’s text input from one language to another.

{% embed url="<https://youtu.be/E2drz7YSNTY>" %}

## Recognize Speech

The "recognize speech" block recognizes the language of a piece of audio. It returns a text transcription of the speech.

<div align="left"><img src="https://1223006790-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MJWkxfX4gze6PVxiJfU%2F-MJWlN56a4-94ZA3MBOG%2Fimage.png?alt=media&#x26;token=e03ccb62-3123-4cdb-b040-9a61692e7471" alt=""></div>
