# RecognitionPart.Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/speech/RecognitionPart.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                   ||
| ↳ | [android.speech.RecognitionPart.Builder](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#) |

A builder for[RecognitionPart](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart)

## Summary

|                                                                                                                Public constructors                                                                                                                 ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#Builder(kotlin.String))`(`rawText:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Creates a new Builder. |

|                                                                                                                                                                                                                                                                                                                        Public methods                                                                                                                                                                                                                                                                                                                        ||
|-------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [RecognitionPart](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart)                  | [build](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#build())`()` Builds the instance.                                                                                                                                                                                                                                                                                                                                                                                                           |
| [RecognitionPart.Builder](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#) | [setConfidenceLevel](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#setConfidenceLevel(kotlin.Int))`(`value:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` The level of confidence for this part if requested with[RecognizerIntent.EXTRA_REQUEST_WORD_CONFIDENCE](https://developer.android.com/reference/kotlin/android/speech/RecognizerIntent#EXTRA_REQUEST_WORD_CONFIDENCE:kotlin.String).                                                                  |
| [RecognitionPart.Builder](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#) | [setFormattedText](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#setFormattedText(kotlin.String))`(`value:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` The formatted text version of the recognized part of the result.                                                                                                                                                                                                                                 |
| [RecognitionPart.Builder](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#) | [setRawText](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#setRawText(kotlin.String))`(`value:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` The`non-null`raw text version of the recognized part of the result.                                                                                                                                                                                                                                          |
| [RecognitionPart.Builder](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#) | [setTimestampMillis](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#setTimestampMillis(kotlin.Long))`(`value:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Non-negative offset of the beginning of this part from the start of the recognition session in milliseconds if requested with[RecognizerIntent.EXTRA_REQUEST_WORD_TIMING](https://developer.android.com/reference/kotlin/android/speech/RecognizerIntent#EXTRA_REQUEST_WORD_TIMING:kotlin.String). |

## Public constructors

### Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(rawText: String)
```

Creates a new Builder.

|                                                                           Parameters                                                                            ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `rawText` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):The`non-null`raw text version of the recognized part of the result. |

## Public methods

### build

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): RecognitionPart
```

Builds the instance. This builder should not be touched after calling this!

|                                                            Return                                                             ||
|--------------------------------------------------------------------------------------------------|-----------------------------|
| [RecognitionPart](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart) | This value cannot be`null`. |

### setConfidenceLevel

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setConfidenceLevel(value: Int): RecognitionPart.Builder
```

The level of confidence for this part if requested with[RecognizerIntent.EXTRA_REQUEST_WORD_CONFIDENCE](https://developer.android.com/reference/kotlin/android/speech/RecognizerIntent#EXTRA_REQUEST_WORD_CONFIDENCE:kotlin.String).

Otherwise, this should equal[CONFIDENCE_LEVEL_UNKNOWN](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart#CONFIDENCE_LEVEL_UNKNOWN:kotlin.Int).

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `value` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.speech.RecognitionPart#CONFIDENCE_LEVEL_UNKNOWN](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart#CONFIDENCE_LEVEL_UNKNOWN:kotlin.Int),[android.speech.RecognitionPart#CONFIDENCE_LEVEL_LOW](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart#CONFIDENCE_LEVEL_LOW:kotlin.Int),[android.speech.RecognitionPart#CONFIDENCE_LEVEL_MEDIUM_LOW](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart#CONFIDENCE_LEVEL_MEDIUM_LOW:kotlin.Int),[android.speech.RecognitionPart#CONFIDENCE_LEVEL_MEDIUM](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart#CONFIDENCE_LEVEL_MEDIUM:kotlin.Int),[android.speech.RecognitionPart#CONFIDENCE_LEVEL_MEDIUM_HIGH](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart#CONFIDENCE_LEVEL_MEDIUM_HIGH:kotlin.Int), or[android.speech.RecognitionPart#CONFIDENCE_LEVEL_HIGH](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart#CONFIDENCE_LEVEL_HIGH:kotlin.Int) |

|                                                                     Return                                                                     ||
|-------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [RecognitionPart.Builder](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#) | This value cannot be`null`. |

### setFormattedText

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setFormattedText(value: String): RecognitionPart.Builder
```

The formatted text version of the recognized part of the result. If formatting is enabled with[RecognizerIntent.EXTRA_ENABLE_FORMATTING](https://developer.android.com/reference/kotlin/android/speech/RecognizerIntent#EXTRA_ENABLE_FORMATTING:kotlin.String), it has a`non-null`value.

Otherwise, it should be`null`by default.

|                                                      Parameters                                                       ||
|---------|--------------------------------------------------------------------------------------------------------------|
| `value` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |

### setRawText

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setRawText(value: String): RecognitionPart.Builder
```

The`non-null`raw text version of the recognized part of the result.

|                                                      Parameters                                                       ||
|---------|--------------------------------------------------------------------------------------------------------------|
| `value` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |

### setTimestampMillis

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setTimestampMillis(value: Long): RecognitionPart.Builder
```

Non-negative offset of the beginning of this part from the start of the recognition session in milliseconds if requested with[RecognizerIntent.EXTRA_REQUEST_WORD_TIMING](https://developer.android.com/reference/kotlin/android/speech/RecognizerIntent#EXTRA_REQUEST_WORD_TIMING:kotlin.String).

Otherwise, this should equal 0.

|                                                                     Return                                                                     ||
|-------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [RecognitionPart.Builder](https://developer.android.com/reference/kotlin/android/speech/RecognitionPart.Builder#) | This value cannot be`null`. |