com.google.mlkit.genai.speechtranslation

Interfaces

SpeechTranslatorResponse

The response from the speech translator.

Classes

SpeechTranslator

Provides an interface for performing on device speech translation.

SpeechTranslatorOptions

Options for SpeechTranslator.

SpeechTranslatorOptions.Builder

Builder for SpeechTranslatorOptions.

SpeechTranslatorRequest

Request for SpeechTranslator.

SpeechTranslatorRequest.Builder

Builder for SpeechTranslatorRequest.

SpeechTranslatorResponse.Audio

Represents a successful audio output result.

SpeechTranslatorResponse.ErrorResponse

Represents an error that occurred during translation.

SpeechTranslatorResponse.Text

Represents a successful text translation result.

TranslationAudio

Represents an audio packet for the speech translator.

Objects

SpeechTranslation

Entry point to get a SpeechTranslator for speech translation.

SpeechTranslatorResponse.CompletedResponse

Represents the completion of the translation session.

Top-level functions summary

SpeechTranslatorOptions
speechTranslatorOptions(
    sourceLocale: Locale,
    targetLocale: Locale,
    init: SpeechTranslatorOptions.Builder.() -> Unit
)

Helper method to construct a SpeechTranslatorOptions in a DSL-like manner.

SpeechTranslatorRequest

Helper method to construct a SpeechTranslatorRequest in a DSL-like manner.

Top-level functions

speechTranslatorOptions

fun speechTranslatorOptions(
    sourceLocale: Locale,
    targetLocale: Locale,
    init: SpeechTranslatorOptions.Builder.() -> Unit = {}
): SpeechTranslatorOptions

Helper method to construct a SpeechTranslatorOptions in a DSL-like manner.

Example usage:

val options = speechTranslatorOptions(sourceLocale, targetLocale) {
executor = myExecutor // Set the [Executor] on which background tasks should be run.
}

speechTranslatorRequest

fun speechTranslatorRequest(
    audioFlow: Flow<TranslationAudio>,
    init: SpeechTranslatorRequest.Builder.() -> Unit = {}
): SpeechTranslatorRequest

Helper method to construct a SpeechTranslatorRequest in a DSL-like manner.

Example usage:

val request = speechTranslatorRequest(audioFlow)