diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-04 01:11:58 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-04 01:11:58 +0200 |
| commit | 5dece5cd3e1271b3af6efb5e0179a571ebdef4ef (patch) | |
| tree | aecde9fc264b04c70d42a1eb477e9929a6acda3f /app/client/modules/samplernn/samplernn.actions.js | |
| parent | c34ecb4aacb1d27913088ff2b4546f1504d8dd86 (diff) | |
actually importing stuff
Diffstat (limited to 'app/client/modules/samplernn/samplernn.actions.js')
| -rw-r--r-- | app/client/modules/samplernn/samplernn.actions.js | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/app/client/modules/samplernn/samplernn.actions.js b/app/client/modules/samplernn/samplernn.actions.js index 70a8a30..f0e835e 100644 --- a/app/client/modules/samplernn/samplernn.actions.js +++ b/app/client/modules/samplernn/samplernn.actions.js @@ -76,6 +76,7 @@ export const load_directories = (id) => (dispatch) => { file.epoch = file.epoch || pair[1] }) + // also show the various flat audio files we have, in the input area.. const flatDatasets = datasets.filter(s => s.name.match(/(wav|aiff?|flac|mp3)$/) && !s.dir) const builtDatasets = datasets.filter(s => s.dir) builtDatasets.forEach(dir => { @@ -117,13 +118,25 @@ export const load_directories = (id) => (dispatch) => { file.persisted = false file.epoch = parseInt(file.epoch || pair[1].replace(/^\D+/, '')) || 0 dataset.epoch = Math.max(file.epoch, dataset.epoch || 0) - dataset.output.push(file) + // here check if the file exists in dataset, if so just check that it's persisted + const found = dataset.output.some(f => { + // if (f.name === + if (f.name === file.name) { + f.persisted = true + return true + } + return false + }) + if (! found) { + dataset.output.push(file) + } }) dispatch({ type: types.samplernn.init, data: { folderLookup, + datasetLookup, folders, files, checkpoints, builtDatasets, @@ -167,6 +180,47 @@ export const load_loss = () => dispatch => { }) } +export const import_files = (state, datasetLookup) => (dispatch) => { + const { selected, folder, url_base, import_action } = state + const names = Object.keys(selected).filter(k => selected[k]) + let promises + switch (import_action) { + case 'Hotlink': + // in this case, create a new file for each file we see. + promises = names.reduce((a,name) => { + return datasetLookup[name].output.map(file => { + const partz = file.name.split('.') + const ext = partz.pop() + return actions.file.create({ + folder_id: folder, + name: file.name, + url: url_base + file.name, + mime: 'audio/' + ext, + epoch: file.epoch, + size: file.size, + module: 'samplernn', + dataset: name, + activity: 'train', + datatype: 'audio', + generated: true, + created_at: new Date(file.date), + updated_at: new Date(file.date), + }) + }).concat(a) + }, []) + break + case 'Upload': + break + default: + break + } + Promise.all(promises).then(data => { + console.log(data) + }).catch(e => { + console.error(e) + }) +} + export const set_folder = (folder) => { types.samplernn.set_folder, folder } export const fetch_url = (url) => (dispatch) => { |
