I have installed the tts library and gotten the example working. I also found some example code on the old forum for a 'Basnik' class and got that working too, but now I'm trying to write my own program that speaks letters and characters.
An important thing is though that the pitch or tone of the voice changes with my control - I have an array of letters and luminance values (0-255) and I want the letter to be read out but the pitch to change according to the luminance value.
I saw voice.setPitch in the Basnick class (code below) but changing it doesn't alter the voice. Having little experience I'm still learning how classes work and the freetts documentation isn't as friendly as Processing's so I can't fathom where all the functions in the basnick class come from what they do and how to get them into processing. Have you got any pointers please?
I tried to modify the tts example:
...
- void mousePressed() {
- tts.setPitch(1);
- tts.speak( "Hello this is a test.");
- }
but get error "The function setPitch(int) does not exist" where as this doesn't occur in the example below which runs fine.
Basnik example below.
-
import guru.ttslib.*;
public class Basnik {
- String voiceName = "kevin16";
- VoiceManager voiceManager;
- Voice voice;
- Basnik(String name) {
- voiceName = name;
- this.setup();
- }
- 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)");
- }
- }
- void setup() {
- listAllVoices();
- System.out.println();
- System.out.println("Using voice: " + voiceName);
- voiceManager = VoiceManager.getInstance();
- voice = voiceManager.getVoice(voiceName);
- voice.setPitch(1.75);
- voice.setPitchShift(0.75);
- // voice.setPitchRange(10.1); //mutace
- voice.setStyle("breathy"); //"business", "casual", "robotic", "breathy"
- if (voice == null) {
- System.err.println(
- "Cannot find a voice named "
- + voiceName + ". Please specify a different voice.");
- System.exit(1);
- }
- voice.allocate();
- }
- void mluv(String _a) {
- if(_a==null) {
- _a= "nothing";
- }
- voice.speak(_a);
- }
- void exit() {
- voice.deallocate();
- }
- }
In Tab 1
-
void setup(){
verlaine = new Basnik("kevin16");
verlaine.mluv("hello, ohtravioso, do you hear me?") ;
}