Skip to content

Commit

Permalink
nocmig whitelist option implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattk70 committed Mar 17, 2022
1 parent d8c7db0 commit b708916
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 20 deletions.
4 changes: 2 additions & 2 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ html, body {
margin-top: -6px;
}

tr[class^="subrow"] {
tr[id^="sub"] {
font-size: 12px;
display: none

}

span[id^="filename_"] {
Expand Down
21 changes: 17 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@
Options
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item disabled" href="#" id="modelOptions">Model</a>
<ul class="nav navbar-nav">
<li class="dropdown-submenu">
<a href="#" class="dropdown-item" data-toggle="dropdown" role="button"
aria-haspopup="true" aria-expanded="false"> <span
class="nav-label">Model</span><span class="material-icons-two-tone arrow">navigate_next</span></a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#" id="useWhitelist">Use Whitelist
<span class='material-icons tick'>done</span>
</a></li>
</ul>
</li>

<li class="dropdown-submenu">
<a href="#" class="dropdown-item" data-toggle="dropdown" role="button"
aria-haspopup="true" aria-expanded="false"> <span
Expand Down Expand Up @@ -221,15 +231,18 @@ <h5 class="modal-title" id="feedbackModalLabel">Feedback</h5>

<!-- Result table -->
<div class="d-none p-0 border-0 overflow-auto tableFixHead" id="resultTableContainer">
<table class="table table-hover p-1">
<table id='results' class="table table-hover p-1">
<thead class="thead-dark">
<tr>
<th scope="col">#</th>
<th scope="col" class="text-right"></th>
<th scope="col">Timestamp</th>
<th scope="col">Common name</th>
<th scope="col">Scientific name</th>
<th scope="col" class="text-center">Confidence</th>
<th scope="col" class="text-center">Confidence <span
class="material-icons-two-tone align-bottom filter pointer">
filter_list
</span></th>
<th scope="col" class="text-center">Other IDs</th>
<th scope="col" class="specFeature text-center">Play</th>
<th scope="col" class="specFeature text-center">XC</th>
<th scope="col" class="specFeature text-center">Save</th>
Expand Down
37 changes: 29 additions & 8 deletions js/model.js

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,8 @@ window.onload = function () {
'colormap': 'inferno',
'timeline': true,
'minConfidence': 0.4,
'timeOfDay': false
'timeOfDay': false,
'useWhitelist': true
}
const {v4: uuidv4} = require('uuid');
config.UUID = uuidv4()
Expand All @@ -681,12 +682,18 @@ window.onload = function () {
}
config = JSON.parse(data)
//console.log('Successfully loaded UUID: ' + config.UUID)

ipcRenderer.send('load-model', {useWhitelist: config.useWhitelist})

if (!config.UUID) {
const {v4: uuidv4} = require('uuid');
config.UUID = uuidv4();
updatePrefs()
}
// Set menu option state
if (!config.useWhitelist) {
$('#useWhitelist .tick').hide()
}
if (!config.spectrogram) {
$('#loadSpectrogram .tick').hide()
}
Expand Down Expand Up @@ -885,6 +892,17 @@ $(document).on('click', '.speccolor', function (e) {
updatePrefs();
})

$(document).on('click', '#useWhitelist', function () {
if (config.useWhitelist) {
config.useWhitelist = false;
$('#useWhitelist .tick').hide()
} else {
config.useWhitelist = true;
$('#useWhitelist .tick').show()
}
ipcRenderer.send('load-model', {useWhitelist: config.useWhitelist});
updatePrefs();
})

$(document).on('click', '.timeline', function () {
if (wavesurfer.timeline && wavesurfer.timeline.wrapper !== null) {
Expand Down
18 changes: 13 additions & 5 deletions js/worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const {ipcRenderer} = require('electron');
const Model = require('./js/model.js');
const AudioBufferSlice = require('./js/AudioBufferSlice.js');
let appPath = '../256x384_model/';
//let appPath = '../256x384_model/';
let appPath = '../24000_v5/';
const lamejs = require("lamejstmp");
const ID3Writer = require('browser-id3-writer');
const path = require("path");
Expand All @@ -26,6 +27,7 @@ let predictWorker;
let predicting = false;
let selection = false;
let controller;
let useWhitelist = true;

ipcRenderer.on('file-load-request', async (event, arg) => {
const currentFile = arg.message;
Expand Down Expand Up @@ -114,6 +116,12 @@ ipcRenderer.on('save', async (event, arg) => {
await saveMP3(arg.start, arg.end, arg.filepath, arg.metadata)
})

ipcRenderer.on('load-model', async (event, arg) => {
console.log("model-loading, using whitelist: " + arg.useWhitelist)
useWhitelist = arg.useWhitelist;
await spawnWorker(useWhitelist)
})

ipcRenderer.on('post', async (event, arg) => {
await postMP3(arg.start, arg.end, arg.filepath, arg.metadata, arg.action)
})
Expand All @@ -126,7 +134,7 @@ ipcRenderer.on('abort', (event, arg) => {
if (predicting) {
//restart the worker
predictWorker.terminate()
spawnWorker()
spawnWorker(useWhitelist)
}
})

Expand Down Expand Up @@ -314,9 +322,9 @@ async function postMP3(start, end, filepath, metadata, action) {


/// Workers From the MDN example
async function spawnWorker() {
async function spawnWorker(useWhitelist) {
predictWorker = new Worker('./js/model.js');
predictWorker.postMessage(['load', appPath])
predictWorker.postMessage(['load', appPath, useWhitelist])

predictWorker.onmessage = (e) => {
const response = e.data;
Expand Down Expand Up @@ -351,7 +359,7 @@ async function spawnWorker() {
}
}

const worker = spawnWorker();




Expand Down
5 changes: 5 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ app.on('activate', () => {
}
});

ipcMain.on('load-model', async (event, arg) => {
const useWhitelist = arg.useWhitelist;
console.log('Main received load-model, using whitelist: ' + arg.useWhitelist)
workerWindow.webContents.send('load-model', {useWhitelist: useWhitelist});
});

ipcMain.on('file-load-request', async (event, arg) => {
const currentFile = arg.message;
Expand Down

0 comments on commit b708916

Please sign in to comment.