9 posts tagged “programming a to z”
Online version here (right click and hit "Play").
Java code here.
.fla file here.
Currently I only have one of the additions to my midterm project working: my homemade text to speech translator using my own voice. It was fairly straighforward to build and program. Here's how I did it:
1) Obtain a list of every possible phoneme from the Rita getPhonemes() method.
2) Recorded myself saying every one of said phonemes and converting them to mp3s.
3) Do getPhonemes() on a piece of text
4) Read the array given by getPhonemes() into Flash
5) Each phoneme of a word is separated by a dash. Split each word into an array divided by these dashes.
6) Create a function which plays one mp3 at a time, pausing for the duration of the mp3 before moving to the next one.
In this example I used text from Michael Gira's "Why I Ate My Wife". My original idea was to use text from my dreams, but I haven't remembered more than five seconds of any dreams I've had since I presented my final idea 3 weeks ago.
What doesn't work (yet):
I wrote a method which gets all the holoynyms of each word (using getHolonym()), then "crawls" all of those words and looks for their holonyms. This piece of text has a strong focus on the body so I looked for words which would return the word "body" or similar words. From there it would use the Flickr API to find images tagged with that word, then displays them in some form when the word they're related to appears on screen in the Flash movie.
Sadly the methods of RitaWN are giving me a lot of trouble even in very straighforward situations and I get an error about which I've found absolutely no useful documentation online.
For some reason, I could not get many functions in RitaWN to work, even simple ones in simple circumstances, so that and the Flickr API will have to wait.
There are two main goals for my final project, which is essentially going to be a more sophisticated (and hopefully more watchable) version of my midterm:
1) Find content that actually has some meaning or signifigance to me
I'm going to use written records of my dreams. I think I have a big notebook full of them at my parents' house in New Jersey, but if I can't get that I'm going to record my dreams now.
2) Make the whole thing more dynamic
The original version started slow, and over the course of a minute sped up every so many words until it was going so fast it was virtually unreadable. I want to do more with juxtaposing slow passages with fast passages, possibly making certain segments of dreams slow and certain fast.
The emphasis here is on making a finished product rather than making the most sophisticated code. I'm going to experiment with lots of different code to see what has the most interesting results.
I'm definitely going to use RiTa alot.
Click here to see the incomplete online version.
I took my midterm and used the Rita library to check for nouns and verbs. Verbs have randomized blinky color and fly towards the screen and nouns jump around randomly with a blinky background.
For reasons I really don't understand it plays perfectly well in Flash Player but the text doesn't jump around when posted online... So hopefully I'll get to show it on my laptop in class.
Online version here.
Java code here.
Flash code here.
My midterm was laregly inspired by the work of Young Hae Chang Heavy Industries. The goal was to create a similar simple but high energy text animation which creates its impact by changing the size and color of the text, changing its speed, and sounds which respond to various characteristics of each word in the text.
The applet takes in a text and finds the amount of times each word is used, the part of speech, and the length of the word. Words used only 1 or 2 times the word appears in large red text on a black backround, if it is used more than 2 times it appears smaller in black text on a red background. The size of the text is directly proportional to the amount of times the word is used. Rarely used words of more than 4 letters appear in all caps, and rarely used verbs appear in italics. There are also different sounds which are played, on every word change, based on these parameters.
Over the course of the text the time between frames decreases until it becomes virtually unreadable and the sounds become a breakbeat mess.
Most of the text analysis is done in Java, and the information about each word is then stored in a text file which can be read by Flash. I chose to use Flash because I was having problems getting the animation to display properly in Processing. For some reason it would randomly skip frames. I'm not sure if it was any error in my code since the frames which would skip would be different every time I ran the program.
For my midterm I would like to create an applet which dynamically creates text based animations based on two of my earlier assignments, the Speech Inhibitor and the Blinky Text Concorance Thing.
I am going to use a webcrawler on a political news website to find articles with a good number of quotes, apply the Speech Inhibitor to them then run them though an applet which will then run them through a much more advanced version of the Blinky Text Concordance Thing in an attempt to get a dramatic animated result in the vein of the work of Young Hae Chang Heavy Industries, which achieves a very dramatic effect using only the speed, size and amount of text shown for each frame.
So far the Text Concordance just gets the amount of times each word in a text file is used and displays them in alphbetical order and changes the text size and black to red contrast based on how many times each word is used. I'd like to:
-use a web crawler to find most used words in a large number of articles and apply that to it
-make the Speech Inhibitor more intricate
-run the Speech Inhibitor on the text before it goes through the Concordance
-make it so that it will not display only one word at a time but will choose either only one word or a phrase based on the popularity of words and phrases used in it, whether it is used in quotes, how many words in the sentence and how many words and sentences in each paragraph. Cut out prepositional and verb phrases and decide whether to show them all at once or one at a time and at what speed and size based on the analysis of the original text.
For my fourth assignment I took all the Spam Filter code from the CVS and changed it into a more generic application which will tell you whether the .txt document you give it is more like Category 1 or Category 2. It's quite simple and not that exciting, but it will likely be useful later on since it's very unlikely I'm going to be using this analysis to analyze spam!
Code here
This class takes all the words in a text file and displays them one at a time very quickly with different colors and sizes depending on how many times the word occurs in the text.
Unfortunately I still haven't figured out how to embed applets on a web page!!@$!@$!#%$.
This program takes an input file, isolates all the text in quotes, and then uses regular expressions to make whoever is talking sound significantly less articulate.
Input:
Alito Resists Making Comparisons to O'Connor By DAVID STOUT WASHINGTON, Jan. 12 - Judge Samuel A. Alito Jr. refused today to compare himself to the justice he would replace on the Supreme Court, Sandra Day O'Connor, as Democratic opposition to the nominee seemed to harden. "I think we all have to be who we are," Judge Alito told the Senate Judiciary Committee, whose Democratic members complained anew that he had not been forthcoming enough during his confirmation hearings. Judge Alito said he believed Justice O'Connor would be remembered "with great admiration." But he declined to say whether he agreed with her ringing dissent in one of the court's most important cases last year, in which the majority held, 5 to 4, that the government could use its power of eminent domain to take private property to promote economic development. "It touches some very sensitive nerves," Judge Alito said of the property case, which arose from a dispute in New London, Conn. "When someone's home is being taken away using the power of eminent domain, that is, that is a blow to a lot of people, even if they're going to get compensated at fair market values for their home." That answer seemed to disappoint the questioner, Senator Herb Kohl, Democrat of Wisconsin, who described the reply as "on the one hand and on the other hand." "I'd ask you," the senator persisted, "if you would, venture an opinion more precisely, specifically - do you agree in general with Justice O'Connor's dissent?" "Well, senator," Judge Alito said, "I don't think I can answer that beyond what I've said." Minutes earlier, Senator Kohl had signaled impatience with Judge Alito for his failure, in the senator's view, to answer directly on how he felt about the possibility of age or term limits for federal judges. "This is the only time - today may be the last time that we ever have a chance as a nation to talk to you," Mr. Kohl said. "So you have a thought on it. I mean, I can't believe you don't have a thought." The committee's ranking Democrat, Senator Patrick J. Leahy of Vermont, also expressed disappointment and skepticism in the responses of Judge Alito, who sits on the United States Court of Appeals for the Third Circuit, in Philadelphia. "I continue to be worried," Mr. Leahy said in a recess. "I pressed the questions again today as I have all week long. He is not clear that he would serve to protect America's fundamental rights. Americans have to look to the Supreme Court to protect their rights." "When people want to take away our rights of the courts, when politicians, in pandering to whatever special interest group it is, want to take away our rights of the court, I would assume somebody who's going on the Supreme Court would say you can't do that," Mr. Leahy went on. "We could not get that clear answer today." The dissatisfaction voiced by Senators Kohl and Leahy could be significant, since they voted in favor of the nomination of Judge John G. Roberts Jr. to be chief justice, and their comments today indicated that, in their eyes at least, Judge Alito suffers by comparison with the earlier nominee. The tone of the hearings, which are nearing conclusion, could preview a straight party-line committee vote on the nominee, with all 10 Republicans voting in favor and all 8 Democrats voting against, although Senator Arlen Specter, Republican of Pennsylvania, has not committed himself. Judge Roberts, by contrast, was endorsed by the committee, 13 to 5. (Senator Russell D. Feingold of Wisconsin was the third Democrat to support Judge Roberts.) Since there are 55 Republicans in the Senate, Judge Alito would still appear to have an excellent chance at confirmation, if by a less decisive margin than the 78-to-22 vote that elevated Judge Roberts.
Output:
Alito Resists Making Comparisons to O'Connor
By DAVID STOUT
WASHINGTON, Jan. 12 - Judge Samuel A. Alito Jr. refused today to compare himself to the justice he would replace on the Supreme Court, Sandra Day O'Connor, as Democratic opposition to the nominee seemed to harden.
"I think, like, we all gotta totally be who we are," Judge Alito told the Senate Judiciary Committee, whose Democratic members complained anew that he had not been forthcoming enough during his confirmation hearings.
Judge Alito said he believed Justice O'Connor would be remembered "with great admiration and whatnot." But he declined to say whether he agreed with her ringing dissent in one of the court's most important cases last year, in which the majority held, 5 to 4, that the government could use its power of eminent domain to take private property to promote economic development.
"It , like,touches some very, uh, sensitive nerves," Judge Alito said of the property case, which arose from a dispute in New London, Conn. "When someone's home is totally being taken away using the power of eminent domain, that is totally, that is totally a blow to a lot of people, even if dudes're going to get, um, compensated at fair market values for their home."
That answer seemed to disappoint the questioner, Senator Herb Kohl, Democrat of Wisconsin, who described the reply as "on the one hand and on the other hand."
"I'd ask you," the senator persisted, "if you would, venture an opinion more, uh, precisely, and stuff, um, specifically - do you agree in general with Justice O'Connor's dissent, you know?"
"Well, senator," Judge Alito said, "I don't think I can, like, answer that beyond what I've said."
Minutes earlier, Senator Kohl had signaled impatience with Judge Alito for his failure, in the senator's view, to answer directly on how he felt about the possibility of age or term limits for federal judges. "This is totally the only time - today may totally be the last time that we ever got a chance as a nation to talk to you," Mr. Kohl said. "So you got a thought on it. I mean, I can't believe you don't got a thought and whatnot."
The committee's ranking Democrat, Senator Patrick J. Leahy of Vermont, also expressed disappointment and skepticism in the responses of Judge Alito, who sits on the United States Court of Appeals for the Third Circuit, in Philadelphia.
"I continue, like, to totally be worried," Mr. Leahy said in a recess. "I pressed, like, the, uh, questions again today as I got, like, all week long. Dude is totally not clear that dude would serve to protect America's, um, fundamental rights. Americans gotta look to the Supreme Court to protect their rights."
"When people want to take away our rights of the courts, when, um, politicians, and stuff, in, uh, pandering to whatever special interest group it , like,is totally, want to take away our rights of the court, I would, like, assume somebody who's going on the Supreme Court would say you can't do that," Mr. Leahy went on. "We could not get that clear answer today."
The dissatisfaction voiced by Senators Kohl and Leahy could be significant, since they voted in favor of the nomination of Judge John G. Roberts Jr. to be chief justice, and their comments today indicated that, in their eyes at least, Judge Alito suffers by comparison with the earlier nominee.
The tone of the hearings, which are nearing conclusion, could preview a straight party-line committee vote on the nominee, with all 10 Republicans voting in favor and all 8 Democrats voting against, although Senator Arlen Specter, Republican of Pennsylvania, has not committed himself.
Judge Roberts, by contrast, was endorsed by the committee, 13 to 5. (Senator Russell D. Feingold of Wisconsin was the third Democrat to support Judge Roberts.)
Since there are 55 Republicans in the Senate, Judge Alito would still appear to have an excellent chance at confirmation, if by a less decisive margin than the 78-to-22 vote that elevated Judge Roberts.
My program takes in an input text and spits it out the same text with the middle letters of every word greater than 3 letters all jumbled up. Somehow your brain can usually still read the words as long as the first and last letter remain in place, though you may get a headache after a while. I wanted to mix up all the appropriate letters with genuine randomness but the code hasn't quite come together yet, so as it stands the program takes the middle letters and reverses their order, which is pretty close and has the same effect. I'm going to keep trying with the randomizing function and post here if I figure it out. The input text here is my working Phys Comp Studio project proposal.
Input:
The Mechanical Synth is a sequencer which allows users to create and compose rhythmic electroacoustic music. Whereas every existing synthesizer, sequencer, and drum machine before it created sound electronically, using either 1) analog synthesis, in which sound is created by manipulating voltage in real time, or 2) prerecorded or preprogrammed digital sound, the Mechanical Synth creates sound by manipulating and amplifying the sounds of motors, solenoids, and virtually any other physical, mechanical object. In theory, the Mechanical Synth will be able to sequence any devices which you can plug into in: motors, cassette players, turntables, lights, TVs, chainsaws, nail guns, fireworks, spaceship launchers, and so forth, so long as you have the proper size relays and power supplies for each device. My main interest is in the sounds which come from motors grinding against, smacking, and otherwise manipulating sheet metal, broken glass, and other industrial detritus, and so that is the direction this project is going, at least in its initial stages.
Output:
The Macinahcel Stnyh is a secneuqer wcihh awolls uress to ctaere and csopmoe rimhtyhc eitsuocaortcelc misuc. Waerehs erevy enitsixg sezisehtnyr, secneuqer, and durm mnihcae brofee it cetaerd snuod ellacinortcely, unisg eehtir 1) aolang sisehtnys, in wcihh snuod is cetaerd by mnitalupinag vgatloe in rael tmie, or 2) pedrocererd or pemmargorperd datigil snuod, the Macinahcel Stnyh cetaers snuod by mnitalupinag and aniyfilpmg the sdnuos of mrotos, sdionelos, and vllautriy any oehtr pacisyhl, macinahcel ocejbt. In troehy, the Macinahcel Stnyh wlil be albe to scneuqee any decives wcihh you can pulg itno in: mrotos, cttessae preyals, telbatnrus, lthgis, TsV, cwasniahs, nial gnus, fkroweris, sihsecapp lrehcnuas, and so ftroh, so lnog as you hvae the peporr szie ryales and pewor seilppus for ecah dcivee. My mian iseretnt is in the sdnuos wcihh cmoe form mrotos gnidnirg asniagt, snikcamg, and osiwrehte mnitalupinag seeht matel, bekorn gsals, and oehtr iairtsudnl dutirtes, and so taht is the doitcerin tihs pcejort is gniog, at lsaet in its iaitinl segats.
UPDATE!!!
Version 2.0: This one takes the odd numbered middle letters and moves them forward one, and moves the even numbered ones back one. I like this one more because the results are a lot easier to read than the original.
Output:
The Mceahinacl Snyth is a sqeeucner wihch allwos uesrs to certae and cmoopse ryhhtimc eeltcorcauotsic msuic. Weheras eevry eixtsnig snyhtsezier, sqeeucner, and durm mcaihne bferoe it certaed suond eeltcorinaclly, uisng etiehr 1) aanolg snyhtseis, in wihch suond is certaed by mnapilutanig vloatge in rael tmie, or 2) pererocdred or perrpgoarmmed dgitial suond, the Mceahinacl Snyth certaes suond by mnapilutanig and apmilyfnig the suodns of mtoros, sloneiods, and vriutlaly any ohter pyhisacl, mceahinacl ojbcet. In tehroy, the Mceahinacl Snyth wlil be albe to sqeeucne any dvecies wihch you can pulg itno in: mtoros, csaestte paleyrs, trutnbaels, lgiths, TsV, cahniasws, nial gnus, friweroks, sapechsip luacnehrs, and so froth, so lnog as you hvae the porepr szie rleyas and pwoer spulpeis for ecah dvecie. My mian itnreset is in the suodns wihch cmoe form mtoros girdnnig aagnist, samkcnig, and ohtreiwse mnapilutanig sehet mteal, borekn galss, and ohter idnsurtail dteiruts, and so taht is the driceiton tihs porejct is giong, at laest in its iinital sategs.