Skip to content

Commit

Permalink
Added more explanation to why context & snr stay disabled in birdNET
Browse files Browse the repository at this point in the history
Also fixed audio filter activation on change in settings
  • Loading branch information
Mattk70 committed Jan 31, 2024
1 parent b1712f4 commit 0a94992
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
20 changes: 11 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ <h5>Saved Records</h5>
<span class="circle"
title="Use your preferred language for birds' common names">?</span>
<div class="row pe-3">
<label class="col-auto ps-0" for="list-to-use">Language:</label>
<label class="col-auto ps-0 pe-1 fs-6" for="list-to-use">Locale:</label>
<select class="form-select col" id="locale">
<option value="en_uk">English (UK)</option>
<option value="en">English (US)</option>
Expand Down Expand Up @@ -327,6 +327,7 @@ <h5>Saved Records</h5>
aria-label="species frequency threshold" aria-describedby="species-frequency-threshold">
<span class="circle"
title="Set the minimum eBird checklist frequency for a bird to be included">?</span>

</div>
</div>
</div>
Expand Down Expand Up @@ -368,11 +369,11 @@ <h5>Saved Records</h5>
</div>
<div class="col-6 ps-0">
<fieldset class="border rounded m-2 p-1 bg-warning">
<legend style="font-size: large"><span
<legend class="bg-warning pb-2" style="font-size: large"><span
class="material-symbols-outlined align-middle"
title="Experimental">science</span> Experimental features
</legend>
<div class="form-group rounded p-2 mb-2 bg-light">
<div class="chirpity-only form-group rounded p-2 mb-2 bg-light">
<div class="form-check form-switch">

<input class="form-check-input" type="checkbox"
Expand All @@ -381,13 +382,15 @@ <h5>Saved Records</h5>
Context mode
</label>
<span class="circle"
title="When enabled, context mode adapts predictions by analyzing the surrounding context.">?</span>
title="When enabled, context mode adapts predictions by analyzing the surrounding context.
Not available in the BirdNET model">?</span>
</div>
</div>
<div class="col me-auto">
<div class="chirpity-only me-auto">
<div class="form-group rounded p-2 mb-2 bg-light">
<span class="circle"
title="Ignore samples with just background noise. Value is the minimum signal strength to look at.">?</span>
title="Ignore samples with just background noise. Value is the minimum signal strength to look at.
Not available in the BirdNET model">?</span>
<label for="snrValue" class="form-label">
SNR filter:
</label>
Expand All @@ -400,9 +403,8 @@ <h5>Saved Records</h5>
</div>
</div>
</div>

</div>
<div class="col me-auto">
<div class="me-auto">
<div class="form-group rounded p-2 mb-2 bg-light">
<span class="circle"
title="When enabled, removes low frequency noise below the threshold.">?</span>
Expand Down Expand Up @@ -617,7 +619,7 @@ <h5>Saved Records</h5>
</div>
</div>
<div class="col"><span class="circle" title="'Pad' adds 2 seconds before and after a selection to the exported audio.
'Fade' adds a 1 second fade effect to the start and end of the audio">?</span></div>
'Fade' adds a 1 second fade effect to the start and end of the audio">?</span></div>
</div>
</div>
</div>
Expand Down
15 changes: 15 additions & 0 deletions js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1439,10 +1439,15 @@ window.onload = async () => {
audioFade.disabled = !audioPadding.checked;
audioDownmix.checked = config.audio.downmix;
setNocmig(config.detect.nocmig);
//const chirpityOnly = document.querySelectorAll('.chirpity-only');
if (config.model !== 'v2.4'){
// show chirpity-only features
//chirpityOnly.forEach(element => element.classList.remove('d-none'));
contextAware.checked = config.detect.contextAware
SNRSlider.disabled = false;
} else {
// hide chirpity-only features
//chirpityOnly.forEach(element => element.classList.add('d-none'));
contextAware.checked = false;
contextAware.disabed = true;
config.detect.contextAware = false;
Expand All @@ -1457,6 +1462,8 @@ window.onload = async () => {
if (config.backend === 'webgl') {
SNRSlider.disabled = true;
};


// Filters
HPThreshold.textContent = config.filters.highPassFrequency + 'Hz';
HPSlider.value = config.filters.highPassFrequency;
Expand Down Expand Up @@ -2235,13 +2242,18 @@ const loadModel = ({clearCache = true} = {}) => {
const modelToUse = document.getElementById('model-to-use');
modelToUse.addEventListener('change', function (e) {
config.model = e.target.value;
const chirpityOnly = document.querySelectorAll('.chirpity-only');
if (config.model === 'v2.4') {
contextAware.checked = false;
// hide chirpity-only features
//chirpityOnly.forEach(element => element.classList.add('d-none'));
contextAware.disabed = true;
config.detect.contextAware = false;
SNRSlider.disabled = true;
config.filters.SNR = 0;
} else {
// show chirpity-only features
//chirpityOnly.forEach(element => element.classList.remove('d-none'));
contextAware.disabed = false;
SNRSlider.disabled = false;
}
Expand Down Expand Up @@ -3972,6 +3984,7 @@ SNRSlider.addEventListener('change', handleSNRchange);

const handleHPchange = () => {
config.filters.highPassFrequency = HPSlider.valueAsNumber;
config.filters.active || toggleFilters();
updatePrefs();
worker.postMessage({ action: 'update-state', filters: { highPassFrequency: config.filters.highPassFrequency } })
showFilterEffect();
Expand All @@ -3988,6 +4001,7 @@ HPSlider.addEventListener('change', handleHPchange);
// Low shelf threshold
const handleLowShelfchange = () => {
config.filters.lowShelfFrequency = LowShelfSlider.valueAsNumber;
config.filters.active || toggleFilters();
updatePrefs();
worker.postMessage({ action: 'update-state', filters: { lowShelfFrequency: config.filters.lowShelfFrequency } })
showFilterEffect();
Expand All @@ -4004,6 +4018,7 @@ LowShelfSlider.addEventListener('change', handleLowShelfchange);
// Low shelf gain
const handleAttenuationchange = () => {
config.filters.lowShelfAttenuation = - lowShelfAttenuation.valueAsNumber;
config.filters.active = true;
updatePrefs();
worker.postMessage({ action: 'update-state', filters: { lowShelfAttenuation: config.filters.lowShelfAttenuation } })
showFilterEffect();
Expand Down

0 comments on commit 0a94992

Please sign in to comment.