Hello,
I’m currently working on a Text To Speech project. I want to change the voice in real time, adding some effects in a sound software (Live). For that purpose, I use Soundflower to route the sound from Processing to Ableton Live. This works fine using this code lines
s = new Sound(this);
s.outputDevice(3);
However, as using an oscillator shows the sound routing is effective, the TTS remains not included in the sound.
Here is the full code
import processing.net.*;
Client myClient;
//gestion du son
import processing.sound.*;
Sound s;
//TTS
import guru.ttslib.*;
TTS tts;
//interval
int interval = 200;//timer
int lastRecordedTime = 0;
String [] firstWords = {
"this ", "that", "a", "which", "the", "what"};
String[] adjectives;
String[] nouns;
String[] verbs;
String[] adverbs;
PFont georgia;
void setup() {
size(400, 400);
background(255);
// Create a Sound object for globally controlling the output volume.
//Fonts
georgia = createFont("Georgia", 24);
myClient = new Client(this, "127.0.0.1", 5204);
// Sound parameters
// Play two sine oscillators with slightly different frequencies for a nice "beat".
SinOsc sin = new SinOsc(this);
sin.play(200, 0.2);
sin = new SinOsc(this);
sin.play(205, 0.2);
s = new Sound(this);
s.outputDevice(3);
//TTS settings
tts = new TTS();
tts.setPitch(random(10));
tts.setPitchRange(20);
tts.setPitchShift(20);
//loadStrings
adjectives = loadStrings("adjectives1.txt");
nouns = loadStrings("nouns1.txt");
verbs = loadStrings("verbs1.txt");
adverbs = loadStrings("negative_adverbs.txt");
//noLoop();
}
void draw() {
// socket python - processing
myClient.write("Paging Python!"); // send whatever you need to send here
background(255);
textFont(georgia, 24);
fill(0);
if(millis()-lastRecordedTime>interval)
{
String word1 = firstWords[int(random(firstWords.length))];
//String word2 = adjectives[int(random(adjectives.length))];
String word3 = nouns[int(random(nouns.length))];
String word4 = verbs[int(random(verbs.length))];
String word5 = adverbs[int(random(adverbs.length))];
String output = firstWords[int(random(firstWords.length))] + " " +
" " + nouns[int(random(nouns.length))]+ " " + verbs[int(random(verbs.length))]+ " " + adverbs[int(random(adverbs.length))];
// joining the Strings together (with a space)
println (output);
tts.speak(output);
lastRecordedTime = millis();
}
}
void mouseReleased() {
redraw();
//loop();
}
Many thanks for any advice…