Package: metamoth
Metamoth is a Python package for parsing the metadata ofAudioMothfiles.
Check the full documentation athttps://metamoth.readthedocs.io.MotivationAudioMoth devices store valuable information in the audio file header. This
includes the device ID, the date and time of recording, gain
settings and battery state. The number of fields in the metadata is
growing as new features are added to the AudioMoth firmware.However, the metadata is not designed to be easily parsed in a programmatic
way. The data is stored as a string comment making it difficult to retrieve the
individual metadata fields. Additionally, the comment format is not well
documented and changes between AudioMoth firmware versions.This package helps byquicklyparsing the metadata and returning an
object containing the metadata.UsageThemetamothpackage provides a single function,parse_metadata,
which parses the metadata of an AudioMoth file and returns an object
containing the metadata.frommetamothimportparse_metadatametadata=parse_metadata('path/to/file')The extracted metadata can be accessed as attributes of the object, as shownduration=metadata.duration_spath=metadata.path# etc.Extracted MetadataThemetadatavariable is an object (of typeAMMetadata) containing the
metadata of the file.The extracted metadata contains:path: the path of the audio filefirmware_version: the firmware version of the AudioMoth that
recorded the file. Since the AudioMoth firmware version is not stored in the
recording, this is an estimate and may be incorrect.Media Informationduration_s: the duration of the file in seconds.samplerate_hz: the sample rate of the file in Hz.channels: the number of channels in the file.samples: the number of audio samples in the file.Data extracted from the AudioMoth comment string:datetime: the date and time of the file in adatetimeobject.timezone: the timezone of the file as atimezoneobject.audiomoth_id: the ID of the AudioMoth that recorded the file.battery_state_v: the battery state of the AudioMoth that recorded
the file in Volts.low_battery: a boolean indicating if the battery state is low.gain: the gain setting of the AudioMoth that recorded the file.comment: the full comment string in the WAV header.The following fields are only available for some AudioMoth firmware versions.
Nonetheless, they are always present in the metadata object, but may beNone.recording_state: the recording state of the AudioMoth that recorded
the file.temperature_c: the temperature of the AudioMoth in Celsius.amplitude_threshold: information concerning the wether an amplitude
threshold was used and the threshold value.frequency_filter: information concerning the wether a frequency filter
was used and the filter settings.deployment_id: the deployment ID as set by the user.external_microphone: a boolean indicating if an external microphone was
used.minimum_trigger_duration_s: the minimum trigger duration in seconds.frequency_trigger: information concerning the wether a frequency trigger
was used and the trigger settings.The following table shows the fields available for each AudioMoth firmware.versionrecording_statetemperature_camplitude_thresholdfrequency_filterdeployment_idexternal_microphoneminimum_trigger_duration_sfrequency_trigger1.0✖✖✖✖✖✖✖✖1.0.1✖✖✖✖✖✖✖✖1.1.0✖✖✖✖✖✖✖✖1.2.0✖✖✖✖✖✖✖✖1.2.1✔✖✖✖✖✖✖✖1.2.2✔✖✖✖✖✖✖✖1.3.0✔✖✖✖✖✖✖✖1.4.0✔✔✔✔✖✖✖✖1.4.1✔✔✔✔✖✖✖✖1.4.2✔✔✔✔✖✖✖✖1.4.3✔✔✔✔✖✖✖✖1.4.4✔✔✔✔✖✖✖✖1.5.0✔✔✔✔✔✔✖✖1.6.0✔✔✔✔✔✔✔✖1.7.0✔✔✔✔✔✔✔✖1.7.1✔✔✔✔✔✔✔✖1.8.0✔✔✔✔✔✔✔✔1.8.1✔✔✔✔✔✔✔✔Supported AudioMoth Firmware VersionsIn the table below you can find the supported AudioMoth firmware versions.Supported AudioMoth Firmware VersionsFirmwareSupported1.0.0✔1.0.1✔1.1.0✔1.2.0✔1.2.1✔1.2.2✔1.3.0✔1.4.0✔1.4.1✔1.4.2✔1.4.3✔1.4.4✔1.5.0✖1.6.0✔1.7.0✖1.7.1✖1.8.0✖1.8.1✖Support for newer firmware versions is planned, see theCONTRIBUTINGsection
if you want to help!PerformanceThemetamothpackage is designed to be fast. It extracts
all the required information from the first few bytes and avoids
loading the audio data. Thusmetamothparsing times are
not affected by the size of the audio file.The following table shows the parsing times ofmetamothcompared toexif tool.File Size (MB)metamoth (ms)exiftool (ms)Speedup7.30.084580~1000x440.085091.86~1000xInstallationThemetamothpackage can be installed usingpip:pip install metamothCheck the installation section of thedocumentationfor more
information.DocumentationThe documentation for themetamothpackage is available athttps://metamoth.readthedocs.io/en/latest/index.html.