Package com.sun.speech.freetts.audio

Examples of com.sun.speech.freetts.audio.AudioPlayer


        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.fine("=== " +
                                 utterance.getString("input_text"));
        }

        AudioPlayer audioPlayer = utterance.getVoice().getAudioPlayer();

  audioPlayer.setAudioFormat(MBROLA_AUDIO);
  audioPlayer.setVolume(utterance.getVoice().getVolume());

        // The AudioPlayer interface currently does not allow streaming audio.
        // We need to know the total number of samples that will be written
        // before we can start writing them. Therefore, we need to load all
        // audio data for this utterance into RAM.
       
        List audioData = (List) utterance.getObject("mbrolaAudio");
        if (audioData == null) {
            throw new ProcessException
                ("No \"mbrolaAudio\" object is associated with utterance");
        }

        // total number of audio bytes

        int totalSize;
        try {
            totalSize = utterance.getInt("mbrolaAudioLength");
        } catch (NullPointerException npe) {
            totalSize = 0;
        }

        audioPlayer.begin(totalSize);

        for (Iterator it = audioData.iterator(); it.hasNext();) {
            byte[] bytes = (byte[]) it.next();
            if (!audioPlayer.write(bytes)) {
                throw new ProcessException
                    ("Cannot write audio data to audio player");
            }
        }

        if (!audioPlayer.end()) {
            throw new ProcessException("audio player reports problem");
        }
    }
View Full Code Here


     */
    public void processUtterance(Utterance utterance) throws ProcessException {
  LPCResult lpcResult = (LPCResult) utterance.getObject("target_lpcres");
  SampleInfo sampleInfo =
      (SampleInfo) utterance.getObject(SampleInfo.UTT_NAME);
  AudioPlayer audioPlayer = utterance.getVoice().getAudioPlayer();

  audioPlayer.setAudioFormat(getAudioFormat(sampleInfo));
  audioPlayer.setVolume(utterance.getVoice().getVolume());

  if (LOGGER.isLoggable(Level.FINE)) {
      LOGGER.fine("=== " +
    utterance.getString("input_text"));
  }
View Full Code Here

TOP

Related Classes of com.sun.speech.freetts.audio.AudioPlayer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.