summaryrefslogtreecommitdiff
path: root/app/client/modules/samplernn/samplernn.tasks.js
blob: 91b4dcc814ec5c1d1e56ffa9c2cc8a0430104473 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import uuidv1 from 'uuid/v1'

import socket from '../../socket'
import types from '../../types'

import actions from '../../actions'

export const train_task = (dataset, folder_id, epochs=1) => dispatch => {
  const task = {
    module: 'samplernn',
    activity: 'train',
    dataset: dataset.name,
    epoch: dataset.checkpoints.length ? dataset.checkpoints[0].epoch || 0 : 0,
    epochs: epochs,
    folder_id: folder_id,
    opt: {
      sample_length: 44100 * 5,
      n_samples: 6,
      keep_old_checkpoints: false,
    }
  }
  console.log(task)
  return actions.queue.add_task(task)
}
export const generate_task = (dataset, folder_id, sample_length=5, n_samples=6, epoch=0) => dispatch => {
  const task = {
    module: 'samplernn',
    activity: 'generate',
    dataset: dataset.name,
    epoch: epoch || (dataset.checkpoints.length && dataset.checkpoints[0].epoch) || 0,
    folder_id: folder_id,
    opt: {
      sample_length: Math.round(44100 * sample_length),
      n_samples,
    }
  }
  console.log(task)
  return actions.queue.add_task(task)
}
export const fetch_task = (url, folder_id, file_id, dataset) => dispatch => {
  if (! url) return console.log('input file inaccessible (no url)')
  const task = {
    module: 'samplernn',
    activity: 'fetch',
    dataset: dataset,
    folder_id: folder_id,
    opt: {
      url,
      file_id,
      dataset,
    }
  }
  return actions.queue.add_task(task)
}
export const log_task = (dataset) => dispatch => {
  const task = {
    module: 'samplernn',
    activity: 'log',
    dataset: dataset.name,
  }
  return actions.queue.add_task(task)
}
export const clear_cache_task = (dataset) => dispatch => {
  const task = {
    module: 'samplernn',
    activity: 'clear_cache',
    dataset: dataset.name,
  }
  return actions.queue.add_task(task)
}