loadWordAudio static method
Load reference audio for a word Audio files should be stored in: assets/audio/words/{word_key}.pcm
Implementation
static Future<Uint8List?> loadWordAudio(String wordKey) async {
if (_audioCache.containsKey(wordKey)) {
return _audioCache[wordKey];
}
try {
final path = 'assets/audio/words/$wordKey.pcm';
final data = await rootBundle.load(path);
final audioBytes = data.buffer.asUint8List();
_audioCache[wordKey] = audioBytes;
debugPrint('Loaded word audio: $path (${audioBytes.length} bytes)');
return audioBytes;
} catch (e) {
debugPrint('Failed to load word audio for $wordKey: $e');
return null;
}
}