Class SpeechRecognitionTranslator

java.lang.Object
ai.djl.modality.audio.translator.SpeechRecognitionTranslator
All Implemented Interfaces:
NoBatchifyTranslator<Audio,String>, PostProcessor<String>, PreProcessor<Audio>, Translator<Audio,String>

public class SpeechRecognitionTranslator extends Object implements NoBatchifyTranslator<Audio,String>
A Translator that post-process the Audio into String to get a text translation of the audio.
  • Constructor Details

    • SpeechRecognitionTranslator

      public SpeechRecognitionTranslator()
  • Method Details

    • processInput

      public NDList processInput(TranslatorContext ctx, Audio input) throws Exception
      Processes the input and converts it to NDList.
      Specified by:
      processInput in interface PreProcessor<Audio>
      Parameters:
      ctx - the toolkit for creating the input NDArray
      input - the input object
      Returns:
      the NDList after pre-processing
      Throws:
      Exception - if an error occurs during processing input
    • processOutput

      public String processOutput(TranslatorContext ctx, NDList list) throws Exception
      Processes the output NDList to the corresponding output object.
      Specified by:
      processOutput in interface PostProcessor<String>
      Parameters:
      ctx - the toolkit used for post-processing
      list - the output NDList after inference, usually immutable in engines like PyTorch. @see Issue 1774
      Returns:
      the output object of expected type
      Throws:
      Exception - if an error occurs during processing output