Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async load(url) {
if (url) {
const split = url.split("/");
const prefix = split.slice(0, split.length - 1).join("/");
const metadataJson = `${prefix}/metadata.json`;
this.model = tfjsSpeechCommands.create('BROWSER_FFT', undefined, url, metadataJson);
} else this.model = tfjsSpeechCommands.create('BROWSER_FFT');
await this.model.ensureModelLoaded();
this.allLabels = this.model.wordLabels();
}
async load(url) {
if (url) {
const split = url.split("/");
const prefix = split.slice(0, split.length - 1).join("/");
const metadataJson = `${prefix}/metadata.json`;
this.model = tfjsSpeechCommands.create('BROWSER_FFT', undefined, url, metadataJson);
} else this.model = tfjsSpeechCommands.create('BROWSER_FFT');
await this.model.ensureModelLoaded();
this.allLabels = this.model.wordLabels();
}
constructor(private readonly router: Router) {
this.recognizer = speechCommands.create('BROWSER_FFT');
this.recognizer.ensureModelLoaded().then(() => {
this.wordLabels = this.recognizer.wordLabels();
this.whitelistIndex = this.wordLabels.map((value, index) => {
if (this.whitelistWords.indexOf(value) !== -1) {
return index;
}
}).filter(value => value !== undefined);
});
}