Reputation: 1032
This is a theorical question about programming patterns for an Open Source software project.
We are forking the Open Source project Araword (written in Java, but that's partially relevant), we want to add the offline Text-To-Speech feature, as now it's only using Google's online TTS.
The software runs cross-platformly. So according to the underlying OS the user has to be able to choose between his platform-related TTS implementation or the cross-platform (Google) one.
We want to switch between every TTS implementation in an elegant manner, but what are the best practices about.
1) I've heard about Factory Method Pattern on wikipedia:
http://en.wikipedia.org/wiki/Factory_method_pattern
2) IoC / Service location pattern:
http://en.wikipedia.org/wiki/Service_locator_pattern
I would appreciate any suggestions.
Upvotes: 1
Views: 110
Reputation: 1002
If you want to switch to the system's TTS, than do something like this:
Or, use the cross-platform FreeTTS library, and then implement that (Please note the voices are lower-quality).
The FreeTTS project can be found here:
http://freetts.sourceforge.net/docs/index.php
Upvotes: 1