Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evented speech controller #4

Merged
merged 12 commits into from
Jun 27, 2016
Merged

Evented speech controller #4

merged 12 commits into from
Jun 27, 2016

Conversation

samgiles
Copy link
Contributor

No description provided.

@@ -23,6 +25,20 @@ export default class MainController extends BaseController {
'reminders': remindersController,
};

const speechController = new SpeechController();
speechController.on(
Copy link
Contributor Author

@samgiles samgiles Jun 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the minute, I'm not certain of the best way to send these events to the correct UI (currently active controller) to display something - is there something simple we can do?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this block earlier in the constructor so that the speechController instance can be passed as an option to the controllers (just like mountNode). Then it'll be up to the controllers to do whatever they want with it.

.pipe(rename('js/polyfills/fetch.js'))
.pipe(rename('js/polyfills/fetch.js')),

gulp.src('./app/js/third_party/webrtc-adapter.js')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you place these files in the components folder instead third_party (see above with lodash and moment)?

@@ -0,0 +1,717 @@
/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way we're handling external dependencies is usually the following:

  • Install via npm (In this case, it's not published on npm so the syntax to use in package.json is something like "JsSpeechRecognizer": "github:dreamdom/JsSpeechRecognizer#master" (not sure if the master is required)
  • Copy the files you need from node_modules to app/js/components using the copy-app-common gulp task (see copy-app-dev and copy-app-production tasks if you need to copy different files on dev and prod environments)
  • Ideally load the file using es2015 modules, or via a <script> tag if not compatible

This avoid checking in external files into the tree.
Sorry for not having documenting this part.

Does it make sense to you?

@@ -68,6 +68,8 @@ gulp.task('copy-app-common', () => {
return merge(
gulp.src([
`${APP_ROOT}**`,
`${APP_ROOT}/data`,
`${APP_ROOT}/js/third_party`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is third_party folder still needed?

@@ -34,6 +50,10 @@ export default class MainController extends BaseController {
});
}

this[p.speechController].start().then(() => {
console.log('Speech controller started');
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in the future we want to wait until the speech controller has started before starting the app to prevent nasty race conditions.
I don't think that's likely to happen though. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is likely to happen as it is, as the only interface we expose is events right now - I think it's OK for now.

import JsSpeechRecognizer from 'components/jsspeechrecognizer';

export default class WakeWordRecogniser {
constructor(options={}) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spaces around =.

this[p.wakewordModelUrl] = '/data/wakeword_model.json';
}

_initializeSpeechRecognition() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all private methods, let's stick to the "symbols properties" pattern (See const p = Object.freeze({... above),

_startSpeechRecognition: Symbol('_startSpeechRecognition'),
_handleSpeechRecognitionEnd: Symbol('_handleSpeechRecognitionEnd'),
_parseIntent: Symbol('_parseIntent'),
_actOnIntent: Symbol('_actOnIntent'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to prefix these properties with _.

@gmarty
Copy link
Collaborator

gmarty commented Jun 27, 2016

r+ with the nits addressed. Good job!

@samgiles samgiles merged commit b691458 into master Jun 27, 2016
@samgiles samgiles deleted the wakeword branch June 27, 2016 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants