birdnet-analyzer 2.0.0__py3-none-any.whl → 2.0.1__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.
Files changed (122) hide show
  1. birdnet_analyzer/__init__.py +9 -8
  2. birdnet_analyzer/analyze/__init__.py +5 -5
  3. birdnet_analyzer/analyze/__main__.py +3 -4
  4. birdnet_analyzer/analyze/cli.py +25 -25
  5. birdnet_analyzer/analyze/core.py +241 -245
  6. birdnet_analyzer/analyze/utils.py +692 -701
  7. birdnet_analyzer/audio.py +368 -372
  8. birdnet_analyzer/cli.py +709 -707
  9. birdnet_analyzer/config.py +242 -242
  10. birdnet_analyzer/eBird_taxonomy_codes_2021E.json +25279 -25279
  11. birdnet_analyzer/embeddings/__init__.py +3 -4
  12. birdnet_analyzer/embeddings/__main__.py +3 -3
  13. birdnet_analyzer/embeddings/cli.py +12 -13
  14. birdnet_analyzer/embeddings/core.py +69 -70
  15. birdnet_analyzer/embeddings/utils.py +179 -193
  16. birdnet_analyzer/evaluation/__init__.py +196 -195
  17. birdnet_analyzer/evaluation/__main__.py +3 -3
  18. birdnet_analyzer/evaluation/assessment/__init__.py +0 -0
  19. birdnet_analyzer/evaluation/assessment/metrics.py +388 -0
  20. birdnet_analyzer/evaluation/assessment/performance_assessor.py +409 -0
  21. birdnet_analyzer/evaluation/assessment/plotting.py +379 -0
  22. birdnet_analyzer/evaluation/preprocessing/__init__.py +0 -0
  23. birdnet_analyzer/evaluation/preprocessing/data_processor.py +631 -0
  24. birdnet_analyzer/evaluation/preprocessing/utils.py +98 -0
  25. birdnet_analyzer/gui/__init__.py +19 -23
  26. birdnet_analyzer/gui/__main__.py +3 -3
  27. birdnet_analyzer/gui/analysis.py +175 -174
  28. birdnet_analyzer/gui/assets/arrow_down.svg +4 -4
  29. birdnet_analyzer/gui/assets/arrow_left.svg +4 -4
  30. birdnet_analyzer/gui/assets/arrow_right.svg +4 -4
  31. birdnet_analyzer/gui/assets/arrow_up.svg +4 -4
  32. birdnet_analyzer/gui/assets/gui.css +28 -28
  33. birdnet_analyzer/gui/assets/gui.js +93 -93
  34. birdnet_analyzer/gui/embeddings.py +619 -620
  35. birdnet_analyzer/gui/evaluation.py +795 -813
  36. birdnet_analyzer/gui/localization.py +75 -68
  37. birdnet_analyzer/gui/multi_file.py +245 -246
  38. birdnet_analyzer/gui/review.py +519 -527
  39. birdnet_analyzer/gui/segments.py +191 -191
  40. birdnet_analyzer/gui/settings.py +128 -129
  41. birdnet_analyzer/gui/single_file.py +267 -269
  42. birdnet_analyzer/gui/species.py +95 -95
  43. birdnet_analyzer/gui/train.py +696 -698
  44. birdnet_analyzer/gui/utils.py +810 -808
  45. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_af.txt +6522 -6522
  46. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ar.txt +6522 -6522
  47. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_bg.txt +6522 -6522
  48. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ca.txt +6522 -6522
  49. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_cs.txt +6522 -6522
  50. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_da.txt +6522 -6522
  51. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_de.txt +6522 -6522
  52. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_el.txt +6522 -6522
  53. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_en_uk.txt +6522 -6522
  54. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_es.txt +6522 -6522
  55. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_fi.txt +6522 -6522
  56. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_fr.txt +6522 -6522
  57. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_he.txt +6522 -6522
  58. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_hr.txt +6522 -6522
  59. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_hu.txt +6522 -6522
  60. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_in.txt +6522 -6522
  61. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_is.txt +6522 -6522
  62. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_it.txt +6522 -6522
  63. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ja.txt +6522 -6522
  64. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ko.txt +6522 -6522
  65. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_lt.txt +6522 -6522
  66. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ml.txt +6522 -6522
  67. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_nl.txt +6522 -6522
  68. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_no.txt +6522 -6522
  69. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_pl.txt +6522 -6522
  70. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_pt_BR.txt +6522 -6522
  71. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_pt_PT.txt +6522 -6522
  72. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ro.txt +6522 -6522
  73. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_ru.txt +6522 -6522
  74. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sk.txt +6522 -6522
  75. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sl.txt +6522 -6522
  76. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sr.txt +6522 -6522
  77. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_sv.txt +6522 -6522
  78. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_th.txt +6522 -6522
  79. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_tr.txt +6522 -6522
  80. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_uk.txt +6522 -6522
  81. birdnet_analyzer/labels/V2.4/BirdNET_GLOBAL_6K_V2.4_Labels_zh.txt +6522 -6522
  82. birdnet_analyzer/lang/de.json +334 -334
  83. birdnet_analyzer/lang/en.json +334 -334
  84. birdnet_analyzer/lang/fi.json +334 -334
  85. birdnet_analyzer/lang/fr.json +334 -334
  86. birdnet_analyzer/lang/id.json +334 -334
  87. birdnet_analyzer/lang/pt-br.json +334 -334
  88. birdnet_analyzer/lang/ru.json +334 -334
  89. birdnet_analyzer/lang/se.json +334 -334
  90. birdnet_analyzer/lang/tlh.json +334 -334
  91. birdnet_analyzer/lang/zh_TW.json +334 -334
  92. birdnet_analyzer/model.py +1212 -1243
  93. birdnet_analyzer/playground.py +5 -0
  94. birdnet_analyzer/search/__init__.py +3 -3
  95. birdnet_analyzer/search/__main__.py +3 -3
  96. birdnet_analyzer/search/cli.py +11 -12
  97. birdnet_analyzer/search/core.py +78 -78
  98. birdnet_analyzer/search/utils.py +107 -111
  99. birdnet_analyzer/segments/__init__.py +3 -3
  100. birdnet_analyzer/segments/__main__.py +3 -3
  101. birdnet_analyzer/segments/cli.py +13 -14
  102. birdnet_analyzer/segments/core.py +81 -78
  103. birdnet_analyzer/segments/utils.py +383 -394
  104. birdnet_analyzer/species/__init__.py +3 -3
  105. birdnet_analyzer/species/__main__.py +3 -3
  106. birdnet_analyzer/species/cli.py +13 -14
  107. birdnet_analyzer/species/core.py +35 -35
  108. birdnet_analyzer/species/utils.py +74 -75
  109. birdnet_analyzer/train/__init__.py +3 -3
  110. birdnet_analyzer/train/__main__.py +3 -3
  111. birdnet_analyzer/train/cli.py +13 -14
  112. birdnet_analyzer/train/core.py +113 -113
  113. birdnet_analyzer/train/utils.py +877 -847
  114. birdnet_analyzer/translate.py +133 -104
  115. birdnet_analyzer/utils.py +426 -419
  116. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.0.1.dist-info}/METADATA +137 -129
  117. birdnet_analyzer-2.0.1.dist-info/RECORD +125 -0
  118. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.0.1.dist-info}/WHEEL +1 -1
  119. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.0.1.dist-info}/licenses/LICENSE +18 -18
  120. birdnet_analyzer-2.0.0.dist-info/RECORD +0 -117
  121. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.0.1.dist-info}/entry_points.txt +0 -0
  122. {birdnet_analyzer-2.0.0.dist-info → birdnet_analyzer-2.0.1.dist-info}/top_level.txt +0 -0
@@ -1,104 +1,133 @@
1
- """Module for translating species labels.
2
-
3
- Can be used to translate species names into other languages.
4
-
5
- Uses the requests to the eBird-API.
6
- """
7
- import json
8
- import os
9
- import urllib.request
10
-
11
- import birdnet_analyzer.config as cfg
12
- import birdnet_analyzer.utils as utils
13
-
14
- LOCALES = ['af', 'ar', 'cs', 'da', 'de', 'en_uk', 'es', 'fi', 'fr', 'hu', 'it', 'ja', 'ko', 'nl', 'no', 'pl', 'pt_BR', 'pt_PT', 'ro', 'ru', 'sk', 'sl', 'sv', 'th', 'tr', 'uk', 'zh']
15
- """ Locales for 26 common languages (according to GitHub Copilot) """
16
-
17
- API_TOKEN = "yourAPIToken"
18
- """ Sign up for your personal access token here: https://ebird.org/api/keygen """
19
-
20
-
21
- def get_locale_data(locale: str):
22
- """Download eBird locale species data.
23
-
24
- Requests the locale data through the eBird API.
25
-
26
- Args:
27
- locale: Two character string of a language.
28
-
29
- Returns:
30
- A data object containing the response from eBird.
31
- """
32
- url = "https://api.ebird.org/v2/ref/taxonomy/ebird?cat=species&fmt=json&locale=" + locale
33
- header = {"X-eBirdAPIToken": API_TOKEN}
34
-
35
- req = urllib.request.Request(url, headers=header)
36
- response = urllib.request.urlopen(req)
37
-
38
- return json.loads(response.read())
39
-
40
-
41
- def translate(locale: str):
42
- """Translates species names for a locale.
43
-
44
- Translates species names for the given language with the eBird API.
45
-
46
- Args:
47
- locale: Two character string of a language.
48
-
49
- Returns:
50
- The translated list of labels.
51
- """
52
- print(f"Translating species names for {locale}...", end="", flush=True)
53
-
54
- # Get locale data
55
- data = get_locale_data(locale)
56
-
57
- # Create list of translated labels
58
- labels: list[str] = []
59
-
60
- for label in cfg.LABELS:
61
- has_translation = False
62
- for entry in data:
63
- if label.split("_", 1)[0] == entry["sciName"]:
64
- labels.append("{}_{}".format(label.split("_", 1)[0], entry["comName"]))
65
- has_translation = True
66
- break
67
- if not has_translation:
68
- labels.append(label)
69
-
70
- print("Done.", flush=True)
71
-
72
- return labels
73
-
74
-
75
- def save_labels_file(labels: list[str], locale: str):
76
- """Saves localized labels to a file.
77
-
78
- Saves the given labels into a file with the format:
79
- "{config.LABELSFILE}_{locale}.txt"
80
-
81
- Args:
82
- labels: List of labels.
83
- locale: Two character string of a language.
84
- """
85
- # Create folder
86
- os.makedirs(cfg.TRANSLATED_LABELS_PATH, exist_ok=True)
87
-
88
- # Save labels file
89
- fpath = os.path.join(
90
- cfg.TRANSLATED_LABELS_PATH, "{}_{}.txt".format(os.path.basename(cfg.LABELS_FILE).rsplit(".", 1)[0], locale)
91
- )
92
- with open(fpath, "w", encoding="utf-8") as f:
93
- for label in labels:
94
- f.write(label + "\n")
95
-
96
-
97
- if __name__ == "__main__":
98
- # Load labels
99
- cfg.LABELS = utils.read_lines(cfg.LABELS_FILE)
100
-
101
- # Translate labels
102
- for locale in LOCALES:
103
- labels = translate(locale)
104
- save_labels_file(labels, locale)
1
+ """Module for translating species labels.
2
+
3
+ Can be used to translate species names into other languages.
4
+
5
+ Uses the requests to the eBird-API.
6
+ """
7
+
8
+ import json
9
+ import os
10
+ import urllib.request
11
+
12
+ import birdnet_analyzer.config as cfg
13
+ from birdnet_analyzer import utils
14
+
15
+ LOCALES = [
16
+ "af",
17
+ "ar",
18
+ "cs",
19
+ "da",
20
+ "de",
21
+ "en_uk",
22
+ "es",
23
+ "fi",
24
+ "fr",
25
+ "hu",
26
+ "it",
27
+ "ja",
28
+ "ko",
29
+ "nl",
30
+ "no",
31
+ "pl",
32
+ "pt_BR",
33
+ "pt_PT",
34
+ "ro",
35
+ "ru",
36
+ "sk",
37
+ "sl",
38
+ "sv",
39
+ "th",
40
+ "tr",
41
+ "uk",
42
+ "zh",
43
+ ]
44
+ """ Locales for 26 common languages (according to GitHub Copilot) """
45
+
46
+ API_TOKEN = "yourAPIToken"
47
+ """ Sign up for your personal access token here: https://ebird.org/api/keygen """
48
+
49
+
50
+ def get_locale_data(locale: str):
51
+ """Download eBird locale species data.
52
+
53
+ Requests the locale data through the eBird API.
54
+
55
+ Args:
56
+ locale: Two character string of a language.
57
+
58
+ Returns:
59
+ A data object containing the response from eBird.
60
+ """
61
+ url = "https://api.ebird.org/v2/ref/taxonomy/ebird?cat=species&fmt=json&locale=" + locale
62
+ header = {"X-eBirdAPIToken": API_TOKEN}
63
+
64
+ req = urllib.request.Request(url, headers=header)
65
+ response = urllib.request.urlopen(req)
66
+
67
+ return json.loads(response.read())
68
+
69
+
70
+ def translate(locale: str):
71
+ """Translates species names for a locale.
72
+
73
+ Translates species names for the given language with the eBird API.
74
+
75
+ Args:
76
+ locale: Two character string of a language.
77
+
78
+ Returns:
79
+ The translated list of labels.
80
+ """
81
+ print(f"Translating species names for {locale}...", end="", flush=True)
82
+
83
+ # Get locale data
84
+ data = get_locale_data(locale)
85
+
86
+ # Create list of translated labels
87
+ labels: list[str] = []
88
+
89
+ for label in cfg.LABELS:
90
+ has_translation = False
91
+ for entry in data:
92
+ if label.split("_", 1)[0] == entry["sciName"]:
93
+ labels.append("{}_{}".format(label.split("_", 1)[0], entry["comName"]))
94
+ has_translation = True
95
+ break
96
+ if not has_translation:
97
+ labels.append(label)
98
+
99
+ print("Done.", flush=True)
100
+
101
+ return labels
102
+
103
+
104
+ def save_labels_file(labels: list[str], locale: str):
105
+ """Saves localized labels to a file.
106
+
107
+ Saves the given labels into a file with the format:
108
+ "{config.LABELSFILE}_{locale}.txt"
109
+
110
+ Args:
111
+ labels: List of labels.
112
+ locale: Two character string of a language.
113
+ """
114
+ # Create folder
115
+ os.makedirs(cfg.TRANSLATED_LABELS_PATH, exist_ok=True)
116
+
117
+ # Save labels file
118
+ fpath = os.path.join(
119
+ cfg.TRANSLATED_LABELS_PATH, "{}_{}.txt".format(os.path.basename(cfg.LABELS_FILE).rsplit(".", 1)[0], locale)
120
+ )
121
+ with open(fpath, "w", encoding="utf-8") as f:
122
+ for label in labels:
123
+ f.write(label + "\n")
124
+
125
+
126
+ if __name__ == "__main__":
127
+ # Load labels
128
+ cfg.LABELS = utils.read_lines(cfg.LABELS_FILE)
129
+
130
+ # Translate labels
131
+ for locale in LOCALES:
132
+ labels = translate(locale)
133
+ save_labels_file(labels, locale)