Class Cheetah


  • public class Cheetah
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Cheetah.Builder  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String LIBRARY_PATH  
      static java.lang.String MODEL_PATH  
    • Constructor Summary

      Constructors 
      Constructor Description
      Cheetah​(java.lang.String accessKey, java.lang.String libraryPath, java.lang.String modelPath, float endpointDurationSec)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete()
      Releases resources acquired by Cheetah.
      CheetahTranscript flush()
      Processes any remaining audio data and returns its transcription.
      int getFrameLength()
      Getter for required number of audio samples per frame.
      int getSampleRate()
      Getter for required audio sample rate for PCM data.
      java.lang.String getVersion()
      Getter for Cheetah version.
      CheetahTranscript process​(short[] pcm)
      Processes given audio data and returns its transcription.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LIBRARY_PATH

        public static final java.lang.String LIBRARY_PATH
      • MODEL_PATH

        public static final java.lang.String MODEL_PATH
    • Constructor Detail

      • Cheetah

        public Cheetah​(java.lang.String accessKey,
                       java.lang.String libraryPath,
                       java.lang.String modelPath,
                       float endpointDurationSec)
                throws CheetahException
        Constructor.
        Parameters:
        accessKey - AccessKey obtained from Picovoice Console.
        libraryPath - Absolute path to the native Cheetah library.
        modelPath - Absolute path to the file containing model parameters.
        endpointDuration - Duration of endpoint in seconds. A speech endpoint is detected when there is a chunk of audio (with a duration specified herein) after an utterance without any speech in it. Set duration to 0 to disable this. Default is 1 second in the Builder.
        Throws:
        CheetahException - if there is an error while initializing Cheetah.
    • Method Detail

      • delete

        public void delete()
        Releases resources acquired by Cheetah.
      • process

        public CheetahTranscript process​(short[] pcm)
                                  throws CheetahException
        Processes given audio data and returns its transcription.
        Parameters:
        pcm - A frame of audio samples. The number of samples per frame can be attained by calling getFrameLength(). The incoming audio needs to have a sample rate equal to getSampleRate() and be 16-bit linearly-encoded. Furthermore, Cheetah operates on single channel audio only.
        Returns:
        Inferred transcription.
        Throws:
        CheetahException - if there is an error while processing the audio frame.
      • flush

        public CheetahTranscript flush()
                                throws CheetahException
        Processes any remaining audio data and returns its transcription.
        Returns:
        Inferred transcription.
        Throws:
        CheetahException - if there is an error while processing the audio frame.
      • getFrameLength

        public int getFrameLength()
        Getter for required number of audio samples per frame.
        Returns:
        Required number of audio samples per frame.
      • getSampleRate

        public int getSampleRate()
        Getter for required audio sample rate for PCM data.
        Returns:
        Required audio sample rate for PCM data.
      • getVersion

        public java.lang.String getVersion()
        Getter for Cheetah version.
        Returns:
        Cheetah version.