We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › text to video
Page Index Toggle Pages: 1
text to video (Read 1196 times)
text to video
Mar 7th, 2010, 8:59am
 
hi, i want to translate text to video parts. For instance:

hi, my name is John.

h = one part of video with somebody who says the letter
i = one part of video with somebody who says the letter

in the dutch language you have different kinds of combinations. I want it to recognize that to.

for instance:

ooi, oi, ch

What is the best way to translate a scentence into video parts?

I've heard that processing isn't good in video.

Code:


import controlP5.*;
ControlP5 controlP5;



String textValue = "";
Textfield myTextfield;

void setup() {
size(400,400);
frameRate(25);
controlP5 = new ControlP5(this);

myTextfield = controlP5.addTextfield("texting",20,20,200,20);
myTextfield.setFocus(true);

}

void draw() {
background(0);
}





public void texting(String theText) {
// receiving text from controller texting
println(theText);
// String str = theText;



char[] theText2 = theText.toCharArray();
println (theText2);


}



Re: text to video
Reply #1 - Mar 7th, 2010, 1:12pm
 
The cleanest way I can think of to recognize character clusters like those is to separate the string into an array of smaller strings (instead of a char[] array).  Most would be one character, but some of them two or three.

In other words, if your maximum char cluster length is 3 chars, check the first 3 chars of your string against all the 3-char clusters, then check the first 2 chars of the string against all the 2-char clusters, and if nothing is found, just save the first char.  Then remove however many were matched from the string, and repeat.
Re: text to video
Reply #2 - Mar 7th, 2010, 1:25pm
 
Actually, you need to have a dictionary where pronunciations matches words.
For example, in English, the ge in gear isn't pronounced the same way than in integer. Sometime, even the meaning is important: in French, fils can be translated to "son" or "threads" (singular vs. plural) and they have different sounds.
In short, the problem is harder than it seems, unless it is very deterministic in Dutch... (it is in Esperanto, for example).
Re: text to video
Reply #3 - Mar 20th, 2010, 5:34am
 
Thanks for replying!

I've been pretty much research on the sounds of the Dutch language. I have a database containing all sounds which occur in the Dutch language (about 11 pages of words). It looks like this:
M      mbt            ambt
     mbts      ambst
     md            beemd, hemd
     mds            hemds

vowels:
e                  bode, bewind.
e                  stevig, hevig.
e                  steel, been.
i                  in, zing.
y                  byssus.
i                  tiran.
                             
y                  Myronus.
iaau                  miaauwen

With this i can split the words into parts.

this is what i got right now:

Code:


import java.util.ArrayList;
import processing.video.*;
Movie myMovie;

ArrayList spc = new ArrayList ();
ArrayList WDstA1 = new ArrayList ();
ArrayList WDnrA1 = new ArrayList ();
String WDst1 = "";
String WDnr1 = "";
int i = 0 ;
int begZin = 0;
int end1 = 0;
int klMax1 = 0;

import controlP5.*;
ControlP5 controlP5;



String textValue = "";
Textfield myTextfield;

void setup() {
size(400,400);
frameRate(25);
controlP5 = new ControlP5(this);

myTextfield = controlP5.addTextfield("texting",20,20,200,20);
myTextfield.setFocus(true);



}

void draw() {
background(0);


}





public void texting(String theText) {
// receiving text from controller texting
println(theText);
// String str = theText
char[] theText2 = theText.toCharArray();
println (theText2);

for (int i=0; i < theText2.length; i++) {
if (theText2[i] == ' '){
// spcAr[x] = i;
spc.add(new Integer(i));



}


}


//println(theText2.length);
// println("array waarde 1 = "+spc.get(0));
//println("array waarde 2 = "+spc.get(1));

/*if (spc.get(0) == " "){
int klMax1 = (Integer)spc.get(0)-1;
}
else {
int klMax1 = theText2.length;
}
*/
int klMax1 = (Integer)spc.get(0)-1;


for (int kl1=0; kl1 < (klMax1)+1; kl1++) {
// println(kl1);
if (theText2[kl1] == 'a'){
WDstA1.add('a');
WDnrA1.add(kl1);
int WDnr1 = i;
}
else if(theText2[kl1] == 'o'){
WDstA1.add('o');
WDnrA1.add(kl1);
int WDnr1 = i;
}
else if(theText2[kl1] == 'e'){
WDstA1.add('e');
WDnrA1.add(kl1);
int WDnr1 = i;
}
else if(theText2[kl1] == 'u'){
WDstA1.add('u');
WDnrA1.add(kl1);
int WDnr1 = i;
}
else if(theText2[kl1] == 'i'){
WDstA1.add('i');
WDnrA1.add(kl1);
int WDnr1 = i;
}
else {
int WDnr1 = i;
}




}
println ("woord klinker(s) = "+ WDstA1);
println ("Positie klinker = "+ WDnrA1 );

if ( (Integer)WDnrA1.get(0) == 0 ) {
int begZin = 1;
println("begin zin is wel een klinker");
}
//else if ( WDnrA1.get(0) == 0
//////////////////////////////////////////////////////// bekijkt hoeveelheid klinkers en weergeeft ze van achteren naar voren
for (int x=0; x < (Integer)WDstA1.size(); x++){
println(WDnrA1.get(x) + "array nummer " +WDstA1.get(x) + " letter " + " potitie " +x);

if ((WDnrA1.contains(x) == true) && (WDnrA1.contains(x+1) == true) && (WDnrA1.contains(x+2) == true)
&& (WDnrA1.contains(x+3) == true) && (WDnrA1.contains(x+4) == true)){
println ("vijf klinkers naast elkaar = "+ WDstA1.get(x)+ WDstA1.get(x+1) + WDstA1.get(x+2) + WDstA1.get(x+3) +
WDstA1.get(x+4));
// x = (Integer)WDstA1.size();

}
else if ((WDnrA1.contains(x) == true) && (WDnrA1.contains(x+1) == true) && (WDnrA1.contains(x+2) == true)
&& (WDnrA1.contains(x = +3) == true)){
println ("vier klinkers naast elkaar = "+ WDstA1.get(x)+ WDstA1.get(x+1) + WDstA1.get(x+2) + WDstA1.get(x+3));
//x = (Integer)WDstA1.size();


}
else if ((WDnrA1.contains(x) == true) && (WDnrA1.contains(x+1) == true) && (WDnrA1.contains(x+2) == true)){
println ("drie klinkers naast elkaar = "+ WDstA1.get(x)+ WDstA1.get(x+1) + WDstA1.get(x+2));
// x = (Integer)WDstA1.size();


}
else if ((WDnrA1.contains(x) == true) && (WDnrA1.contains(x+1) == true)){
println ("twee klinkers naast elkaar = "+ WDstA1.get(x)+ WDstA1.get(x+1));
// x = (Integer)WDstA1.size();


}
else if ((WDnrA1.contains(x) == true)){
println ("een klinkers naast elkaar = "+ WDstA1.get(x));
// x = (Integer)WDstA1.size();

//x = (Integer)WDstA1.size();
}

}
WDstA1.clear();
WDnrA1.clear();
}




At first i want to search the word for the first vowel and possibly second and third or fourth. After i know where the vowels are i want to add consonants possibly before and possibly after the vowel. I allready have a database with the cutted parts of the words. This is like the basic idea of what i want to do. It should be simple. I want to do everything into arrays, because i understand that, but i only get the space checking between the words in an arraylist. and when i want to ask the first value of the arraylist, i get two different values.

Re: text to video
Reply #4 - Mar 20th, 2010, 9:48am
 
Why is this in programs? I'm just having problems with my script. Ofcourse i will share this program with you guys. How is the best way to handle this part?

Code:

for (int i=0; i < theText2.length; i++) {
   if (theText2[i] == ' '){
spcAr[x] = i;
 print(spcAr);


It results into this: [I@45fe3b

i want to have an int out of the array and put it into the "for" loop as < value. tried it with an arraylist, but i couldn't figure it out how to make this value an int.

FIX

int klMax = (Integer)spc.get(0);
for (int klinker1=0; klinker1 < klMax; klinker1++) {
Re: text to video
Reply #5 - Mar 20th, 2010, 11:51am
 
It is in Programs because the first messages were about program design, not syntax.

Some remarks on your previous message: the int  WDnr1 = i; lines in tests are useless because the variable you create there disappears after the closing brace.
Create int WDnr1 = -1; before the test and assign like: WDr1 = i; (well, if you plan to use it).
And, well, I have not understood if you have a question there.

On the last message, the [I@45fe3b is the result we get when we do a System.out.println(spcAr) when spcAr is an array of int. But Processing is supposed to print that OK. Ah, no, it works only with println(), not with print().
Re: text to video
Reply #6 - Mar 20th, 2010, 5:54pm
 
PhiLho  wrote on Mar 20th, 2010, 11:51am:
It is in Programs because the first messages were about program design, not syntax.

Some remarks on your previous message: the int  WDnr1 = i; lines in tests are useless because the variable you create there disappears after the closing brace.
Create int WDnr1 = -1; before the test and assign like: WDr1 = i; (well, if you plan to use it).
And, well, I have not understood if you have a question there.

On the last message, the [I@45fe3b is the result we get when we do a System.out.println(spcAr) when spcAr is an array of int. But Processing is supposed to print that OK. Ah, no, it works only with println(), not with print().


Thanks for helping, now i have a second problem.  ( see previous post for full script). I've inserted this to check if there are multiple vowels next to each other:
Code:

if ((WDnrA1.contains(x) == true) && (WDnrA1.contains(x+1) == true) && (WDnrA1.contains(x+2) == true)
  && (WDnrA1.contains(x+3) == true) && (WDnrA1.contains(x+4) == true)){
println ("vijf klinkers naast elkaar = "+ WDstA1.get(x)+ WDstA1.get(x+1) + WDstA1.get(x+2) + WDstA1.get(x+3) +
   WDstA1.get(x+4));

etc.....

this script results into this
Code:

goerie de poerie
[0] 'g'
[1] 'o'
[2] 'e'
[3] 'r'
[4] 'i'
[5] 'e'
[6] ' '
[7] 'd'
[8] 'e'
[9] ' '
[10] 'p'
[11] 'o'
[12] 'e'
[13] 'r'
[14] 'i'
[15] 'e'
woord klinker(s) = [o, e, i, e]
Positie klinker = [1, 2, 4, 5]
1array nummer o letter  potitie 0
2array nummer e letter  potitie 1
twee klinkers naast elkaar = ei
4array nummer i letter  potitie 2
een klinkers naast elkaar = i
5array nummer e letter  potitie 3

"twee klinkers naast elkaar = ei" means two vowels next to each other, but it must be oe
Re: text to video
Reply #7 - Mar 21st, 2010, 1:13am
 
No need to fully quote the message which is just above your...

I don't understand the purpose of your tests WDnrA1.contains(x+3) (you can skip the == true too).
Apparently, you put chars in the array list, and you go through the whole length of this list to
Wait, no, that's WDstA1, the similar names are confusing.

But your algorithm seems complex. Can't you use String.indexOf function instead? Or do I miss something (haven't tried hard to understand it).
Re: text to video
Reply #8 - Mar 21st, 2010, 6:29am
 
The purpose of that is that i want to check how much vowels are standing together. After checking that i can use that information to let the video fragments speak combined vowels.

indexOf is definantly a option to make it less complex, but then i have to search the whole alfabet and all combinations in the scentence. with the way i want to search, it will search the combinations and then loads in the  combination it finds.

I want to check if value 0 and value 1 is value 0+1

example:
[2, 3, 5, 6]
WDnrA1 array 0 = 2
WDnrA1 array 1 = 3
so now  i know that two vowels are next to each other.

How can i fix this in a easy way. I don't see the code anymore  Cheesy
Page Index Toggle Pages: 1