コード例 #1
0
ファイル: Snitcher.java プロジェクト: supremefist/Snitcher
 public static void listAllVoices() {
   System.out.println();
   System.out.println("All voices available:");
   VoiceManager voiceManager = VoiceManager.getInstance();
   Voice[] voices = voiceManager.getVoices();
   for (int i = 0; i < voices.length; i++) {
     System.out.println("    " + voices[i].getName() + " (" + voices[i].getDomain() + " domain)");
   }
 }
コード例 #2
0
  @SuppressWarnings("unused")
  public static int speak(
      String msg, Double rate, Double pitch, Double range, Double shift, Double volume) {
    System.setProperty(
        "freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
    VoiceManager voiceManager = VoiceManager.getInstance();
    com.sun.speech.freetts.Voice voice = voiceManager.getVoice("kevin16");

    System.out.println("Rate " + voice.getRate());
    System.out.println("Pitch hertz " + voice.getPitch());
    System.out.println("PitchRange " + voice.getPitchRange());
    System.out.println("PitchShift " + voice.getPitchShift());
    System.out.println("Volume " + voice.getVolume());
    if (voice != null) {
      voice.setRate(rate.floatValue());
      voice.setPitch(pitch.floatValue());
      voice.setPitchRange(range.floatValue());
      voice.setPitchShift(shift.floatValue());
      voice.setVolume(volume.floatValue());
      voice.allocate();
      voice.speak(msg);
      voice.deallocate();
    } else {
      System.out.println("All voices available:");
      com.sun.speech.freetts.Voice[] voices = voiceManager.getVoices();
      for (int i = 0; i < voices.length; i++) {
        System.out.println(
            "    " + voices[i].getName() + " (" + voices[i].getDomain() + " domain)");
      }
    }

    // WordNumSyls feature =
    // (WordNumSyls)voice.getFeatureProcessor("word_numsyls");
    // if(feature!=null)
    // try {
    //
    // System.out.println("Syllables# = "+feature.process(null));
    // } catch (ProcessException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // }
    //
    return 0;
  }
コード例 #3
0
ファイル: IVRNews.java プロジェクト: parag/kwegg
  private void constructVoice() {
    /* The VoiceManager manages all the voices for FreeTTS.
     */
    VoiceManager voiceManager = VoiceManager.getInstance();
    String voiceName = "mbrola_us1";
    Voice[] vs = voiceManager.getVoices();
    for (Voice v : vs) {
      System.out.println(v.getName());
    }
    voice = voiceManager.getVoice(voiceName);

    if (voice == null) {
      System.err.println(
          "Cannot find a voice named " + voiceName + ".  Please specify a different voice.");
      System.exit(1);
    }

    /* Allocates the resources for the voice.
     */
    voice.allocate();
  }
 public void listAllVoices() {
   VoiceManager voiceManager = VoiceManager.getInstance();
   Voice[] voices = voiceManager.getVoices();
 }