Class Orca.OrcaStream

  • Enclosing class:
    Orca

    public class Orca.OrcaStream
    extends java.lang.Object
    OrcaStream object that converts a stream of text to a stream of audio.
    • Constructor Summary

      Constructors 
      Constructor Description
      OrcaStream​(long stream)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Releases the resources acquired by the OrcaStream object.
      short[] flush()
      Generates audio for all the buffered text that was added to the OrcaStream object via `OrcaStream.synthesize()`.
      short[] synthesize​(java.lang.String text)
      Adds a chunk of text to the Stream object and generates audio if enough text has been added.
      • Methods inherited from class java.lang.Object

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

      • OrcaStream

        public OrcaStream​(long stream)
    • Method Detail

      • synthesize

        public short[] synthesize​(java.lang.String text)
                           throws OrcaException
        Adds a chunk of text to the Stream object and generates audio if enough text has been added. This function is expected to be called multiple times with consecutive chunks of text from a text stream. The incoming text is buffered as it arrives until there is enough context to convert a chunk of the buffered text into audio. The caller needs to use `OrcaStream.flush()` to generate the audio chunk for the remaining text that has not yet been synthesized.
        Parameters:
        text - A chunk of text from a text input stream, comprised of valid characters. Valid characters can be retrieved by calling `.getValidCharacters()`. Custom pronunciations can be embedded in the text via the syntax `{word|pronunciation}`. They need to be added in a single call to this function. The pronunciation is expressed in ARPAbet format, e.g.: `I {liv|L IH V} in {Sevilla|S EH V IY Y AH}`.
        Returns:
        The generated audio as a sequence of 16-bit linearly-encoded integers, `null` if no audio chunk has been produced.
        Throws:
        OrcaException - if there is an error while synthesizing audio.
      • flush

        public short[] flush()
                      throws OrcaException
        Generates audio for all the buffered text that was added to the OrcaStream object via `OrcaStream.synthesize()`.
        Returns:
        The generated audio as a sequence of 16-bit linearly-encoded integers, `null` if no audio chunk has been produced.
        Throws:
        OrcaException - if there is an error while flushing audio.
      • close

        public void close()
        Releases the resources acquired by the OrcaStream object.