Conflict between a TTS and Sound Object


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);

However, as using an oscillator shows the sound routing is effective, the TTS remains not included in the sound.

Here is the full code

Client myClient;
//gestion du son
import processing.sound.*;
Sound s;
import guru.ttslib.*;
TTS tts;
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);
  // Create a Sound object for globally controlling the output volume.
  georgia = createFont("Georgia", 24);

  myClient = new Client(this, "", 5204); 
  // Sound parameters
  // Play two sine oscillators with slightly different frequencies for a nice "beat".
  SinOsc sin = new SinOsc(this);, 0.2);
  sin = new SinOsc(this);, 0.2);

  s = new Sound(this);
  //TTS settings
  tts = new TTS();
  adjectives = loadStrings("adjectives1.txt");
  nouns = loadStrings("nouns1.txt");
  verbs = loadStrings("verbs1.txt");
  adverbs = loadStrings("negative_adverbs.txt");

void draw() {
  // socket python - processing
  myClient.write("Paging Python!"); // send whatever you need to send here
  textFont(georgia, 24);

    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);
   lastRecordedTime = millis(); 

void mouseReleased() {

Many thanks for any advice…

Were you able to resolve this issue?

If I’m understanding right, you want to route the output of tts.speak(output) into Ableton Live – is that right?

Rerouting the Processing Sound library output will affect not affect fretts. You might need to either change the ttslib (check out the source).

You could also set soundflower as your system primary audio interface. Then all audio generated by Processing should be captured by soundflower for routing.

Of course, I am not an audio expert, and haven’t used soundflower in some time…

Hi Jeremy,

Thanks for these tips. Indeed, after having thought on the issue, I thought I should check the source code of the ttslib, but it isn’t that obvious to find the sound outputs. So, I’ll certainly route the main audio output to Soundflower as you adviced, but the problem is the unability to hear in realtime what’s happening. Then, the sound in Live will be processed after having been recorded.
Otherwise, I have to check an other TTS library which would use a different sound router options.