Class Leopard


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

      Nested Classes 
      Modifier and Type Class Description
      static class  Leopard.Builder  
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete()
      Releases resources acquired by Leopard.
      int getSampleRate()
      Getter for required audio sample rate for PCM data.
      java.lang.String getVersion()
      Getter for Leopard version.
      java.lang.String process​(short[] pcm)
      Processes given audio data and returns its transcription.
      java.lang.String processFile​(java.lang.String path)
      Processes given audio file 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
      • VALID_EXTENSIONS

        public static final java.lang.String[] VALID_EXTENSIONS
    • Constructor Detail

      • Leopard

        public Leopard​(java.lang.String accessKey,
                       java.lang.String libraryPath,
                       java.lang.String modelPath)
                throws LeopardException
        Constructor.
        Parameters:
        accessKey - AccessKey obtained from Picovoice Console.
        libraryPath - Absolute path to the native Leopard library.
        modelPath - Absolute path to the file containing model parameters.
        Throws:
        LeopardException - if there is an error while initializing Leopard.
    • Method Detail

      • delete

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

        public java.lang.String process​(short[] pcm)
                                 throws LeopardException
        Processes given audio data and returns its transcription.
        Parameters:
        pcm - A frame of audio samples. The incoming audio needs to have a sample rate equal to getSampleRate() and be 16-bit linearly-encoded. Furthermore, Leopard operates on single channel audio only.
        Returns:
        Inferred transcription.
        Throws:
        LeopardException - if there is an error while processing the audio frame.
      • processFile

        public java.lang.String processFile​(java.lang.String path)
                                     throws LeopardException
        Processes given audio file and returns its transcription.
        Parameters:
        path - Absolute path to the audio file. The file needs to have a sample rate equal to or greater than `.sample_rate`. The supported formats are: `FLAC`, `MP3`, `Ogg`, `Opus`, `Vorbis`, `WAV`, and `WebM`.
        Returns:
        Inferred transcription.
        Throws:
        LeopardException - if there is an error while processing the audio 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 Leopard version.
        Returns:
        Leopard version.