JSFiddle - React, Tailwind, and code Playground
by morphcast
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MorphCast SDK Example</title>
<script src="https://ai-sdk.morphcast.com/v1.16/ai-sdk.js"></script>
<script>
// Imposta la chiave di licenza
const licenseKey = '9087cfd2037a28a79769fdcaa4962252379cd2e2fd0b';
// Inizializza l'SDK MorphCast con la chiave di licenza
const loader = CY.loader().licenseKey(licenseKey);
// Aggiungi il modulo FACE_EMOTION
loader.addModule(CY.modules().FACE_EMOTION.name, {smoothness: 0.40});
window.addEventListener(CY.modules().FACE_EMOTION.eventName, (evt) => {
const emotions = evt.detail.output.emotion;
// Remove the probability of 'Fear'
const fearProbability = emotions.Fear;
delete emotions.Fear;
// Redistribute the probability of 'Fear' across other emotions
const remainingEmotionCount = Object.keys(emotions).length;
const redistribution = fearProbability / remainingEmotionCount;
Object.keys(emotions).forEach(emotion => {
emotions[emotion] += redistribution;
});
console.log('Adjusted Emotion Probabilities:', emotions);
});
// Carica i moduli
loader.load().then(({start}) => {
console.log("MorphCast SDK caricato con successo");
start();
}).catch(error => {
console.error("Errore nel caricamento dell'SDK MorphCast:", error);
});
</script>
</head>
<body>
<!-- Il contenuto del body può essere aggiunto qui -->
</body>
</html>