-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f534104
commit 9098f32
Showing
52 changed files
with
23,593 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015", "react"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# React + Node Starter | ||
_for [Heroku](https://www.heroku.com/) deployment_ | ||
|
||
## Overview | ||
|
||
This is a simple starter to get you up and running for React projects. This is intended to provide: | ||
|
||
* a lightweight webpack config (for development and production) | ||
* some helpful tooling for development workflow | ||
* a similar setup to what you'll see in the wild | ||
* Heroku-ready deployment setup | ||
|
||
## Running | ||
|
||
Install dependencies: `$ npm install` or `$ yarn` | ||
|
||
Fire up a development server: `$ npm run dev` | ||
|
||
Once the server is running, you can visit `http://localhost:3000/` | ||
|
||
## File layout | ||
|
||
- **Frontend React** | ||
- The top level application Container is in `frontend/containers/AppContainer.js` | ||
- CSS styles are in `frontend/assets/stylesheets/base.scss` | ||
- **Backend Express** | ||
- Entry point is `server.js` | ||
- API routes are under `backend/routes.js` | ||
- API routes are served under `http://localhost:3000/api` | ||
|
||
## Production Build | ||
|
||
To build your production assets and run the server: | ||
|
||
``` | ||
$ npm start | ||
``` | ||
|
||
## Deploying to Heroku | ||
|
||
This app is set up for deployment to Heroku! | ||
|
||
_This assumes you have already have a Heroku account and have the | ||
[Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli) installed_ | ||
|
||
``` | ||
$ heroku login | ||
$ heroku create -a name-of-your-app | ||
$ git push heroku master | ||
$ heroku open | ||
``` | ||
|
||
Heroku will follow the `build` command in your `package.json` and compile assets with `webpack.prod.config.js`. It runs the Express web server in `server.js`. | ||
|
||
If you're unfamiliar with Heroku deployment (or just need a refresher), they have a really great walkthrough [here](https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction). | ||
|
||
## Running on Glitch | ||
|
||
1. Go to https://glitch.com/edit/#!/horizons-hackathon-react and click | ||
`Remix this 🎤` | ||
1. Click `Show` at the top to preview your app! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
var SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1'); | ||
var fs = require('fs'); | ||
|
||
var speech_to_text = new SpeechToTextV1({ | ||
username: 'USER', | ||
password: 'PASS' | ||
}); | ||
|
||
// var params = { | ||
// // From file | ||
// audio: fs.createReadStream(file), | ||
// content_type: 'audio/flac', | ||
// word_confidence: true, | ||
// timestamps: true, | ||
// keywords: ['Like', 'You Know', 'Actually', 'I Mean', 'Sort of', 'Kind Of', 'Right', 'Uh', 'Um', 'Uhm'], | ||
// keywords_threshold: 0.5, | ||
// profanity_filter: true | ||
// }; | ||
|
||
// 'continuous', | ||
// 'max_alternatives', | ||
// 'word_alternatives_threshold', | ||
|
||
// speech_to_text.recognize(params, function(err, res) { | ||
// if (err) | ||
// console.log(err); | ||
// else | ||
// fs.writeFile('./data.json', JSON.stringify(res)); | ||
// var analytics = { | ||
// pauses: calculatePauses(res), | ||
// wordFrequency: wordCount(res), | ||
// speed: speakerSpeed(res), | ||
// clarity: calculateClarity(res), | ||
// duration: calculateDuration(res) | ||
// } | ||
// console.log(JSON.stringify(analytics, null, 2)); | ||
// }); | ||
|
||
// var res = JSON.parse(fs.readFileSync('./data.json')); | ||
// console.log(JSON.stringify(res, null, 2)); | ||
// | ||
// var analytics = { | ||
// pauses: calculatePauses(res), | ||
// wordFrequency: wordCount(res), | ||
// speed: speakerSpeed(res), | ||
// clarity: calculateClarity(res), | ||
// duration: calculateDuration(res), | ||
// cursingCount: cursingCount(res) | ||
// } | ||
// console.log(JSON.stringify(analytics, null, 2)); | ||
|
||
// // or streaming | ||
// fs.createReadStream('./resources/speech.wav') | ||
// .pipe(speech_to_text.createRecognizeStream({ content_type: 'audio/l16; rate=44100' })) | ||
// .pipe(fs.createWriteStream('./transcription.txt')); | ||
|
||
|
||
module.exports = function(file, cb) { | ||
|
||
var params = { | ||
// From file | ||
audio: fs.createReadStream(file), | ||
content_type: 'audio/wav', | ||
word_confidence: true, | ||
timestamps: true, | ||
keywords: ['Like', 'You Know', 'Actually', 'I Mean', 'Sort of', 'Kind Of', 'Right', 'Uh', 'Um', 'Uhm'], | ||
keywords_threshold: 0.5, | ||
profanity_filter: true | ||
}; | ||
|
||
speech_to_text.recognize(params, function(err, res) { | ||
if (err) | ||
console.log(err); | ||
else | ||
var analytics = { | ||
pauses: calculatePauses(res), | ||
wordFrequency: wordCount(res), | ||
speed: speakerSpeed(res), | ||
clarity: calculateClarity(res), | ||
duration: calculateDuration(res), | ||
cursingCount: cursingCount(res) | ||
} | ||
cb(analytics); | ||
}); | ||
|
||
function calculatePauses(res) { | ||
var pauses = []; | ||
var prevEnd = false; | ||
res.results.forEach(section => { | ||
section.alternatives.forEach(alternative => { | ||
alternative.timestamps.forEach((wordStats, index) => { | ||
if (wordStats[0] === '%HESITATION') { | ||
pauses.push(wordStats[2] - wordStats[1]); | ||
} | ||
if (index === alternative.timestamps.length - 1) { | ||
prevEnd = wordStats[2]; | ||
} | ||
if (index === 0 && prevEnd) { | ||
pauses.push(wordStats[1] - prevEnd); | ||
} | ||
}) | ||
}) | ||
}) | ||
return {data: pauses, preview: pauses.length}; | ||
} | ||
|
||
function wordCount(res) { | ||
var _ = require('underscore'); | ||
var wordCount = {}; | ||
var numberOfWords = 0; | ||
res.results.forEach(section => { | ||
section.alternatives.forEach(alternative => { | ||
alternative.timestamps.forEach(wordStats => { | ||
if (wordStats[0] !== '%HESITATION') { | ||
numberOfWords += 1; | ||
if(wordCount.hasOwnProperty(wordStats[0])) { | ||
wordCount[wordStats[0]] = wordCount[wordStats[0]] + 1; | ||
} else { | ||
wordCount[wordStats[0]] = 1; | ||
} | ||
} | ||
}) | ||
}) | ||
}) | ||
wordCount = _.chain(wordCount).pairs().sort((a, b) => { | ||
return b[1] - a[1]; | ||
}).value(); | ||
console.log('wordCount', wordCount); | ||
return {data: wordCount, preview: numberOfWords}; | ||
} | ||
|
||
function speakerSpeed(res) { | ||
var allWordObjs = []; | ||
res.results.forEach(section => { | ||
section.alternatives.forEach(alternative => { | ||
alternative.timestamps.forEach(wordStats => { | ||
if (wordStats[0] !== '%HESITATION') { | ||
allWordObjs.push(wordStats); | ||
} | ||
}) | ||
}) | ||
}) | ||
var wordFreq = []; | ||
var totalWordFreq = 0; | ||
var wordCount = Math.max(allWordObjs.length, 1); | ||
allWordObjs.forEach((wordObj, index) => { | ||
if (index < allWordObjs.length - 5) { | ||
var timeSpan = allWordObjs[index + 4][2] - wordObj[1]; | ||
var wordsPerMinute = 5 / timeSpan * 60; | ||
wordFreq.push(wordsPerMinute); | ||
totalWordFreq += wordsPerMinute; | ||
} | ||
}) | ||
var preview = totalWordFreq / wordCount; | ||
return {data: wordFreq, preview}; | ||
} | ||
|
||
function calculateClarity(res) { | ||
var clarityArray = []; | ||
var totalClarity = 0; | ||
var wordCount = 0; | ||
res.results.forEach(section => { | ||
section.alternatives.forEach(alternative => { | ||
alternative.word_confidence.forEach(wordStats => { | ||
clarityArray.push(wordStats[1]); | ||
totalClarity += wordStats[1]; | ||
wordCount += 1; | ||
}) | ||
}) | ||
}) | ||
var clarityAvg = totalClarity / Math.max(wordCount, 1) * 100 | ||
return {data: clarityArray, preview: clarityAvg}; | ||
} | ||
|
||
function calculateDuration(res) { | ||
var allWordObjs = []; | ||
res.results.forEach(section => { | ||
section.alternatives.forEach(alternative => { | ||
alternative.timestamps.forEach(wordStats => { | ||
if (wordStats[0] !== '%HESITATION') { | ||
allWordObjs.push(wordStats); | ||
} | ||
}) | ||
}) | ||
}) | ||
if (allWordObjs.length < 2) { | ||
return 0; | ||
} | ||
return allWordObjs[allWordObjs.length - 1][2] - allWordObjs[0][1]; | ||
} | ||
|
||
function cursingCount(res) { | ||
var badWords = require('bad-words'); | ||
var cursingCount = 0; | ||
var customFilter = new badWords({ placeHolder: '*'}); | ||
res.results.forEach(section => { | ||
section.alternatives.forEach(alternative => { | ||
alternative.timestamps.forEach(wordStats => { | ||
if (customFilter.clean(wordStats[0]).indexOf('*') !== -1) { | ||
cursingCount += 1; | ||
} | ||
}) | ||
}) | ||
}) | ||
return cursingCount; | ||
} | ||
|
||
// const ToneAnalyzerV3 = require('watson-developer-cloud/tone-analyzer/v3'); | ||
// | ||
// const tone_analyzer = new ToneAnalyzerV3({ | ||
// username: 'USER', | ||
// password: 'PASS', | ||
// version_date: '2016-10-19' | ||
// }); | ||
// | ||
// tone_analyzer.tone({ text: 'I am amazing and you suck' }, function(err, tone) { | ||
// if (err) { | ||
// console.log(err); | ||
// } else { | ||
// console.log('tone endpoint:'); | ||
// console.log(JSON.stringify(tone, null, 2)); | ||
// } | ||
// }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
var mongoose = require('mongoose'); | ||
var Schema = mongoose.Schema; | ||
|
||
var CompanySchema = new Schema ({ | ||
name: { | ||
type: String, | ||
required: true | ||
}, | ||
behavQ1: { | ||
type: String, | ||
required: true | ||
}, | ||
behavQ2: { | ||
type: String, | ||
required: true | ||
}, | ||
behavQ3: { | ||
type: String, | ||
required: true | ||
}, | ||
behavQ4: { | ||
type: String, | ||
required: true | ||
}, | ||
techQ1: { | ||
type: Schema.ObjectId, | ||
ref: 'Question' | ||
}, | ||
techQ2: { | ||
type: Schema.ObjectId, | ||
ref: 'Question' | ||
}, | ||
companyCulture: { | ||
type: String, | ||
required: true | ||
}, | ||
responsibilities: { | ||
type: String, | ||
required: true | ||
}, | ||
futureOfCompany: { | ||
type: String, | ||
required: true | ||
}, | ||
typicalDay: { | ||
type: String, | ||
required: true | ||
}, | ||
bestThingAboutCompany: { | ||
type: String, | ||
required: true | ||
}, | ||
lookingForInRole: { | ||
type: String, | ||
required: true | ||
} | ||
}) | ||
|
||
var QuestionSchema = new Schema ({ | ||
question: { | ||
type: String, | ||
required: true | ||
}, | ||
inputArr: { | ||
type: Array, | ||
required: true | ||
}, | ||
outputArr: { | ||
type: Array, | ||
required: true | ||
} | ||
}); | ||
|
||
var UserSchema = new Schema({ | ||
data: { | ||
type: Object, | ||
require: true | ||
}, | ||
}) | ||
|
||
|
||
var Company = mongoose.model('Company', CompanySchema) | ||
var Question = mongoose.model('Question', QuestionSchema) | ||
var User = mongoose.model('User', UserSchema) | ||
|
||
module.exports = { | ||
Company: Company, | ||
Question: Question, | ||
User: User | ||
}; |
Oops, something went wrong.