MediaPipeTasksText Framework Reference

LanguageDetector

final class LanguageDetector

Identifies the language of input text using a MediaPipe TensorFlow Lite model.

  • Initializes a detector from an on-disk .tflite model file using default filtering options.

    Declaration

    Swift

    convenience init(modelPath: String) throws

    Parameters

    modelPath

    File-system path to the TensorFlow Lite model asset.

  • Initializes the underlying MediaPipe task graph using options.

    Declaration

    Swift

    init(options: LanguageDetectorOptions) throws

    Parameters

    options

    Model asset and prediction-filtering settings.

  • Infers the most likely languages for text.

    Declaration

    Swift

    final func detect(text: String) throws -> LanguageDetectorResult

    Parameters

    text

    UTF-8 text to analyze.

    Return Value

    Ranked language predictions matching the configured thresholds and filters.