public void listenHeadLines(FastFeed feed) { allNews = NewsTableHandler.getInstance().getAllNewsForFeed(feed, 0, 10); int i = 0; voice.speak("Press one of the following options to listen to news."); for (CloudNews news : allNews) { voice.speak(i + " for. " + news.getTitle()); i++; } }
public static void main(String[] args) { VoiceManager voiceManager = VoiceManager.getInstance(); Voice helloVoice = voiceManager.getVoice(VOICE_NAME); if (helloVoice == null) { System.err.println( "Cannot find a voice named " + VOICE_NAME + ". Please specify a different voice."); return; } helloVoice.allocate(); helloVoice.speak("Thank you for giving me a voice. I'm so glad to say hello to this world."); helloVoice.deallocate(); }
public void listenFeeds() { int num = feedList.length; for (int i = 0; i < num; i++) { FastFeed feed = feedList[i]; voice.speak("Press " + i + " for. " + feed.getName()); } }
public void menu() { boolean keepRunning = true; String option = "1"; int optionInt; while (keepRunning) { System.out.println(); listenFeeds(); try { System.out.println("press: "); option = keyboard.readLine(); optionInt = Integer.parseInt(option); listenHeadLines(feedList[optionInt]); voice.speak("Press # for main menu"); System.out.println("press: "); option = keyboard.readLine(); if (option.equals("#")) continue; optionInt = Integer.parseInt(option); listenNews(allNews.get(optionInt)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
public void destroy() { System.out.println("Destroy called!"); view.dispose(); running = false; voice.deallocate(); timer.stop(); arduino.close(); }
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 read() { int i, j, k; String temp = ""; String temp1 = ""; msg = s3.toCharArray(); for (i = 0; i < s3.length(); i++) { try { dos.write(msg[i]); // System.out.println(msg[i]); } catch (Exception e) { System.out.print("read send" + e); } } try { while ((rs = dis.readLine()) != null) { temp += rs; if (rs.equals("OK")) break; if (rs.equals("ERROR")) break; } k = 0; StringTokenizer t = new StringTokenizer(temp, "\""); while (t.hasMoreTokens()) { temp1 = "" + t.nextToken().trim(); k++; if (k == 7) { System.out.println(temp1); VoiceManager voiceManager = VoiceManager.getInstance(); Voice helloVoice = voiceManager.getVoice("kevin"); helloVoice.allocate(); helloVoice.speak(temp1); helloVoice.deallocate(); } } } catch (Exception e) { System.out.print("read rec" + e); } }
/** * Fixes apostrophe s segments. * * @param utterance the utterance to fix */ private void fixApostrophe(Utterance utterance) { Voice voice = utterance.getVoice(); for (Item item = utterance.getRelation(Relation.SEGMENT).getHead(); item != null; item = item.getNext()) { String word = wordPath.findFeature(item).toString(); if (word.equals("'s")) { String pname = item.getPrevious().toString(); if (("fa".indexOf(voice.getPhoneFeature(pname, "ctype")) != -1) && ("dbg".indexOf(voice.getPhoneFeature(pname, "cplace")) == -1)) { prependSchwa(item); } else if (voice.getPhoneFeature(pname, "cvox").equals("-")) { item.getFeatures().setString("name", "s"); } } else if (word.equals("'ve") || word.equals("'ll") || word.equals("'d")) { if ("-".equals(P_PH_VC.findFeature(item))) { prependSchwa(item); } } } }
public void initializeVoice() { // listAllVoices(); voice = voiceManager.getVoice("kevin16"); voice.setDurationStretch(1.0f); /* * voice.setPitch(100.0f); voice.setPitchRange(11.0f); * voice.setPitchShift(1.0f); voice.setDurationStretch(1.0f); */ voice.setPitch(100.0f); voice.setPitchRange(11.0f); voice.setPitchShift(1.0f); voice.setDurationStretch(1f); // System.out.println() voice.allocate(); }
@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; }
public void say(String text) { System.out.println("Stitcher: " + text); voice.speak(text); }
private void destruct() { /* Clean up and leave. */ voice.deallocate(); }
public void listenNews(CloudNews news) { String content = news.getContent(); content = content.replaceAll("\\<.*?>", ""); voice.speak(content); }