Openai Text To Speech icon Openai Text To Speech — Convert text to dynamic, real-time speech with nine expressive OpenAI voices-natural, varied, accessible robot communication. Try it →
France
Asked — Edited

The Robot Program 027 - Microsoft Cognitive Emotion In French

Hi, after watching this video on Youtube, i writed a little script for translate the emotion in french :

$retVal=" " $retVal= $EmotionDescription if ($EmotionDescription="Happiness") $retVal="eureu" endif if ($EmotionDescription="Sadness") $retVal="Triste" endif if ($EmotionDescription="Surprise") $retVal="Surpri" endif if ($EmotionDescription="Anger") $retVal= "En Colère" endif if ($EmotionDescription="Neutral") $retVal="sans zexpression" endif if ($EmotionDescription="Disgust") $retVal="Dégouté" endif if ($EmotionDescription="Fear") $retVal="Effrayé" endif SayEZB(("iL ME SEMBLE QUE VOUS zaiTe" + $retVal))

Valere.


ARC Pro

Upgrade to ARC Pro

Get access to the latest features and updates before they're released. You'll have everything that's needed to unleash your robot's potential!

Author Avatar
PRO
USA
#1  

Valere73,

Do you need help ?

to help readability, use [ code ] [ /code ] tags.

ARC > Edit Script > use (Alt+F) to format code improves readability.


#using elseif less comparisations => less cpu
if ($EmotionDescription="Happiness")
  $retVal="eureu"
ELSEif ($EmotionDescription="Sadness")
  $retVal="Triste"
ELSEif ($EmotionDescription="Surprise")
  $retVal="Surpri"
ELSEif ($EmotionDescription="Anger")
  $retVal= "En Colere"
ELSEif ($EmotionDescription="Neutral")
  $retVal="sans zexpression"
ELSEif ($EmotionDescription="Disgust")
  $retVal="Degoute"
ELSEif ($EmotionDescription="Fear")
  $retVal="Effraye"
ELSE
  $retVal=$EmotionDescription
endif
#removed extra parentheses
SayEZB("IL ME SEMBLE QUE VOUS ZAITE " + $retVal)
#2  

This is where a switch or case statement would be useful. Not saying it is needed, but would just be useful in the script language.

Author Avatar
PRO
USA
#3  

I agree.

if you have zillions strings to match you can be creative:


#can be moved to the initialize script
DefineArray($emotion_keys_en, 7)
$emotion_keys_en[0]="Happiness"
$emotion_keys_en[1]="Sadness"
$emotion_keys_en[2]="Surprise"
$emotion_keys_en[3]="Anger"
$emotion_keys_en[4]="Neutral"
$emotion_keys_en[5]="Disgust"
$emotion_keys_en[6]="Fear"

DefineArray($emotion_keys_fr, 7)
$emotion_keys_fr[0]="Eureu"
$emotion_keys_fr[1]="Triste"
$emotion_keys_fr[2]="Surpri"
$emotion_keys_fr[3]="En Colere"
$emotion_keys_fr[4]="Sans zexpression"
$emotion_keys_fr[5]="Degoute"
$emotion_keys_fr[6]="Effraye"

#main logic

$retVal=$EmotionDescription

repeat ($ix, 0, GetArraySize("$emotion_keys_en")-1, 1)
  if ($EmotionDescription=$emotion_keys_en[$ix])
    $retVal=$emotion_keys_fr[$ix]
    # key found => break the repeat
    $ix=GetArraySize("$emotion_keys_en")
  endif
endrepeat

SayEZB("IL ME SEMBLE QUE VOUS ZAITE " + $retVal)
#4  

Great ! thanks I understand the code but it's too high level for me stress