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

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

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

Voice.allocate介绍

暂无

代码示例

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

public void init(Map<String, Integer> voices) {
  for(String voiceName: voices.keySet())
  {
    int voiceCount = voices.get(voiceName);
    LinkedList<Voice> list = new LinkedList<Voice>();
    this.voicePool.put(voiceName, list);
    while(voiceCount>0)
    {
      
      Voice v = voiceManager.getVoice(voiceName);
      v.allocate();
      list.add(v);
      voiceCount--;
    }
  }
  
  
}

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

public void init(Map<String, Integer> voices) {
  for(String voiceName: voices.keySet())
  {
    int voiceCount = voices.get(voiceName);
    LinkedList<Voice> list = new LinkedList<Voice>();
    this.voicePool.put(voiceName, list);
    while(voiceCount>0)
    {
      
      Voice v = voiceManager.getVoice(voiceName);
      v.allocate();
      list.add(v);
      voiceCount--;
    }
  }
  
  
}

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

public void init(Map<String, Integer> voices) {
  for(String voiceName: voices.keySet())
  {
    int voiceCount = voices.get(voiceName);
    LinkedList<Voice> list = new LinkedList<Voice>();
    this.voicePool.put(voiceName, list);
    while(voiceCount>0)
    {
      
      Voice v = voiceManager.getVoice(voiceName);
      v.allocate();
      list.add(v);
      voiceCount--;
    }
  }
  
  
}

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

public Voice allocateVoice(String voiceName)
{
  LinkedList<Voice> voicesList = this.voicePool.get(voiceName);
  if(voicesList == null)
  {
    voicesList = new LinkedList<Voice>();
    this.voicePool.put(voiceName, voicesList);
  }
  
  if(voicesList.size() == 0)
  {
    Voice v = voiceManager.getVoice(voiceName);
    v.allocate();
    return v;
  }else
  {
    return voicesList.removeFirst();
  }
  
  
  
}

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

public void init(Map<String, Integer> voices) {
  for(String voiceName: voices.keySet())
  {
    int voiceCount = voices.get(voiceName);
    LinkedList<Voice> list = new LinkedList<Voice>();
    this.voicePool.put(voiceName, list);
    while(voiceCount>0)
    {
      
      Voice v = voiceManager.getVoice(voiceName);
      v.allocate();
      list.add(v);
      voiceCount--;
    }
  }
  
  
}

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

public void init(Map<String, Integer> voices) {
  for(String voiceName: voices.keySet())
  {
    int voiceCount = voices.get(voiceName);
    LinkedList<Voice> list = new LinkedList<Voice>();
    this.voicePool.put(voiceName, list);
    while(voiceCount>0)
    {
      
      Voice v = voiceManager.getVoice(voiceName);
      v.allocate();
      list.add(v);
      voiceCount--;
    }
  }
  
  
}

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

public Voice allocateVoice(String voiceName)
{
  LinkedList<Voice> voicesList = this.voicePool.get(voiceName);
  if(voicesList == null)
  {
    voicesList = new LinkedList<Voice>();
    this.voicePool.put(voiceName, voicesList);
  }
  
  if(voicesList.size() == 0)
  {
    Voice v = voiceManager.getVoice(voiceName);
    v.allocate();
    return v;
  }else
  {
    return voicesList.removeFirst();
  }
  
  
  
}

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

public Voice allocateVoice(String voiceName)
{
  LinkedList<Voice> voicesList = this.voicePool.get(voiceName);
  if(voicesList == null)
  {
    voicesList = new LinkedList<Voice>();
    this.voicePool.put(voiceName, voicesList);
  }
  
  if(voicesList.size() == 0)
  {
    Voice v = voiceManager.getVoice(voiceName);
    v.allocate();
    return v;
  }else
  {
    return voicesList.removeFirst();
  }
  
  
  
}

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

public Voice allocateVoice(String voiceName)
{
  LinkedList<Voice> voicesList = this.voicePool.get(voiceName);
  if(voicesList == null)
  {
    voicesList = new LinkedList<Voice>();
    this.voicePool.put(voiceName, voicesList);
  }
  
  if(voicesList.size() == 0)
  {
    Voice v = voiceManager.getVoice(voiceName);
    v.allocate();
    return v;
  }else
  {
    return voicesList.removeFirst();
  }
  
  
  
}

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

public Voice allocateVoice(String voiceName)
{
  LinkedList<Voice> voicesList = this.voicePool.get(voiceName);
  if(voicesList == null)
  {
    voicesList = new LinkedList<Voice>();
    this.voicePool.put(voiceName, voicesList);
  }
  
  if(voicesList.size() == 0)
  {
    Voice v = voiceManager.getVoice(voiceName);
    v.allocate();
    return v;
  }else
  {
    return voicesList.removeFirst();
  }
  
  
  
}

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

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

private void init() {
  VoiceManager voiceManager = VoiceManager.getInstance();
  this.voice = voiceManager.getVoice(this.getVoiceName());
  this.voice.allocate();

相关文章