Class WhisperComponent

java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.asr.whisper.WhisperComponent
All Implemented Interfaces:
ASRInterface

public class WhisperComponent extends DiarcComponent implements ASRInterface
The implementation of an DIARCComponent with the Whisper speech recognizer.
  • Constructor Details

    • WhisperComponent

      public WhisperComponent()
  • Method Details

    • additionalUsageInfo

      protected List<org.apache.commons.cli.Option> additionalUsageInfo()
      Description copied from class: DiarcComponent
      Override this method to define command line options available in sub-class. This should be paired with a parseArgs implementation.
      Overrides:
      additionalUsageInfo in class DiarcComponent
      Returns:
    • parseArgs

      protected void parseArgs(org.apache.commons.cli.CommandLine cmdLine)
      Description copied from class: DiarcComponent
      Override this method to parse command line args in the sub-class. Called directly after construction to pass runtime values that will override default values. This should parse all the options that additionalUsageInfo provides.
      Overrides:
      parseArgs in class DiarcComponent
    • init

      protected void init()
      Description copied from class: DiarcComponent
      Perform any component initialization. This should not be used for setting local fields to default values as was the case in DIARC. This method is called after the constructor, and after parseArgs. Setting default values should be done in field declaration or in the constructor.
      Overrides:
      init in class DiarcComponent
    • shutdownComponent

      public void shutdownComponent()
      Description copied from class: DiarcComponent
      Any component that needs particular shutdown logic needs to override this method and
      Overrides:
      shutdownComponent in class DiarcComponent
    • transcribeSpeech

      public String transcribeSpeech(float[] samples)
      Transcribe audio data in 16kHz, mono F32
      Specified by:
      transcribeSpeech in interface ASRInterface
      Parameters:
      samples - Audio.java data
      Returns:
      transcribed text
    • transcribeAndReportSpeech

      public void transcribeAndReportSpeech(float[] samples)
      Transcribe audio in 16kHz, mono F32 and report to listener component.
      Specified by:
      transcribeAndReportSpeech in interface ASRInterface
      Parameters:
      samples - Audio.java data
    • writeFloatArrayToWav

      public void writeFloatArrayToWav(float[] audioData, String filePath, int sampleRate)
      Create a wav file from audio sample data.
      Parameters:
      audioData - audio data in floating point representation
      filePath - file to save audio to
      sampleRate - sample rate of the audio
    • disableMicrophone

      public void disableMicrophone()
      Specified by:
      disableMicrophone in interface ASRInterface
    • enableMicrophone

      public void enableMicrophone()
      Specified by:
      enableMicrophone in interface ASRInterface