Stage (11) Week Commencing (03.03.14)
Week (21)
Description
This blog is a roll over from Fridays session at University where I got help from my lecturer with the applescript code here is the outcome of that session. Applescript is an unfamiliar script for me and although it was indemnified at the start of the project as the most suitable process to output the voice script into I still needed help in exporting the app to do this.
To start with we had to alter the speech out put and make a bridge from applescript to processing the code looks like this.
set theVoices to {"Alex", "Bruce", "Fred", "Kathy", "Vicki", "Victoria"}
set thePath to (path to desktop as Unicode text) & "test.txt" // set path to desktop
set the_file to thePath //set file to the path
set the_text to (do shell script "cat " & quoted form of (POSIX path of the_file))
set the clipboard to the_text
set theSentence to the clipboard
log (theSentence)
say theSentence using ("Victoria") speaking rate 104 modulation 15 pitch 8
on readFile(unixPath)
return (do shell script "cat /" & unixPath)
end readFile
We set the path to desktop / test.txt outputted the code as an application and placed the application inside the data folder in Eliza and using processing we could send the output string from Eliza into the clipboard test.txt, then opening the bridge application and using the voice function in applescript make the script audible and outputs them to the pc speakers. I changed the modulation and speaking rate and pitch tomake it sound more melancholy.
CODE:
import codeanticode.eliza.*;
Eliza eliza;
PFont font;
String elizaResponse, humanResponse;
boolean showCursor;
int lastTime;
PImage bg1a;
void setup()
{
size(1200, 786);
bg1a=loadImage("bg1.jpg");
// When Eliza is initialized, a default script built into the
// library is loaded.
eliza = new Eliza(this);
// A new script can be loaded through the readScript function.
// It can take local as well as remote files.
eliza.readScript("scriptnew.txt");
//eliza.readScript("http://chayden.net/eliza/script");
// To go back to the default script, use this:
//eliza.readDefaultScript();
font = loadFont("Rockwell-24.vlw");
textFont(font);
printElizaIntro();
humanResponse = "";
showCursor = true;
lastTime = 0;
}
void draw()
{
image(bg1a,0,0,width,height);
//background(102);
fill(255);
stroke (111);
text(elizaResponse, 30, 450, width - 40, height);
fill(0);
int t = millis();
if (t - lastTime > 500)
{
showCursor = !showCursor;
lastTime = t;
}
if (showCursor) text(humanResponse + "_", 30, 600, width - 40, height);
else text(humanResponse, 30, 600, width - 40, height);
}
void keyPressed()
{
if ((key == ENTER) || (key == RETURN))
{
println(humanResponse);
//first scan for keywords
elizaResponse = eliza.processInput(humanResponse);
println(">> " + elizaResponse);
String[] out={elizaResponse};
saveStrings("/Users/macbookpro/Desktop/test.txt",out);
delay(10);
println(sketchPath+"/data/applescriptbridge.app");
open(sketchPath+"/data/applescriptbridge.app");
humanResponse = "";
}
else if ((key > 31) && (key != CODED))
{
// If the key is alphanumeric, add it to the String
humanResponse = humanResponse + key;
}
else if ((key == BACKSPACE) && (0 < humanResponse.length()))
{
char c = humanResponse.charAt(humanResponse.length() - 1);
humanResponse = humanResponse.substring(0, humanResponse.length() - 1);
}
}
void printElizaIntro()
{
String hello = "Hello.";
elizaResponse = hello + " " + eliza.processInput(hello);
println(">> " + elizaResponse);
}
Here is an example of the voice output from Processing to Applescript
Feelings
I am feeling very positive after the session with my tutor
am I really impressed with how the voice adds another level to the build and
I'm just really happy with it all at the moment.EvaluationGoing into uni and
having a one on one session with my tutor has been a massive boost what would
have taken me days to figure out was done and explained to me in a couple of
hours.
Analysis
My tutor made it clear to me how the process works and I
feel like I have a good grasp on what processes where implemented and how he
used them to create the outcome it made sense to me and I was happy
experimenting on my own with some of the functions in applescript.
Conclusion
In conclusion this session was extremely fun entering and
interesting I would not do anything different I did not feel like i had to make
loads of notes to make sense of the processes involved and I'm happy with the
outcome.
Action Plan
Next session I want to concentrate on
getting the mouth moving in time with the audio out-put however because of on
going finical issues I may struggle to get into uni for a couple of weeks.
No comments:
Post a Comment