Package 

Class AsrModule

  • All Implemented Interfaces:
    java.io.Closeable , java.lang.AutoCloseable

    
    public final class AsrModule
     implements Closeable
                        

    AsrModule is a wrapper around the ExecuTorch ASR Runner. It provides a simple interface to transcribe audio from WAV files using speech recognition models like Whisper.

    The module loads a WAV file, optionally preprocesses it using a preprocessor module (e.g., for mel-spectrogram extraction), and then runs the ASR model to generate transcriptions.

    Warning: These APIs are experimental and subject to change without notice

    • Constructor Detail

      • AsrModule

        AsrModule(String modelPath, String tokenizerPath, String dataPath, String preprocessorPath)
        Parameters:
        modelPath - Path to the ExecuTorch model file (.pte).
        tokenizerPath - Path to the tokenizer directory containing tokenizer.
        dataPath - Optional path to additional data file (e.g.
        preprocessorPath - Optional path to preprocessor .pte for converting raw audio to features.
    • Method Detail

      • close

         Unit close()

        Releases native resources. Call this when done with the module.

      • load

         final Integer load()

        Force loading the module. Otherwise the model is loaded during first transcribe() call.

      • transcribe

        @JvmOverloads() final String transcribe(String wavPath, AsrTranscribeConfig config, AsrCallback callback)

        Transcribe audio from a WAV file.

        This is a blocking call that returns the complete transcription.

        Parameters:
        wavPath - Path to the WAV audio file
        config - Configuration for transcription (null uses default configuration)
        callback - Optional callback to receive tokens as they are generated (can be null)
      • transcribe

        @JvmOverloads() final String transcribe(String wavPath, AsrTranscribeConfig config)

        Transcribe audio from a WAV file.

        This is a blocking call that returns the complete transcription.

        Parameters:
        wavPath - Path to the WAV audio file
        config - Configuration for transcription (null uses default configuration)
      • transcribe

        @JvmOverloads() final String transcribe(String wavPath)

        Transcribe audio from a WAV file.

        This is a blocking call that returns the complete transcription.

        Parameters:
        wavPath - Path to the WAV audio file