Conflict between a TTS and Sound Object

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…

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.