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

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

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

Voice.deallocate介绍

暂无

代码示例

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

public void clear()
{
  Iterator<Entry<String, LinkedList<Voice>>> it =this.voicePool.entrySet().iterator();
  while(it.hasNext())
  {
    Entry<String, LinkedList<Voice>> entry = it.next();
    it.remove();
    for(Voice v: entry.getValue())
    {
      v.deallocate();
    }
    entry.getValue().clear();
  }
  
  
}

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

public void clear()
{
  Iterator<Entry<String, LinkedList<Voice>>> it =this.voicePool.entrySet().iterator();
  while(it.hasNext())
  {
    Entry<String, LinkedList<Voice>> entry = it.next();
    it.remove();
    for(Voice v: entry.getValue())
    {
      v.deallocate();
    }
    entry.getValue().clear();
  }
  
  
}

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

public void clear()
{
  Iterator<Entry<String, LinkedList<Voice>>> it =this.voicePool.entrySet().iterator();
  while(it.hasNext())
  {
    Entry<String, LinkedList<Voice>> entry = it.next();
    it.remove();
    for(Voice v: entry.getValue())
    {
      v.deallocate();
    }
    entry.getValue().clear();
  }
  
  
}

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

public void clear()
{
  Iterator<Entry<String, LinkedList<Voice>>> it =this.voicePool.entrySet().iterator();
  while(it.hasNext())
  {
    Entry<String, LinkedList<Voice>> entry = it.next();
    it.remove();
    for(Voice v: entry.getValue())
    {
      v.deallocate();
    }
    entry.getValue().clear();
  }
  
  
}

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

public void clear()
{
  Iterator<Entry<String, LinkedList<Voice>>> it =this.voicePool.entrySet().iterator();
  while(it.hasNext())
  {
    Entry<String, LinkedList<Voice>> entry = it.next();
    it.remove();
    for(Voice v: entry.getValue())
    {
      v.deallocate();
    }
    entry.getValue().clear();
  }
  
  
}

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

/**
 * Shuts down this TTSSession synthesizer by closing the AudioPlayer and
 * voice.
 */
public void dispose() {
  if (audioPlayer != null)
    audioPlayer.close();
  if (voice != null)
    voice.deallocate();
}

代码示例来源:origin: es.ucm.fdi.grasia.faerie.demos/talkingAgents.out

@Override
  public void run(ContextEvent event) {
    Attribute attribute = event.getSourceAttributeInstance();
    Entity entity = attribute.getEntity();
    Logger.getLogger(this.getClass()).info("<BEHAVIOR> " + oracle + " talking to " + entity.getName());

    VoiceManager voiceManager = VoiceManager.getInstance();
    Voice helloVoice = voiceManager.getVoice(voice);

    helloVoice.allocate();

    String text;
    if ("First Oracle".equals(oracle))
      text = "How you dare to disturb me?";
    else if ("Second Oracle".equals(oracle))
      text = "You are not interesting for me";
    else if ("Third Oracle".equals(oracle))
      text = "You are insignificant";
    else
      text = "Stupid";

    helloVoice.speak("I'm the " + oracle + ". " + text + ", mortal.");
    helloVoice.deallocate();
  }
}

代码示例来源:origin: es.ucm.fdi.grasia.faerie.demos/talkingAgents.out

@Override
  public void run(ContextEvent event) {
    Attribute attribute = event.getSourceAttributeInstance();
    Entity entity = attribute.getEntity();
    Logger.getLogger(this.getClass()).info("<BEHAVIOR> " + oracle + " saying goodbye to " + entity.getName());

    VoiceManager voiceManager = VoiceManager.getInstance();
    Voice helloVoice = voiceManager.getVoice(voice);

    helloVoice.allocate();
    helloVoice.speak("Go!");
    helloVoice.deallocate();
  }
}

代码示例来源:origin: es.ucm.fdi.grasia.faerie.demos/talkingAgents.out

@Override
  public void run(ContextEvent event) {
    Attribute attribute = event.getSourceAttributeInstance();
    Entity entity = attribute.getEntity();
    Logger.getLogger(this.getClass()).info("<BEHAVIOR> " + oracle + " giving welcome to " + entity.getName());

    VoiceManager voiceManager = VoiceManager.getInstance();
    Voice helloVoice = voiceManager.getVoice(voice);

    helloVoice.allocate();
    helloVoice.speak("You, " + entity.getName());
    helloVoice.deallocate();
  }
}

代码示例来源: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;
  }
}

相关文章