-
- 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classAsrModule.Companion
-
Method Summary
Modifier and Type Method Description final BooleangetIsValid()final BooleangetIsLoaded()Unitclose()Releases native resources. final Integerload()Force loading the module. final Stringtranscribe(String wavPath, AsrTranscribeConfig config, AsrCallback callback)Transcribe audio from a WAV file. final Stringtranscribe(String wavPath, AsrTranscribeConfig config)Transcribe audio from a WAV file. final Stringtranscribe(String wavPath)Transcribe audio from a WAV file. -
-
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
-
getIsValid
final Boolean getIsValid()
-
getIsLoaded
final Boolean getIsLoaded()
-
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 fileconfig- 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 fileconfig- 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
-
-
-
-