britekit 0.1.2__py3-none-any.whl → 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of britekit might be problematic. Click here for more details.

Files changed (47) hide show
  1. britekit/__about__.py +1 -1
  2. britekit/__init__.py +6 -2
  3. britekit/cli.py +6 -1
  4. britekit/commands/__init__.py +2 -1
  5. britekit/commands/_analyze.py +40 -12
  6. britekit/commands/_audioset.py +8 -8
  7. britekit/commands/_calibrate.py +8 -8
  8. britekit/commands/_ckpt_ops.py +6 -6
  9. britekit/commands/_db_add.py +12 -12
  10. britekit/commands/_db_delete.py +15 -15
  11. britekit/commands/_embed.py +4 -4
  12. britekit/commands/_ensemble.py +7 -7
  13. britekit/commands/_extract.py +158 -19
  14. britekit/commands/_find_dup.py +5 -5
  15. britekit/commands/_inat.py +4 -4
  16. britekit/commands/_init.py +1 -1
  17. britekit/commands/_pickle.py +13 -7
  18. britekit/commands/_plot.py +26 -26
  19. britekit/commands/_reextract.py +6 -6
  20. britekit/commands/_reports.py +41 -27
  21. britekit/commands/_search.py +12 -12
  22. britekit/commands/_train.py +6 -6
  23. britekit/commands/_tune.py +13 -13
  24. britekit/commands/_wav2mp3.py +2 -2
  25. britekit/commands/_xeno.py +7 -7
  26. britekit/commands/_youtube.py +3 -3
  27. britekit/core/analyzer.py +43 -13
  28. britekit/core/audio.py +14 -14
  29. britekit/core/augmentation.py +24 -0
  30. britekit/core/data_module.py +2 -2
  31. britekit/core/dataset.py +1 -4
  32. britekit/core/plot.py +8 -8
  33. britekit/core/predictor.py +51 -23
  34. britekit/core/reextractor.py +6 -6
  35. britekit/core/util.py +44 -8
  36. britekit/occurrence_db/occurrence_data_provider.py +13 -13
  37. britekit/testing/{per_minute_tester.py → per_block_tester.py} +39 -36
  38. britekit/testing/per_recording_tester.py +2 -2
  39. britekit/training_db/extractor.py +65 -30
  40. britekit/training_db/training_data_provider.py +1 -1
  41. britekit/training_db/training_db.py +97 -100
  42. britekit-0.1.5.dist-info/METADATA +299 -0
  43. {britekit-0.1.2.dist-info → britekit-0.1.5.dist-info}/RECORD +46 -46
  44. britekit-0.1.2.dist-info/METADATA +0 -290
  45. {britekit-0.1.2.dist-info → britekit-0.1.5.dist-info}/WHEEL +0 -0
  46. {britekit-0.1.2.dist-info → britekit-0.1.5.dist-info}/entry_points.txt +0 -0
  47. {britekit-0.1.2.dist-info → britekit-0.1.5.dist-info}/licenses/LICENSE.txt +0 -0
@@ -542,7 +542,7 @@ class TrainingDatabase:
542
542
  Insert a Source record.
543
543
 
544
544
  Args:
545
- name (str): Name of the source (e.g. "Xeno-Canto").
545
+ - name (str): Name of the source (e.g. "Xeno-Canto").
546
546
 
547
547
  Returns:
548
548
  row_id (int): ID of the inserted record.
@@ -560,10 +560,10 @@ class TrainingDatabase:
560
560
  Delete one or more Source records.
561
561
 
562
562
  Args:
563
- filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
564
- column names for the Source table are:
565
- - ID (int): record ID
566
- - Name (str): source name
563
+ - filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
564
+ column names for the Source table are:
565
+ - ID (int): record ID
566
+ - Name (str): source name
567
567
 
568
568
  Returns:
569
569
  Number of records deleted.
@@ -578,10 +578,10 @@ class TrainingDatabase:
578
578
  Query the Source table.
579
579
 
580
580
  Args:
581
- filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
582
- column names for the Source table are:
583
- - ID (int): record ID
584
- - Name (str): source name
581
+ - filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
582
+ column names for the Source table are:
583
+ - ID (int): record ID
584
+ - Name (str): source name
585
585
 
586
586
  Returns:
587
587
  A list of entries, each as a SimpleNamespace object with the following attributes:
@@ -617,10 +617,10 @@ class TrainingDatabase:
617
617
  Get the number of records in the Source table.
618
618
 
619
619
  Args:
620
- filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
621
- column names for the Source table are:
622
- - ID (int): record ID
623
- - Name (str): source name
620
+ - filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
621
+ column names for the Source table are:
622
+ - ID (int): record ID
623
+ - Name (str): source name
624
624
 
625
625
  Returns:
626
626
  Number of records that match the criteria.
@@ -639,7 +639,7 @@ class TrainingDatabase:
639
639
  Insert a Category record.
640
640
 
641
641
  Args:
642
- name (str): Name of the category (e.g. "bird").
642
+ - name (str): Name of the category (e.g. "bird").
643
643
 
644
644
  Returns:
645
645
  row_id (int): ID of the inserted record.
@@ -657,10 +657,10 @@ class TrainingDatabase:
657
657
  Delete one or more Category records.
658
658
 
659
659
  Args:
660
- filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
661
- column names for the Category table are:
662
- - ID (int): record ID
663
- - Name (str): source name
660
+ - filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
661
+ column names for the Category table are:
662
+ - ID (int): record ID
663
+ - Name (str): source name
664
664
 
665
665
  Returns:
666
666
  Number of records deleted.
@@ -675,10 +675,10 @@ class TrainingDatabase:
675
675
  Query the Category table.
676
676
 
677
677
  Args:
678
- filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
679
- column names for the Category table are:
680
- - ID (int): record ID
681
- - Name (str): category name
678
+ - filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
679
+ column names for the Category table are:
680
+ - ID (int): record ID
681
+ - Name (str): category name
682
682
 
683
683
  Returns:
684
684
  A list of entries, each as a SimpleNamespace object with the following attributes:
@@ -714,10 +714,10 @@ class TrainingDatabase:
714
714
  Get the number of records in the Category table.
715
715
 
716
716
  Args:
717
- filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
718
- column names for the Category table are:
719
- - ID (int): record ID
720
- - Name (str): category name
717
+ - filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
718
+ column names for the Category table are:
719
+ - ID (int): record ID
720
+ - Name (str): category name
721
721
 
722
722
  Returns:
723
723
  Number of records that match the criteria.
@@ -743,11 +743,11 @@ class TrainingDatabase:
743
743
  Insert a Class record.
744
744
 
745
745
  Args:
746
- category_id (int, required): Record ID of the category (e.g. ID of "bird" in the Category table).
747
- name (str, required): Name of the class (e.g. "White-winged Crossbill").
748
- alt_name (str, optional): Alternate name of the class (e.g. "Two-barred Crossbill").
749
- code (str, optional): Code for the class (e.g. "WWCR").
750
- alt_code (str, optional): Alternate code
746
+ - category_id (int, required): Record ID of the category (e.g. ID of "bird" in the Category table).
747
+ - name (str, required): Name of the class (e.g. "White-winged Crossbill").
748
+ - alt_name (str, optional): Alternate name of the class (e.g. "Two-barred Crossbill").
749
+ - code (str, optional): Code for the class (e.g. "WWCR").
750
+ - alt_code (str, optional): Alternate code
751
751
 
752
752
  Returns:
753
753
  row_id (int): ID of the inserted record.
@@ -769,7 +769,7 @@ class TrainingDatabase:
769
769
  Delete one ore more Class records.
770
770
 
771
771
  Args:
772
- filters (dict, optional): a dict of column_name/value pairs that define filters.
772
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
773
773
 
774
774
  Returns:
775
775
  Number of records deleted.
@@ -784,7 +784,7 @@ class TrainingDatabase:
784
784
  Query the Class table.
785
785
 
786
786
  Args:
787
- filters (dict, optional): a dict of column_name/value pairs that define filters.
787
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
788
788
 
789
789
  Returns:
790
790
  A list of entries, each as a SimpleNamespace object with the following attributes:
@@ -836,7 +836,7 @@ class TrainingDatabase:
836
836
  Get the number of records in the Class table.
837
837
 
838
838
  Args:
839
- filters (dict, optional): a dict of column_name/value pairs that define filters.
839
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
840
840
 
841
841
  Returns:
842
842
  Number of records that match the criteria.
@@ -855,7 +855,7 @@ class TrainingDatabase:
855
855
  Insert a SoundType record.
856
856
 
857
857
  Args:
858
- name (str, required): Name of the sound type.
858
+ - name (str, required): Name of the sound type.
859
859
 
860
860
  Returns:
861
861
  row_id (int): ID of the inserted record.
@@ -873,7 +873,7 @@ class TrainingDatabase:
873
873
  Delete one or more SoundType records.
874
874
 
875
875
  Args:
876
- filters (dict, optional): a dict of column_name/value pairs that define filters.
876
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
877
877
 
878
878
  Returns:
879
879
  Number of records deleted.
@@ -888,7 +888,7 @@ class TrainingDatabase:
888
888
  Query the SoundType table.
889
889
 
890
890
  Args:
891
- filters (dict, optional): a dict of column_name/value pairs that define filters.
891
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
892
892
 
893
893
  Returns:
894
894
  A list of entries, each as a SimpleNamespace object with the following attributes:
@@ -928,7 +928,7 @@ class TrainingDatabase:
928
928
  Get the number of records in the SoundType table.
929
929
 
930
930
  Args:
931
- filters (dict, optional): a dict of column_name/value pairs that define filters.
931
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
932
932
 
933
933
  Returns:
934
934
  Number of records that match the criteria.
@@ -953,10 +953,10 @@ class TrainingDatabase:
953
953
  Insert a Recording record.
954
954
 
955
955
  Args:
956
- source_id (int, required): Record ID of the source (e.g. ID of "Xeno-Canto" in the Source table).
957
- filename (str, required): Name of the recording (e.g. "XC12345.mp3").
958
- path (str, required): Full path to the recording.
959
- seconds (float, optional): Duration of the recording in seconds.
956
+ - source_id (int, required): Record ID of the source (e.g. ID of "Xeno-Canto" in the Source table).
957
+ - filename (str, required): Name of the recording (e.g. "XC12345.mp3").
958
+ - path (str, required): Full path to the recording.
959
+ - seconds (float, optional): Duration of the recording in seconds.
960
960
 
961
961
  Returns:
962
962
  row_id (int): ID of the inserted record.
@@ -977,7 +977,7 @@ class TrainingDatabase:
977
977
  Delete one or more Recording records.
978
978
 
979
979
  Args:
980
- filters (dict, optional): a dict of column_name/value pairs that define filters.
980
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
981
981
 
982
982
  Returns:
983
983
  Number of records deleted.
@@ -994,7 +994,7 @@ class TrainingDatabase:
994
994
  Query the Recording table.
995
995
 
996
996
  Args:
997
- filters (dict, optional): a dict of column_name/value pairs that define filters.
997
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
998
998
 
999
999
  Returns:
1000
1000
  A list of entries, each as a SimpleNamespace object with the following attributes:
@@ -1049,7 +1049,7 @@ class TrainingDatabase:
1049
1049
  Return all recordings that have segments with the given class.
1050
1050
 
1051
1051
  Args:
1052
- class_name (str): name of the class.
1052
+ - class_name (str): name of the class.
1053
1053
 
1054
1054
  Returns:
1055
1055
  A list of entries, each as a SimpleNamespace object with the following attributes:
@@ -1099,9 +1099,9 @@ class TrainingDatabase:
1099
1099
  Update a record in the Recording table.
1100
1100
 
1101
1101
  Args:
1102
- id (int): ID that identifies the record to update
1103
- field (str): Name of column to update.
1104
- value: New value.
1102
+ - id (int): ID that identifies the record to update
1103
+ - field (str): Name of column to update.
1104
+ - value: New value.
1105
1105
  """
1106
1106
  try:
1107
1107
  sql = f"""
@@ -1117,7 +1117,7 @@ class TrainingDatabase:
1117
1117
  Get the number of records in the Recording table.
1118
1118
 
1119
1119
  Args:
1120
- filters (dict, optional): a dict of column_name/value pairs that define filters.
1120
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
1121
1121
 
1122
1122
  Returns:
1123
1123
  Number of records that match the criteria.
@@ -1140,9 +1140,9 @@ class TrainingDatabase:
1140
1140
  Insert a Segment record.
1141
1141
 
1142
1142
  Args:
1143
- recording_id (int, required): Record ID of the recording.
1144
- offset (float, required): offset in seconds from start of the recording.
1145
- audio (blob, optional): corresponding raw audio.
1143
+ - recording_id (int, required): Record ID of the recording.
1144
+ - offset (float, required): offset in seconds from start of the recording.
1145
+ - audio (blob, optional): corresponding raw audio.
1146
1146
 
1147
1147
  Returns:
1148
1148
  row_id (int): ID of the inserted record.
@@ -1160,7 +1160,7 @@ class TrainingDatabase:
1160
1160
  Delete one or more Segment records.
1161
1161
 
1162
1162
  Args:
1163
- filters (dict, optional): a dict of column_name/value pairs that define filters.
1163
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
1164
1164
  """
1165
1165
  try:
1166
1166
  self._delete_records("Segment", filters, self.segment_relationships)
@@ -1176,8 +1176,8 @@ class TrainingDatabase:
1176
1176
  Query the Segment table.
1177
1177
 
1178
1178
  Args:
1179
- filters (dict, optional): a dict of column_name/value pairs that define filters.
1180
- include_audio (bool, optional): if True, include audio in the returned objects. Default = False.
1179
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
1180
+ - include_audio (bool, optional): if True, include audio in the returned objects. Default = False.
1181
1181
 
1182
1182
  Returns:
1183
1183
  A list of entries, each as a SimpleNamespace object with the following attributes:
@@ -1244,8 +1244,8 @@ class TrainingDatabase:
1244
1244
  Get segment info for the given class.
1245
1245
 
1246
1246
  Args:
1247
- class_name (str): class name.
1248
- include_audio (bool, optional): if True, include audio in the returned objects. Default = False.
1247
+ - class_name (str): class name.
1248
+ - include_audio (bool, optional): if True, include audio in the returned objects. Default = False.
1249
1249
 
1250
1250
  Returns:
1251
1251
  A list of entries, each as a SimpleNamespace object with the following attributes:
@@ -1298,7 +1298,7 @@ class TrainingDatabase:
1298
1298
  Get the number of records in the Segment table.
1299
1299
 
1300
1300
  Args:
1301
- filters (dict, optional): a dict of column_name/value pairs that define filters.
1301
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
1302
1302
 
1303
1303
  Returns:
1304
1304
  Number of records that match the criteria.
@@ -1312,9 +1312,6 @@ class TrainingDatabase:
1312
1312
  """
1313
1313
  Get the class name and segment count for all classes.
1314
1314
 
1315
- Args:
1316
- None
1317
-
1318
1315
  Returns:
1319
1316
  A list of entries, each as a SimpleNamespace object with the following attributes:
1320
1317
  - class_name (str): Class Name.
@@ -1350,9 +1347,9 @@ class TrainingDatabase:
1350
1347
  Update a record in the Segment table.
1351
1348
 
1352
1349
  Args:
1353
- id (int): ID that identifies the record to update
1354
- field (str): Name of column to update.
1355
- value: New value.
1350
+ - id (int): ID that identifies the record to update
1351
+ - field (str): Name of column to update.
1352
+ - value: New value.
1356
1353
  """
1357
1354
  try:
1358
1355
  sql = f"""
@@ -1408,7 +1405,7 @@ class TrainingDatabase:
1408
1405
  Get the number of records in the SegmentClass table.
1409
1406
 
1410
1407
  Args:
1411
- filters (dict, optional): a dict of column_name/value pairs that define filters.
1408
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
1412
1409
 
1413
1410
  Returns:
1414
1411
  Number of records that match the criteria.
@@ -1429,8 +1426,8 @@ class TrainingDatabase:
1429
1426
  records.
1430
1427
 
1431
1428
  Args:
1432
- segment_id (int, required): Segment ID.
1433
- class_id (int, required): Class ID.
1429
+ - segment_id (int, required): Segment ID.
1430
+ - class_id (int, required): Class ID.
1434
1431
 
1435
1432
  Returns:
1436
1433
  row_id (int): ID of the inserted record.
@@ -1448,9 +1445,9 @@ class TrainingDatabase:
1448
1445
  Update a record in the SegmentClass table.
1449
1446
 
1450
1447
  Args:
1451
- id (int): ID that identifies the record to update
1452
- field (str): Name of column to update.
1453
- value: New value.
1448
+ - id (int): ID that identifies the record to update
1449
+ - field (str): Name of column to update.
1450
+ - value: New value.
1454
1451
  """
1455
1452
  try:
1456
1453
  sql = f"""
@@ -1470,7 +1467,7 @@ class TrainingDatabase:
1470
1467
  Insert a SpecGroup record.
1471
1468
 
1472
1469
  Args:
1473
- name (str): Name of the group (e.g. "logscale").
1470
+ - name (str): Name of the group (e.g. "logscale").
1474
1471
 
1475
1472
  Returns:
1476
1473
  row_id (int): ID of the inserted record.
@@ -1488,10 +1485,10 @@ class TrainingDatabase:
1488
1485
  Query the SpecGroup table.
1489
1486
 
1490
1487
  Args:
1491
- filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
1492
- column names for the SpecGroup table are:
1493
- - ID (int): record ID
1494
- - Name (str): specgroup name
1488
+ - filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
1489
+ column names for the SpecGroup table are:
1490
+ - ID (int): record ID
1491
+ - Name (str): specgroup name
1495
1492
 
1496
1493
  Returns:
1497
1494
  A list of entries, each as a SimpleNamespace object with the following attributes:
@@ -1527,10 +1524,10 @@ class TrainingDatabase:
1527
1524
  Delete one or more SpecGroup records.
1528
1525
 
1529
1526
  Args:
1530
- filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
1531
- column names for the Category table are:
1532
- - ID (int): record ID
1533
- - Name (str): specgroup name
1527
+ - filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
1528
+ column names for the Category table are:
1529
+ - ID (int): record ID
1530
+ - Name (str): specgroup name
1534
1531
 
1535
1532
  Returns:
1536
1533
  Number of records deleted.
@@ -1545,10 +1542,10 @@ class TrainingDatabase:
1545
1542
  Get the number of records in the SpecGroup table.
1546
1543
 
1547
1544
  Args:
1548
- filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
1549
- column names for the Source table are:
1550
- - ID (int): record ID
1551
- - Name (str): spec group name
1545
+ - filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
1546
+ column names for the Source table are:
1547
+ - ID (int): record ID
1548
+ - Name (str): spec group name
1552
1549
 
1553
1550
  Returns:
1554
1551
  Number of records that match the criteria.
@@ -1572,10 +1569,10 @@ class TrainingDatabase:
1572
1569
  Insert a SpecValue record.
1573
1570
 
1574
1571
  Args:
1575
- value (blob, required): the actual compressed spectrogram
1576
- spec_group_id (int, required): ID of spec group record
1577
- segment_id (int, required): ID of segment record
1578
- sampling_rate (int): sampling rate used to create it
1572
+ - value (blob, required): the actual compressed spectrogram
1573
+ - spec_group_id (int, required): ID of spec group record
1574
+ - segment_id (int, required): ID of segment record
1575
+ - sampling_rate (int): sampling rate used to create it
1579
1576
 
1580
1577
  Returns:
1581
1578
  row_id (int): ID of the inserted record.
@@ -1595,7 +1592,7 @@ class TrainingDatabase:
1595
1592
  Query the SpecValue table.
1596
1593
 
1597
1594
  Args:
1598
- filters (dict, optional): a dict of column_name/value pairs that define filters.
1595
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
1599
1596
 
1600
1597
  Returns:
1601
1598
  A list of entries, each as a SimpleNamespace object with the following attributes:
@@ -1649,9 +1646,9 @@ class TrainingDatabase:
1649
1646
  Delete one or more SpecValue records.
1650
1647
 
1651
1648
  Args:
1652
- filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
1653
- column names for the SpecValue table are:
1654
- - ID (int): record ID
1649
+ - filters (dict, optional): a dict of column_name/value pairs that define filters. Valid
1650
+ column names for the SpecValue table are:
1651
+ - ID (int): record ID
1655
1652
 
1656
1653
  Returns:
1657
1654
  Number of records deleted.
@@ -1666,9 +1663,9 @@ class TrainingDatabase:
1666
1663
  Update a record in the SpecValue table.
1667
1664
 
1668
1665
  Args:
1669
- id (int): ID that identifies the record to update
1670
- field (str): Name of column to update.
1671
- value: New value.
1666
+ - id (int): ID that identifies the record to update
1667
+ - field (str): Name of column to update.
1668
+ - value: New value.
1672
1669
  """
1673
1670
  try:
1674
1671
  sql = f"""
@@ -1684,7 +1681,7 @@ class TrainingDatabase:
1684
1681
  Get the number of records in the SpecValue table.
1685
1682
 
1686
1683
  Args:
1687
- filters (dict, optional): a dict of column_name/value pairs that define filters.
1684
+ - filters (dict, optional): a dict of column_name/value pairs that define filters.
1688
1685
 
1689
1686
  Returns:
1690
1687
  Number of records that match the criteria.
@@ -1710,11 +1707,11 @@ class TrainingDatabase:
1710
1707
  Fetch joined spectrogram records for the given class.
1711
1708
 
1712
1709
  Args:
1713
- class_name (str): class name.
1714
- include_value (bool, optional): If True, include the compressed spectrogram. Default = True.
1715
- include_embedding (bool, optional): If True, include embeddings in the returned objects. Default = False.
1716
- spec_group (str): Name of spectrogram group. Default = "default".
1717
- limit (int, optional): If specified, only return up to this many records.
1710
+ - class_name (str): class name.
1711
+ - include_value (bool, optional): If True, include the compressed spectrogram. Default = True.
1712
+ - include_embedding (bool, optional): If True, include embeddings in the returned objects. Default = False.
1713
+ - spec_group (str): Name of spectrogram group. Default = "default".
1714
+ - limit (int, optional): If specified, only return up to this many records.
1718
1715
 
1719
1716
  Returns:
1720
1717
  A list of entries, each as a SimpleNamespace object with the following attributes: