diff --git a/README.md b/README.md index ea54a1c6..66d210c2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Chirpity-Electron +# Chirpity Electron app to identify the calls of nocturnal migrants from audio files. @@ -13,6 +13,11 @@ First, clone the project and install all dependencies: ``` git clone https://github.com/Mattk70/Chirpity-Electron cd Chirpity-Electron +``` + +Chirpity depends on Node.js, follow the link for the download and installation instructions. +Once installed, run: +``` npm install ``` @@ -24,21 +29,21 @@ npm start ## Development setup -Setting up the project requires Node.js, which we need to install first. -After that, we can initialize the source directory with: + +Initialize the source directory with: ``` npm init ``` -Now, we need to install project dependencoies with: +Now, install project dependencoies with: ``` npm install --save-dev ``` -After that, we can build a windows msi installer with: +After that, build a windows msi installer with: ``` npm run export diff --git a/img/icon/chirpity_logo2.png b/img/icon/chirpity_logo2.png new file mode 100644 index 00000000..35213f58 Binary files /dev/null and b/img/icon/chirpity_logo2.png differ diff --git a/js/ui.js b/js/ui.js index 84f838a3..58ed7457 100644 --- a/js/ui.js +++ b/js/ui.js @@ -1476,7 +1476,7 @@ window.onload = async () => { speciesThreshold: config.speciesThreshold }); loadModel(); - worker.postMessage({ action: 'clear-cache' }) + //worker.postMessage({ action: 'clear-cache' }) // New users - show the tour if (!config.seenTour) { setTimeout(prepTour, 2000) @@ -2191,7 +2191,7 @@ speciesThreshold.addEventListener('change', () =>{ worker.postMessage({ action: 'update-list', list: config.list }) }) -const loadModel = () => { +const loadModel = ({clearCache = true} = {}) => { t0_warmup = Date.now(); worker.postMessage({ action: 'load-model', @@ -2200,7 +2200,8 @@ const loadModel = () => { batchSize: config[config.backend].batchSize, warmup: config.warmup, threads: config[config.backend].threads, - backend: config.backend + backend: config.backend, + clearCache: clearCache }); } @@ -2253,7 +2254,7 @@ const handleBackendChange = (e) => { updatePrefs(); // restart wavesurfer regions to set new maxLength initRegion(); - loadModel(); + loadModel({clearCache: false}); } const backend = document.getElementsByName('backend'); @@ -3472,7 +3473,7 @@ batchSizeSlider.addEventListener('input', (e) => { }) batchSizeSlider.addEventListener('change', (e) => { config[config.backend].batchSize = BATCH_SIZE_LIST[e.target.value]; - loadModel(); + loadModel({clearCache: false}); updatePrefs(); // Reset region maxLength initRegion(); @@ -3960,7 +3961,7 @@ ThreadSlider.addEventListener('input', () => { }); ThreadSlider.addEventListener('change', () => { config[config.backend].threads = ThreadSlider.valueAsNumber; - loadModel(); + loadModel({clearCache: false}); updatePrefs(); }); diff --git a/js/worker.js b/js/worker.js index 7ac82179..89d5b4e4 100644 --- a/js/worker.js +++ b/js/worker.js @@ -204,7 +204,6 @@ const clearCache = async (fileCache, sizeLimitInGB) => { const requiredSpace = sizeLimitInGB * 1024 ** 3; // If Full, clear at least 25% of cache, so we're not doing this too frequently if (size > requiredSpace) { - // while (size > requiredSpace && canBeRemovedFromCache.length) { while (canBeRemovedFromCache.length > 1) { const file = canBeRemovedFromCache.shift(); const proxy = metadata[file].proxy; @@ -251,9 +250,10 @@ break; case "chart": {await onChartRequest(args); break; } - case "clear-cache": {CACHE_LOCATION = p.join(TEMP, "chirpity"); -fs.existsSync(CACHE_LOCATION) || fs.mkdirSync(CACHE_LOCATION); -await clearCache(CACHE_LOCATION, 0); + case "clear-cache": { + CACHE_LOCATION = p.join(TEMP, "chirpity"); + fs.existsSync(CACHE_LOCATION) || fs.mkdirSync(CACHE_LOCATION); + await clearCache(CACHE_LOCATION, 0); break; } case "convert-dataset": {convertSpecsFromExistingSpecs(); @@ -314,7 +314,12 @@ break; event: "spawning" }); sampleRate = args.model === "v2.4" ? 48_000 : 24_000; - + // Since models have different sample rates, we need to clear the cache of + // files that have been resampled for a different model, and reset metadata + CACHE_LOCATION = p.join(TEMP, "chirpity"); + DEBUG && console.log('clear cache', args.clearCache, 'location', CACHE_LOCATION) + args.clearCache && ipcRenderer.invoke('clear-cache', CACHE_LOCATION) + metadata = {} BATCH_SIZE = parseInt(args.batchSize); setAudioContext(sampleRate); memoryDB = undefined; diff --git a/main.js b/main.js index e732a0ac..c46c16b5 100644 --- a/main.js +++ b/main.js @@ -489,3 +489,9 @@ ipcMain.handle('saveFile', (event, arg) => { }); mainWindow.webContents.send('saveFile', { message: 'file saved!' }); }); + +ipcMain.handle('clear-cache', (event, filePath) => { + // console.log("cache location:", event, filePath); + // return + clearCache(filePath) +}) \ No newline at end of file diff --git a/package.json b/package.json index 9f175595..bbc55100 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chirpity", - "version": "0.11.0", + "version": "0.11.1", "description": "Chirpity Nocmig", "main": "main.js", "scripts": { diff --git a/preload.js b/preload.js index 6bcc1e01..20b943da 100644 --- a/preload.js +++ b/preload.js @@ -51,7 +51,7 @@ contextBridge.exposeInMainWorld('electron', { getPath: () => ipcRenderer.invoke('getPath'), getTemp: () => ipcRenderer.invoke('getTemp'), getVersion: () => ipcRenderer.invoke('getVersion'), - getAudio: () => ipcRenderer.invoke('getAudio'), + getAudio: () => ipcRenderer.invoke('getAudio') }); contextBridge.exposeInMainWorld('module', {