/** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ // Load the binding import '@tensorflow/tfjs-node'; import chalk from 'chalk'; import * as ora from 'ora'; import * as Vorpal from 'vorpal'; import {AudioModel} from './audio_model'; import {Dataset} from './dataset'; import {WavFileFeatureExtractor} from './wav_file_feature_extractor'; // tslint:disable-next-line:no-any (global as any).AudioContext = class AudioContext {}; export const MODEL_SHAPE = [98, 40, 1]; export const labelsMsg = [ {type: 'input', name: 'labels', message: 'Enter labels (seperate by comma)'} ]; export const trainingMsg = [ {type: 'input', name: 'dir', message: 'Enter file directory'}, {type: 'input', name: 'label', message: 'Enter label for the directory'} ]; export const filenameMsg = [{ type: 'input', name: 'filename', message: 'Enter target filename for the model' }]; let model: AudioModel; let labels: string[]; const vorpal = new Vorpal(); let spinner = ora(); vorpal.command('create_model [labels...]') .alias('c') .description('create the audio model') .action((args, cb) => { console.log(args.labels); labels = args.labels as string[]; model = new AudioModel( MODEL_SHAPE, labels, new Dataset(labels.length), new WavFileFeatureExtractor()); cb(); }); vorpal .command( 'load_dataset all