Browse the newest, top selling and discounted Otome products on Steam. Trust Me, I Got This! Is available as a free download for Windows and Mac OS via its Global Game Jam page (where you can also find the source files, if you're interested in picking through the Unity project files for game-development inspiration) or as a web browser game, as well as Windows and Mac OS downloadable files, via its itch.io game page on Circus Atos' profile. I've been playing with text to speech recently. If you have a Mac and a little time on your hands, feedback and bug fixes would be most welcome.
posted 8 years ago- Optional 'thank-you' note:
This is not exactly a SSCCE, but it is as short as I could make it. If you have a Mac and a little time on your hands, feedback and bug fixes would be most welcome.import java.io.*; import java.util.*; public class MacSpeaker { protected File scriptFile; protected Process process; protected final String[] voices; protected int voiceIndex = 0; //protected int pitch = 0; // -10 to +10 protected int volume = 50; // 0 to 100 protected int rate = 100; // 80 to 400 public static void main(String[] args) { new MacSpeaker().test(); } private void test() { int numVoices = voices.length; if (numVoices 0) { return; } Random random = new Random(); for (int i = 0; i < 10 && i < numVoices; i++) { voiceIndex = random.nextInt(numVoices); volume = random.nextInt(100); System.out.println('Voice: ' + voices[voiceIndex] + ' Volume: ' + volume); speakAndWait('Hello World'); try { Thread.sleep(500); } catch (InterruptedException ex) { ex.printStackTrace(); } } } public MacSpeaker() { voices = populateVoiceArray(); } protected String[] populateVoiceArray() { Scanner input = null; try { Process p = Runtime.getRuntime().exec('say -v '?'); new ProcessReader(p, true); // consume the error stream input = new Scanner(p.getInputStream()); List<String> voiceList = new ArrayList<String>(); while (input.hasNextLine()) { voiceList.add(input.nextLine()); } return voiceList.toArray(new String[0]); } catch (IOException ex) { ex.printStackTrace(); } return new String[]{}; } protected void makeScriptFile() { String speakScript = ' + 'on run argvn' + ' set theCall to (item 1 of argv)n' + ' set theVoice to (item 2 of argv)n' + ' set theVolume to (item 3 of argv)n' + ' set theRate to (item 4 of argv)n' + ' set oldVolume to output volume of (get volume settings)n' + ' set volume output volume ((oldVolume * theVolume) / 100)n' + ' say -v theVoice -r theRate theCall with waiting until completionn' + ' set volume output volume (oldVolume)n' + 'end runn'; FileWriter fw = null; try { scriptFile = File.createTempFile('speech', '.scpt'); scriptFile.deleteOnExit(); fw = new java.io.FileWriter(scriptFile); fw.write(speakScript); } catch (IOException ex) { ex.printStackTrace(); } finally { if (fw != null) { try { fw.close(); } catch (IOException ex) { ex.printStackTrace(); } } } } public void speakAndWait(String call) { process = speak(call); if (process != null) { try { process.waitFor(); } catch (InterruptedException ex) { ex.printStackTrace(); } } } protected Process speak(String call) { process = null; try { process = Runtime.getRuntime().exec(new String[]{'osascript', scriptFile.getAbsolutePath(), '' + call + '', '' + voices[voiceIndex] + '', ' + volume, ' + rate }); new ProcessReader(process, false); // consume the output stream new ProcessReader(process, true); // consume the error stream } catch (IOException ex) { ex.printStackTrace(); } return process; } } class ProcessReader { public ProcessReader(Process process, final boolean errorStream) { final InputStream processStream = errorStream ? process.getErrorStream() : process.getInputStream(); new Thread() { @Override public void run() { try { BufferedReader br = new BufferedReader(new InputStreamReader(processStream)); String line; while ((line = br.readLine()) != null) { if (errorStream) { System.err.println(line); } else { System.out.println(line); } } } catch (IOException ex) { ex.printStackTrace(); } } }.start(); } }
Thank you for reading.
luck, db
There are no new questions, but there may be new answers.
- Optional 'thank-you' note:
http://www.fileden.com/files/2008/12/12/2221280/HousieGame.jar
luck, db
There are no new questions, but there may be new answers.
- Optional 'thank-you' note:
Voice `'?' not found.
I then changed the 'say' line to use an actual name rather than a question mark.
Process p = Runtime.getRuntime().exec('say -v Bruce');
But then it hung because say requires a message.
This thread suggests looking in a directory for the list of available voices.
Jeanne-Boyarskys-MacBook-Pro:2012-cs258-testing nyjeanne$ ls /System/Library/Speech/Voices/
AgataCompact.SpeechVoice LeeCompact.SpeechVoice
Agnes.SpeechVoice MagedCompact.SpeechVoice
Albert.SpeechVoice MikkoCompact.SpeechVoice
Alex.SpeechVoice MilenaCompact.SpeechVoice
AylinCompact.SpeechVoice NaraeCompact.SpeechVoice
BadNews.SpeechVoice NarisaCompact.SpeechVoice
Bahh.SpeechVoice Organ.SpeechVoice
Bells.SpeechVoice OskarCompact.SpeechVoice
Boing.SpeechVoice PaoloCompact.SpeechVoice
Bruce.SpeechVoice Princess.SpeechVoice
Bubbles.SpeechVoice Ralph.SpeechVoice
Cellos.SpeechVoice RaquelCompact.SpeechVoice
DanielCompact.SpeechVoice SamanthaCompact.SpeechVoice
Deranged.SpeechVoice Sin-JiCompact.SpeechVoice
DiegoCompact.SpeechVoice StineCompact.SpeechVoice
EszterCompact.SpeechVoice Ting-TingCompact.SpeechVoice
FelixCompact.SpeechVoice Trinoids.SpeechVoice
Fred.SpeechVoice Vicki.SpeechVoice
GoodNews.SpeechVoice Victoria.SpeechVoice
Hysterical.SpeechVoice VirginieCompact.SpeechVoice
IdaCompact.SpeechVoice Whisper.SpeechVoice
JavierCompact.SpeechVoice XanderCompact.SpeechVoice
JoanaCompact.SpeechVoice Ya-LingCompact.SpeechVoice
Junior.SpeechVoice YannickCompact.SpeechVoice
Kathy.SpeechVoice Zarvox.SpeechVoice
KyokoCompact.SpeechVoice ZuzanaCompact.SpeechVoice
[OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
- Optional 'thank-you' note:
Jeanne Boyarsky wrote:Copy and pasted. Ran and got
Voice `'?' not found.
That's strange. I took that from the official reference. It's even in the examples towards the bottom of that page.
What does that do from the terminal, with and without the single quotes? I'm thinking the single quotes may require quoting or double-quoting when passed from Runtime.exec. There's one line in my Linux implementation that looks like this, I may need something similar here. + ' '' + call + ''
I then changed the 'say' line to use an actual name rather than a question mark.
Process p = Runtime.getRuntime().exec('say -v Bruce');
But then it hung because say requires a message.
Yes, that I would expect. But the purpose of that method is to retrieve a String array of available voice names (for subsequent use in a JComboBox).
Does this alternative, adapted from a MacScripter topc, work for you? protected String[] populateVoiceArray() { Scanner input = null; try { String voicesScript = ' + '#!/usr/local/bin/pythonn' + 'from AppKit import NSSpeechSynthesizern' + 'voices = NSSpeechSynthesizer.availableVoices()n' + 'for voice in voices:n' + ' voiceattr = NSSpeechSynthesizer.attributesForVoice_(voice)n' + ' voicename = voiceattr['VoiceName']n' + ' print voicename.encode('utf-8')n'; File file = File.createTempFile('voices', '.py'); file.deleteOnExit(); FileWriter fw = new FileWriter(file); fw.write(voicesScript); fw.close(); Process p = Runtime.getRuntime().exec('python ' + file.getPath()); new ProcessReader(p, true); // consume the error stream input = new Scanner(p.getInputStream()); List<String> voiceList = new ArrayList<String>(); while (input.hasNextLine()) { voiceList.add(input.nextLine()); } return voiceList.toArray(new String[0]); } catch (IOException ex) { ex.printStackTrace(); } finally { if (input != null) { input.close(); } } return new String[]{}; }
This thread suggests looking in a directory for the list of available voices.
That would be a last resort, capturing the 'ls' of that directory. Looks like the parsing needed, to get a voice name that can be passed to say, is to take the part up to the first dot and insert a space before each uppercase letter (except the first).
Thank you again.
luck, db
There are no new questions, but there may be new answers.
- Optional 'thank-you' note:
[OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
- Optional 'thank-you' note:
I don't know if this will help you or not, but in Terminal, if I type:
say -v bruce hello my name is bruce
the computer speaks in the Bruce voice: hello my name is bruce
If I type only 'say -v bruce' at the beginning then hit enter, I get the beach ball spinning for a few seconds, then whatever I type at the prompt is spoken in the bruce voice once I hit the enter key. Each phrase I have it speak is on one line in the Terminal.
Perhaps this is already known to you, but maybe not.
BD
I've got just enough Java knowledge to royally screw everything up. :-)
- Optional 'thank-you' note:
I pasted in your new code, and the terminal output read:
Voice: Ralph Volume: 61
and got a Null pointer in the try block at scripFile.getAbsolutePath() in the speak method.
Hope that helps. :-)
BD
I've got just enough Java knowledge to royally screw everything up. :-)
- Optional 'thank-you' note:
edit Oh, I see that say -v '?' appears for ver. 10.7.4 and isn't there for 10.6.
What about the second option, the one uising NSSpeechSynthesizer? Does that fly?
luck, db
There are no new questions, but there may be new answers.
- Optional 'thank-you' note:
I am running Lion. I did not consult the manual, just typed in a few commands to test how 'say' worked.
If you want me to test something specific, just ask. :-)
Cheers
BD
I've got just enough Java knowledge to royally screw everything up. :-)
iTunes is going places.
Download macOS Catalina for an all‑new entertainment experience. Your music, TV shows, movies, podcasts, and audiobooks will transfer automatically to the Apple Music, Apple TV, Apple Podcasts, and Apple Books apps where you'll still have access to your favorite iTunes features, including purchases, rentals, and imports.
You can always download iTunes 12.8 for previous versions of macOS,
as well as the iTunes application for Windows.
Hardware:
- Mac computer with an Intel processor
- To play 720p HD video, an iTunes LP, or iTunes Extras, a 2.0GHz Intel Core 2 Duo or faster processor is required
- To play 1080p HD video, a 2.4GHz Intel Core 2 Duo or faster processor and 2GB of RAM is required
- Screen resolution of 1024x768 or greater; 1280x800 or greater is required to play an iTunes LP or iTunes Extras
- Internet connection to use Apple Music, the iTunes Store, and iTunes Extras
- Apple combo drive or SuperDrive to create audio, MP3, or backup CDs; some non-Apple CD-RW recorders may also work. Songs from the Apple Music catalog cannot be burned to a CD.
Software:
- OS X version 10.10.5 or later
- 400MB of available disk space
- Apple Music, iTunes Store, and iTunes Match availability may vary by country
- Apple Music trial requires sign-up and is available for new subscribers only. Plan automatically renews after trial.
iTunes
Download the latest version for Windows.
The latest entertainment apps now come installed with macOS Catalina. Upgrade today to get your favorite music, movies, TV shows, and podcasts. You can join Apple Music and stream — or download and play offline — over 75 million songs, ad‑free.
iTunes
Download the latest version from the Microsoft Store.
Detective Time (itch) (mattie) Mac Os 7
Hardware:
- PC with a 1GHz Intel or AMD processor with support for SSE2 and 512MB of RAM
- To play standard-definition video from the iTunes Store, an Intel Pentium D or faster processor, 512MB of RAM, and a DirectX 9.0–compatible video card is required
- To play 720p HD video, an iTunes LP, or iTunes Extras, a 2.0GHz Intel Core 2 Duo or faster processor, 1GB of RAM, and an Intel GMA X3000, ATI Radeon X1300, or NVIDIA GeForce 6150 or better is required
- To play 1080p HD video, a 2.4GHz Intel Core 2 Duo or faster processor, 2GB of RAM, and an Intel GMA X4500HD, ATI Radeon HD 2400, or NVIDIA GeForce 8300 GS or better is required
- Screen resolution of 1024x768 or greater; 1280x800 or greater is required to play an iTunes LP or iTunes Extras
- 16-bit sound card and speakers
- Internet connection to use Apple Music, the iTunes Store, and iTunes Extras
- iTunes-compatible CD or DVD recorder to create audio CDs, MP3 CDs, or backup CDs or DVDs. Songs from the Apple Music catalog cannot be burned to a CD.
Software:
- Windows 10
- 64-bit editions of Windows require the iTunes 64-bit installer
- 400MB of available disk space
- Some third-party visualizers may no longer be compatible with this version of iTunes. Please contact the developer for an updated visualizer that is compatible with iTunes 12.1 or later.
- Apple Music, iTunes Store, and iTunes Match availability may vary by country
- Apple Music trial requires sign-up and is available for new subscribers only. Plan automatically renews after trial.
iTunes is going places.
Visit the iTunes Store on iOS to buy and download your favorite songs, TV shows, movies, and podcasts. You can also download macOS Catalina for an all-new entertainment experience on desktop. Your library will transfer automatically to the new Apple Music app, Apple TV, and Apple Podcasts. And you'll still have access to your favorite iTunes features, including your previous iTunes Store purchases, rentals, and imports and the ability to easily manage your library.
Music, TV, and podcasts
take center stage.
iTunes forever changed the way people experienced music, movies, TV shows, and podcasts. It all changes again with three all-new, dedicated apps — Apple Music, Apple TV, and Apple Podcasts — each designed from the ground up to be the best way to enjoy entertainment on your Mac. And rest assured; everything you had in your iTunes library is still accessible in each app. iCloud seamlessly syncs everything across your devices — or you can back up, restore, and sync by connecting the device directly to your Mac.
The new Apple Music app is the ultimate music streaming experience on Mac.1 Explore a library of over 75 million songs, discover new artists and tracks, find the perfect playlist, download and listen offline, or enjoy all the music you've collected over the years. And find it all in your music library on all your devices.
The Apple TV app for Mac is the new home for all your favorite movies, shows, premium channels, and Apple TV+. Watch everything directly in the app or enjoy it offline, and discover the best of what's on in the Watch Now tab. You can even pick up where you left off on any screen, across all your devices. And for the first time, 4K2 and Dolby Atmos3-supported movies are available on Mac.
More than 700,000 of the best entertainment, comedy, news, and sports shows are now available on your Mac with Apple Podcasts. Search for podcasts by title, topic, guest, host, content, and more. Subscribe and be notified as soon as new episodes become available. And in the Listen Now tab, you can easily pick up where you left off across all your devices.
iTunes Support can help answer your questions
Get help with syncing, updating to a more recent version of iTunes, or with an iTunes Store purchase — and much more.
Learn moreDetective Time (itch) (mattie) Mac Os Catalina
Looking for a previous version of iTunes?
Download earlier versions of iTunes to work with compatible operating systems and hardware.
Find previous versions of iTunes