Skip to main content

Voice Download

|

This example lets users browse available human voice packages, download them, and display country flags for each voice.

Highlights

  • Load voice packages from ContentStore
  • Download and pause voices
  • Display a country flag per voice
  • Track progress and completion state

Key implementation

Load voices

import { ContentStore, ContentType, GemError } from '@magiclane/maps-sdk';

ContentStore.asyncGetStoreContentList(
ContentType.humanVoice,
(err: GemError, items) => {
if (err === GemError.success && items) {
setVoices(items);
}
}
);

Render the country flag

import { MapDetails } from '@magiclane/maps-sdk';

const flagImg = MapDetails.getCountryFlag(countryCode, { width: 80, height: 80 });
if (flagImg) {
const base64 = convertUint8ArrayToBase64(flagImg);
const uri = 'data:image/png;base64,' + base64;
}

Download a voice package

voiceItem.asyncDownload(
(err: GemError) => {
if (err === GemError.success) {
setIsDownloaded(true);
}
},
{
onProgressCallback: (prog: number) => {
setProgress(prog);
},
allowChargedNetworks: true,
}
);

Notes

  • Replace YOUR_API_TOKEN_HERE with your Magic Lane API token.
  • Voice content uses ContentType.humanVoice.
  • UI state reflects ContentStoreItemStatus during download.