We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am working with the STT library, trying to get the type that it is displaying in my processing sketch to be in "paragraph" form, meaning every time it processes a new word, it places the new word at a consistent distance form the previous word.
example:
chair as table house
*note that all these words "chair as table house" are input into STT at different times.
I am currently using the textWidth() function to calculate the distance of the result word, but this is only picking up on the most recent word processed. I need to create a way to store all of the previous textWidth() values.
Please look at my code and let me know if you have any suggestions.
thank you
import com.getflourish.stt.*;`
import ddf.minim.*;
import ddf.minim.analysis.*;
STT stt;
String result;
String changed;
float x;
float y;
float dim;
Minim minim;
AudioInput input;
AudioPlayer player;
PFont font;
float sw;
void setup ()
{
size(800, 800);
stt = new STT(this);
stt.enableDebug();
stt.setLanguage("en");
input = stt.getLineIn ();
font = createFont("Arial", 24);
result = "speak";
x = sw;
y = 30;
background (0);
}
void draw ()
{
textFont(font,20);
if (! result.equals(changed)) {
text(result, x, y);
changed = result;
}
sw = textWidth(result);
if (x > width) {
x = 0;
y += 1;
}
}
void transcribe (String utterance, float confidence)
{
println(utterance);
result = utterance;
}
public void keyPressed () {
stt.begin();
}
public void keyReleased () {
stt.end();
}
void stop()
{
input.close();
minim.stop();
super.stop();
}