Skip to content

Commit

Permalink
Small changes to Litoria nasuta recognizer
Browse files Browse the repository at this point in the history
Original hash: 908ca60
  • Loading branch information
towsey committed Dec 19, 2016
1 parent 2fe59d4 commit 6a487ac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
1 change: 0 additions & 1 deletion AudioAnalysis/AnalysisPrograms/AnalysisPrograms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@
<Compile Include="Recognizers\LitoriaFreycineti.cs" />
<Compile Include="Recognizers\LitoriaWatjulumensis.cs" />
<Compile Include="Recognizers\LitoriaBicolor.cs" />
<Compile Include="Recognizers\CriniaTinnula.cs" />
<Compile Include="Recognizers\UperoleiaLithomoda.cs" />
<Compile Include="Recognizers\PlatyplectrumOrnatum.cs" />
<Compile Include="Recognizers\LimnodynastesConvex.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static Arguments Dev()
//string configPath = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\RecognizerConfigFiles\Towsey.LitoriaBicolor.yml";

// Litoria caerulea Common green tree frog
//string recordingPath = @"G:\SensorNetworks\WavFiles\Frogs\LitoriaSpecies\Groote\EmeraldRiver_LitoriaCaerulea_20131223_220522.wav";
//string recordingPath = @"G:\SensorNetworks\WavFiles\Frogs\LitoriaSpecies\Groote\EmeraldRiver_LitoriaCaerulea_Lrothii_20131223_220522.wav";
//string outputPath = @"G:\SensorNetworks\Output\Frogs\TestOfRecognizers-2016November";
//string configPath = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\RecognizerConfigFiles\Towsey.LitoriaCaerulea.yml";

Expand All @@ -124,7 +124,8 @@ public static Arguments Dev()
//string configPath = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\Towsey.LitoriaFallax.yml";

// Litoria nasuta
string recordingPath = @"G:\SensorNetworks\WavFiles\Frogs\LitoriaSpecies\Groote\EmeraldRiver_LitoriaNasuta_Lbicolor_20131225_223700_30_0.wav";
string recordingPath = @"G:\SensorNetworks\WavFiles\Frogs\LitoriaSpecies\43 Litoria nasuta.mp3";
//string recordingPath = @"G:\SensorNetworks\WavFiles\Frogs\LitoriaSpecies\Groote\EmeraldRiver_LitoriaNasuta_Lbicolor_20131225_223700_30_0.wav";
string outputPath = @"G:\SensorNetworks\Output\Frogs\TestOfRecognizers-2016December";
string configPath = @"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\Towsey.LitoriaNasuta.yml";

Expand Down
21 changes: 14 additions & 7 deletions AudioAnalysis/AnalysisPrograms/Recognizers/LitoriaNasuta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ namespace AnalysisPrograms.Recognizers
/// This is a frog recognizer based on the "croak" or "honk" template.
/// The algorithm is similar to L.caerulea without the use of DCT to detect pulse trains.
/// It detects croak type calls by extracting three features: croak bandwidth, dominant frequency, croak duration.
/// It may also look for trains of repeated croaks and set a minimum pulse train duration.
///
/// The Stewart CD recording of L.nasuta exhibits a long pulse train - a DCT could be used to pickup the pulse train.
/// However in the recording from Karlina, L.nasuta does not exhibit a long pulse train.
///
/// To call this recognizer, the first command line argument must be "EventRecognizer".
/// Alternatively, this recognizer can be called via the MultiRecognizer.
Expand Down Expand Up @@ -170,6 +172,7 @@ public override RecognizerResults Recognize(AudioRecording recording, dynamic co
freqBinWidth, recognizerConfig.EventThreshold,
recognizerConfig.MinCroakDuration, recognizerConfig.MaxCroakDuration);
// add necesary info into the candidate events
double[,] hits = null;
var prunedEvents = new List<AcousticEvent>();
foreach (var ae in croakEvents)
{
Expand All @@ -181,6 +184,10 @@ public override RecognizerResults Recognize(AudioRecording recording, dynamic co
prunedEvents.Add(ae);
}


/*
// DO NOT LOOK FOR A PULSE TRAIN because recording from Karlina does not have one for L.nasuta.
// With those events that survive the above Array2Events process, we now extract a new array croak scores
croakScoreArray = AcousticEvent.ExtractScoreArrayFromEvents(prunedEvents, rowCount, recognizerConfig.AbbreviatedSpeciesName);
DataTools.Normalise(croakScoreArray, decibelThreshold, out normalisedScores, out normalisedThreshold);
Expand All @@ -190,7 +197,7 @@ public override RecognizerResults Recognize(AudioRecording recording, dynamic co
// Look for oscillations in the difference array
// duration of DCT in seconds
//croakScoreArray = DataTools.filterMovingAverageOdd(croakScoreArray, 5);
croakScoreArray = DataTools.filterMovingAverageOdd(croakScoreArray, 5);
double dctDuration = recognizerConfig.DctDuration;
// minimum acceptable value of a DCT coefficient
double dctThreshold = recognizerConfig.DctThreshold;
Expand All @@ -204,7 +211,6 @@ public override RecognizerResults Recognize(AudioRecording recording, dynamic co
var events = AcousticEvent.ConvertScoreArray2Events(dctScores, recognizerConfig.MinHz, recognizerConfig.MaxHz, sonogram.FramesPerSecond,
freqBinWidth, recognizerConfig.EventThreshold,
recognizerConfig.MinDuration, recognizerConfig.MaxDuration);
double[,] hits = null;
prunedEvents = new List<AcousticEvent>();
foreach (var ae in events)
{
Expand All @@ -215,16 +221,17 @@ public override RecognizerResults Recognize(AudioRecording recording, dynamic co
ae.Name = recognizerConfig.AbbreviatedSpeciesName;
prunedEvents.Add(ae);
}

var scoresPlot = new Plot(this.DisplayName, dctScores, recognizerConfig.EventThreshold);
*/

// do a recognizer test.
if (MainEntry.InDEBUG)
{
//TestTools.RecognizerScoresTest(scores, new FileInfo(recording.FilePath));
//AcousticEvent.TestToCompareEvents(prunedEvents, new FileInfo(recording.FilePath));
}

var scoresPlot = new Plot(this.DisplayName, dctScores, recognizerConfig.EventThreshold);
var scoresPlot = new Plot(this.DisplayName, croakScoreArray, recognizerConfig.EventThreshold);


if (true)
Expand All @@ -235,7 +242,7 @@ public override RecognizerResults Recognize(AudioRecording recording, dynamic co
DataTools.Normalise(amplitudeArray, decibelThreshold, out normalisedScores, out normalisedThreshold);
var amplPlot = new Plot("Band amplitude", normalisedScores, normalisedThreshold);

var debugPlots = new List<Plot> { scoresPlot, croakPlot2, croakPlot1, amplPlot };
var debugPlots = new List<Plot> { scoresPlot, /*croakPlot2,*/ croakPlot1, amplPlot };
// NOTE: This DrawDebugImage() method can be over-written in this class.
var debugImage = RecognizerBase.DrawDebugImage(sonogram, prunedEvents, debugPlots, hits);
var debugPath = FilenameHelpers.AnalysisResultPath(outputDirectory, recording.BaseName, SpeciesName, "png", "DebugSpectrogram");
Expand Down

0 comments on commit 6a487ac

Please sign in to comment.