Skip to content

Commit

Permalink
Wrote out directive msgs and addressed a few formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ohjay committed Oct 15, 2015
1 parent 1e7f5da commit d121b3f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
6 changes: 4 additions & 2 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ h1 {
font-weight: normal;
}

p, #log, #final-word {
p, #final-word {
font-family: 'Roboto Condensed';
color: #ead06c;
font-size: 18px;
font-size: 21px;
text-align: center;
z-index: 1;
margin-left: 7.5px;
}

span {
Expand All @@ -34,6 +35,7 @@ span {
font-family: 'Roboto Condensed';
color: #ead06c;
font-size: 70px;
margin-left: 10px; /* otherwise the cursor makes it look a little off-center */
}

#drake {
Expand Down
19 changes: 13 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>The Rap App</title>

<link rel="stylesheet" href="css/style.css" />
<link href=' http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>
</head>

<body style="background-color: #000000">
Expand All @@ -32,8 +32,7 @@
</div>

<p>
Hey, welcome to the Rap App! I'm just testing out some speech recognition stuff right now.
<div id="log"></div>
<span id="directive">Hey, welcome to the Rap App! To play some sick beats, click START.</span>
<div id="final-word"></div>
<div style="text-align: center">
<span id="typed"></span>
Expand Down Expand Up @@ -68,15 +67,23 @@
// Initialize the MP3 player after the page loads all of the HTML
window.addEventListener("load", initMP3Player, false);

var timesStarted = 0;
function initMP3Player() {
startButton = document.getElementById("start");
startButton.addEventListener("click", start);

function start() {
if (audio.paused) {
if (++timesStarted > 2) {
$('#directive').text("You know what to do, bro. Show 'em what you've got.");
} else {
$('#directive').text("You best be spitting some savage lines right now.");
}

audio.play();
startButton.innerHTML = '<button type="button">Stop</button>';
} else {
$('#directive').text("What!? Don't be quitting on me, man.");
audio.pause();
startButton.innerHTML = '<button type="button">Start</button>';
}
Expand Down Expand Up @@ -176,20 +183,20 @@
var r = new webkitSpeechRecognition();

r.onresult = function(event) {
/* Only the final word */
// Only the final word
if (event.results[event.results.length - 1].isFinal) {
var finalPhrase = event.results[event.results.length - 1][0].transcript;
var finalWord = finalPhrase.substring(finalPhrase.lastIndexOf(' ') + 1);

document.getElementById("final-word").innerHTML = "You said: " + finalPhrase;
rhymes = ["Rhymes: " + lookup(finalWord).toString() + "^2000"];
rhymes = ["Rhymes: " + lookup(finalWord).toString() + "^3000"];
updated = true;
r.stop();
}
};

r.onerror = function(event) {
$('#log').text('[ERROR]: ' + event.error);
$('#directive').text('[SPEECH RECOGNITION ERROR] : ' + event.error);
};

r.onend = function() {
Expand Down
1 change: 0 additions & 1 deletion js/mobypron.js
Original file line number Diff line number Diff line change
Expand Up @@ -35463,7 +35463,6 @@ var mobypron = {
mantle: "'m/&/nt/-/l",
mantlet: "'m/&/ntl/I/t",
mantling: "'m/&/ntl/I//N/",
Manto: "'m/&/nt/oU/",
mantra: "'m/&/ntr/@/",
mantram: "'m/&/ntr/@/m",
mantrap: "'m/&/ntr/&/p",
Expand Down
8 changes: 4 additions & 4 deletions mobypron/read_and_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
data = myfile.read().replace('\n', '')

with open("mobypron_new.txt") as myfile2:
content = myfile2.readlines()
content = myfile2.readlines()

for line in content:
if (line.split(":")[0][2:]).upper() in data:
target.write(str(line) + '\n')
print(line)
if (line.split(":")[0][2:]).upper() in data:
target.write(str(line) + '\n')
print(line)

rap_list.close()
target.close()

0 comments on commit d121b3f

Please sign in to comment.