| |
| |
| |
| |
| |
| |
| |
|
|
| |
| export const SAMPLE_AUDIOS = [ |
| { |
| id: 'test', |
| label: 'Sample Recording', |
| description: 'Test bird call β North America', |
| file: '/samples/test.ogg', |
| emoji: 'π΅', |
| }, |
| ] |
|
|
| |
| export const BIRD_FACTS = { |
| norcar: { |
| commonName: 'Northern Cardinal', |
| scientificName: 'Cardinalis cardinalis', |
| family: 'Cardinalidae', |
| habitat: 'Woodlands, gardens, shrublands', |
| diet: 'Seeds, fruit, and insects', |
| funFacts: [ |
| "The male's brilliant red plumage comes from carotenoid pigments in its diet.", |
| 'Unlike most songbirds, female Northern Cardinals also sing β a rare trait among North American birds.', |
| 'They are non-migratory and often visit backyard feeders year-round.', |
| ], |
| range: { |
| center: [37.0, -85.0], |
| description: 'Eastern and central North America, from southern Canada to Mexico.', |
| }, |
| wikiImage: 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Cardinalis_cardinalis_-_20070909.jpg/480px-Cardinalis_cardinalis_-_20070909.jpg', |
| color: '#c4714a', |
| }, |
| westan: { |
| commonName: 'Western Tanager', |
| scientificName: 'Piranga ludoviciana', |
| family: 'Cardinalidae', |
| habitat: 'Coniferous and mixed forests', |
| diet: 'Insects, berries, and fruit', |
| funFacts: [ |
| "Males sport a brilliant red head with yellow and black body β one of North America's most colorful birds.", |
| 'Despite their tropical appearance, Western Tanagers breed across western North America.', |
| 'Their song is a burry, robin-like phrase often described as "pit-er-ick".', |
| ], |
| range: { |
| center: [45.5, -116.0], |
| description: 'Western North America, from Alaska south to Mexico during breeding season.', |
| }, |
| wikiImage: 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Piranga_ludoviciana_-Western_Tanager.jpg/480px-Piranga_ludoviciana_-Western_Tanager.jpg', |
| color: '#c9a84c', |
| }, |
| baleag: { |
| commonName: 'Bald Eagle', |
| scientificName: 'Haliaeetus leucocephalus', |
| family: 'Accipitridae', |
| habitat: 'Coasts, rivers, large lakes', |
| diet: 'Fish, waterfowl, small mammals', |
| funFacts: [ |
| 'Bald Eagles can spot a fish from nearly two miles away.', |
| "Their iconic white head and tail don't appear until they reach maturity at age 4β5.", |
| "A Bald Eagle's nest can weigh over a ton after years of additions.", |
| ], |
| range: { |
| center: [55.0, -105.0], |
| description: 'Across North America, especially near large bodies of open water.', |
| }, |
| wikiImage: 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/1e/Bald_Eagle_Portrait.jpg/480px-Bald_Eagle_Portrait.jpg', |
| color: '#7a9e7e', |
| }, |
| amecro: { |
| commonName: 'American Crow', |
| scientificName: 'Corvus brachyrhynchos', |
| family: 'Corvidae', |
| habitat: 'Open woodland, fields, urban areas', |
| diet: 'Omnivore β insects, seeds, carrion, small animals', |
| funFacts: [ |
| 'American Crows are among the most intelligent birds β they use tools and recognize human faces.', |
| 'They form large communal roosts in winter, sometimes numbering in the millions.', |
| 'Crows remember and hold grudges against specific humans who have threatened them.', |
| ], |
| range: { |
| center: [42.0, -95.0], |
| description: 'Throughout North America except the far north and desert southwest.', |
| }, |
| wikiImage: 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/74/American-Crow.jpg/480px-American-Crow.jpg', |
| color: '#4a3a4a', |
| }, |
| } |
|
|
| |
| const DEFAULT_FACTS = { |
| commonName: null, |
| scientificName: '', |
| family: 'Unknown', |
| habitat: 'North America', |
| diet: 'Varies by species', |
| funFacts: [ |
| 'This species was identified from its unique acoustic signature.', |
| 'Bird calls are as individual as fingerprints β no two species sound alike.', |
| ], |
| range: { |
| center: [45.0, -100.0], |
| description: 'North America', |
| }, |
| wikiImage: null, |
| color: '#9a749a', |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| export function enrichResult(apiResponse) { |
| const { predictions, top_species, confidence } = apiResponse |
| const facts = BIRD_FACTS[top_species] ?? DEFAULT_FACTS |
| const commonName = facts.commonName ?? top_species |
|
|
| const topPredictions = predictions.map(p => ({ |
| name: BIRD_FACTS[p.species_code]?.commonName ?? p.species_code, |
| confidence: p.confidence, |
| })) |
|
|
| return { |
| commonName, |
| scientificName: facts.scientificName ?? '', |
| confidence, |
| family: facts.family, |
| habitat: facts.habitat, |
| diet: facts.diet, |
| funFacts: facts.funFacts, |
| range: facts.range, |
| wikiImage: facts.wikiImage, |
| color: facts.color, |
| topPredictions, |
| } |
| } |
|
|