File size: 5,831 Bytes
2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe 2cc62ca ffc05fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | /**
* src/data/mockData.js
*
* - SAMPLE_AUDIOS: single test.ogg sample in public/samples/
* - BIRD_FACTS: static enrichment data keyed by BirdCLEF species code
* - enrichResult: merges API response with local facts for the result panel
*/
// ββ Sample audio files (place .ogg files in public/samples/) βββββββββββββββββ
export const SAMPLE_AUDIOS = [
{
id: 'test',
label: 'Sample Recording',
description: 'Test bird call β North America',
file: '/samples/test.ogg',
emoji: 'π΅',
},
]
// ββ Static enrichment data keyed by BirdCLEF species code ββββββββββββββββββββ
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',
},
}
// ββ Default fallback for unknown species codes ββββββββββββββββββββββββββββββββ
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',
}
/**
* Merge the raw API prediction response with local enrichment facts.
*
* @param {object} apiResponse - Response from POST /predict
* Shape: { predictions: [{species_code, confidence}], top_species, confidence, model }
* @returns {object} Full result object for BirdResult + RangeMap components
*/
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,
}
}
|