com.sun.speech.freetts.Voice.setAudioPlayer()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中com.sun.speech.freetts.Voice.setAudioPlayer()方法的一些代码示例,展示了Voice.setAudioPlayer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Voice.setAudioPlayer()方法的具体详情如下:
包路径:com.sun.speech.freetts.Voice
类名称:Voice
方法名:setAudioPlayer

Voice.setAudioPlayer介绍

暂无

代码示例

代码示例来源:origin: org.restcomm.media.resources/player

public void releaseVoice(Voice v)
{
  v.setAudioPlayer(null);
  this.voicePool.get(v.getName().toLowerCase()).add(v);
}

代码示例来源:origin: org.restcomm.media.core.resource/player

public void releaseVoice(Voice v)
{
  v.setAudioPlayer(null);
  this.voicePool.get(v.getName().toLowerCase()).add(v);
}

代码示例来源:origin: org.mobicents.media.resources/player

public void releaseVoice(Voice v)
{
  v.setAudioPlayer(null);
  this.voicePool.get(v.getName().toLowerCase()).add(v);
}

代码示例来源:origin: ua.mobius.media.resources/player

public void releaseVoice(Voice v)
{
  v.setAudioPlayer(null);
  this.voicePool.get(v.getName().toLowerCase()).add(v);
}

代码示例来源:origin: org.restcomm.media.core.resource/media-core-resource-player

public void releaseVoice(Voice v)
{
  v.setAudioPlayer(null);
  this.voicePool.get(v.getName().toLowerCase()).add(v);
}

代码示例来源:origin: org.restcomm.media.core.resource/media-core-resource-player

public TtsTrackImpl(URL url, String voiceName,VoicesCache vc) throws IOException {
  this.voiceCache = vc;
  isReady = false;
  URLConnection connection = url.openConnection();
  frameSize = (int) (period * format.getChannels() * format.getSampleSize() * format.getSampleRate() / 8000);
  // creating voice
  //VoiceManager voiceManager = VoiceManager.getInstance();
 //voice = voiceManager.getVoice(voiceName);
  voice = voiceCache.allocateVoice(voiceName);
  //this.voice.allocate();
  // creating speech buffer for writting
  TTSAudioBuffer audioBuffer = new TTSAudioBuffer();
  // assign buffer to speech engine and start generation
  // produced media data will be stored in the audio buffer
  this.voice.setAudioPlayer(audioBuffer);
  this.voice.speak(connection.getInputStream());
  audioBuffer.flip();
}

代码示例来源:origin: org.restcomm.media.core.resource/player

public TtsTrackImpl(URL url, String voiceName,VoicesCache vc) throws IOException {
  this.voiceCache = vc;
  isReady = false;
  URLConnection connection = url.openConnection();
  frameSize = (int) (period * format.getChannels() * format.getSampleSize() * format.getSampleRate() / 8000);
  // creating voice
  //VoiceManager voiceManager = VoiceManager.getInstance();
 //voice = voiceManager.getVoice(voiceName);
  voice = voiceCache.allocateVoice(voiceName);
  //this.voice.allocate();
  // creating speech buffer for writting
  TTSAudioBuffer audioBuffer = new TTSAudioBuffer();
  // assign buffer to speech engine and start generation
  // produced media data will be stored in the audio buffer
  this.voice.setAudioPlayer(audioBuffer);
  this.voice.speak(connection.getInputStream());
  audioBuffer.flip();
}

代码示例来源:origin: org.mobicents.media.resources/player

public TtsTrackImpl(URL url, String voiceName,VoicesCache vc) throws IOException {
  this.voiceCache = vc;
  isReady = false;
  URLConnection connection = url.openConnection();
  frameSize = (int) (period * format.getChannels() * format.getSampleSize() * format.getSampleRate() / 8000);
  // creating voice
  //VoiceManager voiceManager = VoiceManager.getInstance();
 //voice = voiceManager.getVoice(voiceName);
  voice = voiceCache.allocateVoice(voiceName);
  //this.voice.allocate();
  // creating speech buffer for writting
  TTSAudioBuffer audioBuffer = new TTSAudioBuffer();
  // assign buffer to speech engine and start generation
  // produced media data will be stored in the audio buffer
  this.voice.setAudioPlayer(audioBuffer);
  this.voice.speak(connection.getInputStream());
  audioBuffer.flip();
}

代码示例来源:origin: org.restcomm.media.resources/player

public TtsTrackImpl(URL url, String voiceName,VoicesCache vc) throws IOException {
  this.voiceCache = vc;
  isReady = false;
  URLConnection connection = url.openConnection();
  frameSize = (int) (period * format.getChannels() * format.getSampleSize() * format.getSampleRate() / 8000);
  // creating voice
  //VoiceManager voiceManager = VoiceManager.getInstance();
 //voice = voiceManager.getVoice(voiceName);
  voice = voiceCache.allocateVoice(voiceName);
  //this.voice.allocate();
  // creating speech buffer for writting
  TTSAudioBuffer audioBuffer = new TTSAudioBuffer();
  // assign buffer to speech engine and start generation
  // produced media data will be stored in the audio buffer
  this.voice.setAudioPlayer(audioBuffer);
  this.voice.speak(connection.getInputStream());
  audioBuffer.flip();
}

代码示例来源:origin: ua.mobius.media.resources/player

public TtsTrackImpl(URL url, String voiceName,VoicesCache vc) throws IOException {
  this.voiceCache = vc;
  isReady = false;
  URLConnection connection = url.openConnection();
  frameSize = (int) (period * format.getChannels() * format.getSampleSize() * format.getSampleRate() / 8000);
  // creating voice
  //VoiceManager voiceManager = VoiceManager.getInstance();
 //voice = voiceManager.getVoice(voiceName);
  voice = voiceCache.allocateVoice(voiceName);
  //this.voice.allocate();
  // creating speech buffer for writting
  TTSAudioBuffer audioBuffer = new TTSAudioBuffer();
  // assign buffer to speech engine and start generation
  // produced media data will be stored in the audio buffer
  this.voice.setAudioPlayer(audioBuffer);
  this.voice.setVolume(1.0f);
    this.voice.speak(connection.getInputStream());
  audioBuffer.flip();
}

代码示例来源:origin: net.sf.phat/phat-audio

private boolean speak(String text, String path, String file) {
  try {
    System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
    SingleFileAudioPlayer objPlayer = null;
    String voiceName = "kevin16";
    VoiceManager voiceManager = VoiceManager.getInstance();                 
    Voice objVoice = voiceManager.getVoice(voiceName);
    if (objVoice == null) {
      System.err.println("Cannot find a voice named " + voiceName + ".  Please specify a different voice.");
      return false;
    }
    objVoice.allocate();
    objPlayer = new SingleFileAudioPlayer(path + file, Type.WAVE); 
    objPlayer.setAudioFormat(audioFormat);
    objVoice.setAudioPlayer(objPlayer);
    objVoice.speak(text);
    objVoice.deallocate();
    objPlayer.close();
    return true;
  } catch (Exception e) {
    return false;
  }
}

代码示例来源:origin: org.mobicents.resources/tts-ra

this.voice.setAudioPlayer(audioPlayer);

代码示例来源:origin: org.restcomm.media.resources/player

public TtsTrackImpl(String text, String voiceName,VoicesCache vc) {
  this.voiceCache = vc;
  isReady = false;
  // creating voice
  //VoiceManager voiceManager = VoiceManager.getInstance();
  //voice = voiceManager.getVoice(voiceName);
  voice = voiceCache.allocateVoice(voiceName);
  //voice.allocate();
  // creating speech buffer for writting
  TTSAudioBuffer audioBuffer = new TTSAudioBuffer();
  // assign buffer to speech engine and start generation
  // produced media data will be stored in the audio buffer
  voice.setAudioPlayer(audioBuffer);
  voice.speak(text);
  audioBuffer.flip();
  frameSize = (int) (period * format.getChannels() * format.getSampleSize() * format.getSampleRate() / 8000);
}

代码示例来源:origin: org.mobicents.media.resources/player

public TtsTrackImpl(String text, String voiceName,VoicesCache vc) {
  this.voiceCache = vc;
  isReady = false;
  // creating voice
  //VoiceManager voiceManager = VoiceManager.getInstance();
  //voice = voiceManager.getVoice(voiceName);
  voice = voiceCache.allocateVoice(voiceName);
  //voice.allocate();
  // creating speech buffer for writting
  TTSAudioBuffer audioBuffer = new TTSAudioBuffer();
  // assign buffer to speech engine and start generation
  // produced media data will be stored in the audio buffer
  voice.setAudioPlayer(audioBuffer);
  voice.speak(text);
  audioBuffer.flip();
  frameSize = (int) (period * format.getChannels() * format.getSampleSize() * format.getSampleRate() / 8000);
}

代码示例来源:origin: org.restcomm.media.core.resource/media-core-resource-player

public TtsTrackImpl(String text, String voiceName,VoicesCache vc) {
  this.voiceCache = vc;
  isReady = false;
  // creating voice
  //VoiceManager voiceManager = VoiceManager.getInstance();
  //voice = voiceManager.getVoice(voiceName);
  voice = voiceCache.allocateVoice(voiceName);
  //voice.allocate();
  // creating speech buffer for writting
  TTSAudioBuffer audioBuffer = new TTSAudioBuffer();
  // assign buffer to speech engine and start generation
  // produced media data will be stored in the audio buffer
  voice.setAudioPlayer(audioBuffer);
  voice.speak(text);
  audioBuffer.flip();
  frameSize = (int) (period * format.getChannels() * format.getSampleSize() * format.getSampleRate() / 8000);
}

代码示例来源:origin: org.restcomm.media.core.resource/player

public TtsTrackImpl(String text, String voiceName,VoicesCache vc) {
  this.voiceCache = vc;
  isReady = false;
  // creating voice
  //VoiceManager voiceManager = VoiceManager.getInstance();
  //voice = voiceManager.getVoice(voiceName);
  voice = voiceCache.allocateVoice(voiceName);
  //voice.allocate();
  // creating speech buffer for writting
  TTSAudioBuffer audioBuffer = new TTSAudioBuffer();
  // assign buffer to speech engine and start generation
  // produced media data will be stored in the audio buffer
  voice.setAudioPlayer(audioBuffer);
  voice.speak(text);
  audioBuffer.flip();
  frameSize = (int) (period * format.getChannels() * format.getSampleSize() * format.getSampleRate() / 8000);
}

代码示例来源:origin: ua.mobius.media.resources/player

public TtsTrackImpl(String text, String voiceName,VoicesCache vc) {
    this.voiceCache = vc;
    isReady = false;
    frameSize = (int) (period * format.getChannels() * format.getSampleSize() * format.getSampleRate() / 8000);
    // creating voice
    //VoiceManager voiceManager = VoiceManager.getInstance();
    //voice = voiceManager.getVoice(voiceName);
    voice = voiceCache.allocateVoice(voiceName);

    //voice.allocate();
    // creating speech buffer for writting
    TTSAudioBuffer audioBuffer = new TTSAudioBuffer();

    // assign buffer to speech engine and start generation
    // produced media data will be stored in the audio buffer
    voice.setAudioPlayer(audioBuffer);
    voice.setVolume(1.0f);
    voice.speak(text);

    audioBuffer.flip();
//        frameSize = (int) (period * format.getChannels() * format.getSampleSize() * format.getSampleRate() / 8000);

  }

相关文章