NSSpeechSynthesizer extends NSObject { public void setOutputToFileURL(URI uri) { setProperty(SpeechProperty.OutputToFileURLProperty, uri != null ? NSURL.CLASS.URLWithString(uri.toString()) : null); }  static NSSpeechSynthesizer synthesizerWithVoiceIdentifier(String voiceIdentifer); static NSSpeechSynthesizer synthesizerWithVoice(NSVoice voice); static NSVoice defaultVoice(); static List<NSVoice> availableVoices(); static boolean isAnyApplicationSpeaking(); synchronized void setDelegate(final NSSpeechSynthesizerDelegate delegate); synchronized NSSpeechSynthesizerDelegate getDelegate(); String opcodeToPhoneme(short opcode); static String createSyncPoint(int marker); NSObject getProperty(SpeechProperty property); void setProperty(SpeechProperty property, NSObject value); void addSpeechDictionary(NSSpeechDictionary dictionary); NSSpeechStatus getStatus(); NSSpeechError getError(); NSSpeechMode getInputMode(); void setInputMode(NSSpeechMode mode); NSSpeechMode getCharacterMode(); void setCharacterMode(NSSpeechMode mode); NSSpeechMode getNumberMode(); void setNumberMode(NSSpeechMode mode); NSSpeechSynthesizerInfo getSynthesizerInfo(); float getPitchBase(); void setPitchBase(float baselinePitch); float getPitchMod(); void setPitchMod(float modulation); List<NSSpeechPhonemeInfo> getPhonemeInfo(); int getRecentSync(); boolean setVoice(NSVoice voice); NSVoice getVoice(); void setCommandDelimiter(NSSpeechCommand delimiters); void reset(); void setOutputToFileURL(URI uri); boolean startSpeakingStringToURL(String text, URI uri); abstract void continueSpeaking(); abstract boolean isSpeaking(); abstract void pauseSpeakingAtBoundary(NSSpeechBoundary boundary); abstract String phonemesFromText(String text); abstract float rate(); abstract void setRate(float rate); abstract void setUsesFeedbackWindow(boolean useFeedbackWindow); abstract boolean setVoice(String voiceIdentifier); abstract void setVolume(float volume); abstract boolean startSpeakingString(String text); abstract void stopSpeaking(); abstract void stopSpeakingAtBoundary(NSSpeechBoundary boundary); abstract boolean usesFeedbackWindow(); String getVoiceIdentifier(); float getVolume(); static final _Class CLASS; }
@Test public void testSetOutputToFileURL() throws IOException { File helloWorld = null; FileInputStream fis = null; try { helloWorld = File.createTempFile("helloworld", ".aiff"); helloWorld.deleteOnExit(); NSSpeechSynthesizer ss = NSSpeechSynthesizer.synthesizerWithVoice(null); SynthesizerDelegate sd = new SynthesizerDelegate(ss); ss.setOutputToFileURL(helloWorld.toURI()); ss.startSpeakingString("Hello World"); sd.waitForSpeechDone(5000, true); assertTrue(helloWorld.exists()); fis = new FileInputStream(helloWorld); assertTrue("Should have some bytes", fis.available() > 0); } finally { if ( fis != null ) { fis.close(); } if ( helloWorld != null ) { helloWorld.delete(); } } }