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
Speech-commands model: Add inference code for browser-native FFT #58
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 11 of 11 files at r1.
Reviewable status: 0 of 1 approvals obtained (waiting on @nsthorat, @dsmilkov, and @pyu10055)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @nsthorat, @dsmilkov, and @pyu10055)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! I left a few comments post-submit. Sorry for the delay on this!
Reviewed 5 of 11 files at r1.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @caisq, @nsthorat, and @dsmilkov)
speech-commands/src/browser_fft_extractor.ts, line 47 at r1 (raw file):
* dimension. * The return value is assumed to be whether a flag for whether the * refractory period should initiate, e.g., when a word is recognized.
unfamiliar with this word: refractory. Is there a more common alternative?
speech-commands/src/browser_fft_extractor.ts, line 207 at r1 (raw file):
} async stop(): Promise<void> {
Any reason why stop() needs to be async? I see no await/async call inside? Do you foresee future other implementations of FeatureExtractor being async?
speech-commands/src/browser_fft_extractor.ts, line 223 at r1 (raw file):
} getFeatures(): Float32Array[] {
who else implements FeaturesExtractor? Can we change the interface to fit this need, instead of having to throw error on a method that no one implements?
speech-commands/src/browser_fft_extractor.ts, line 270 at r1 (raw file):
* and suppression time. */ export class Tracker {
keep this class private?
speech-commands/src/browser_fft_extractor.ts, line 280 at r1 (raw file):
* * @param period The event-firing period, in number of frames. * @param suppressionPeriod The suppression period, in number of frames.
Will you use this suppressionPeriod soon? Let's error on the side of less code/config/logic until we need it.
speech-commands/src/types.ts, line 27 at r1 (raw file):
export type RecognizerCallback = (result: SpeechCommandRecognizerResult) => Promise<void>;
any reason why the user-provided recognizerCallback need to return a promise? Let's just do void
speech-commands/src/types.ts, line 66 at r1 (raw file):
// Getter for word labels. wordLabels(): string[];
you can mark it as get wordLabels() { ... }
speech-commands/src/types.ts, line 69 at r1 (raw file):
// Get the required number of frames. params(): RecognizerConfigParams;
same here.
speech-commands/src/types.ts, line 129 at r1 (raw file):
} export interface RecognizerConfigParams {
just call it RecognizerConfig to be consistent with other config interfaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @caisq and @nsthorat)
speech-commands/src/browser_fft_extractor.ts, line 47 at r1 (raw file):
Previously, dsmilkov (Daniel Smilkov) wrote…
unfamiliar with this word: refractory. Is there a more common alternative?
Changing it to "suppression" in #61
speech-commands/src/browser_fft_extractor.ts, line 207 at r1 (raw file):
Previously, dsmilkov (Daniel Smilkov) wrote…
Any reason why stop() needs to be async? I see no await/async call inside? Do you foresee future other implementations of FeatureExtractor being async?
Yes, this is because stop() may call some WebAudio functions that are actually async.
speech-commands/src/browser_fft_extractor.ts, line 223 at r1 (raw file):
Previously, dsmilkov (Daniel Smilkov) wrote…
who else implements FeaturesExtractor? Can we change the interface to fit this need, instead of having to throw error on a method that no one implements?
@pyu10055 may use this in later PRs.
speech-commands/src/browser_fft_extractor.ts, line 270 at r1 (raw file):
Previously, dsmilkov (Daniel Smilkov) wrote…
keep this class private?
This is exported for testing. It is not included in index.ts and is hence effectively private (from public API point of view)
speech-commands/src/browser_fft_extractor.ts, line 280 at r1 (raw file):
Previously, dsmilkov (Daniel Smilkov) wrote…
Will you use this suppressionPeriod soon? Let's error on the side of less code/config/logic until we need it.
Yes, see #61.
speech-commands/src/types.ts, line 27 at r1 (raw file):
Previously, dsmilkov (Daniel Smilkov) wrote…
any reason why the user-provided recognizerCallback need to return a promise? Let's just do void
The callback can potentially be async. Type definition doesn't allow me to specify "async" here, but specifying the return type of Promise suffices.
speech-commands/src/types.ts, line 66 at r1 (raw file):
Previously, dsmilkov (Daniel Smilkov) wrote…
you can mark it as
get wordLabels() { ... }
I don't think TypeScript interfaces allow you to use get
in it.
speech-commands/src/types.ts, line 129 at r1 (raw file):
Previously, dsmilkov (Daniel Smilkov) wrote…
just call it RecognizerConfig to be consistent with other config interfaces.
Done in #61
This change is