Synchronisation labiale
Tu dis quoi ?

Rendre plus réaliste
Plusieurs personnages vont parler, et pour l’instant on ne voit qu’une bulle de texte. J’avais déjà la possibilité d’utiliser du son, mais ce n’était pas encore joli. Quand quelqu’un parle, la bouche doit bouger, alors j’ai cherché comment on fait dans les dessins animés.
Pour faire court, avec au moins 6 à 9 images différentes de la bouche, on peut donner l’impression qu’elle parle vraiment. Il existe plusieurs logiciels qui convertissent le son en l’image à afficher.
Entrée audio > logiciel > sortie [ABBFGG].
Ensuite, dans le jeu, une image différente de la tête est affichée pour chaque lettre.
-- convert csv to a lua table
local libSyncTable = {}
for line in csvData:gmatch("[^\r\n]+") do
local a, b = line:match("(%S+)\t(%w)")
local framekey
if b == "A" then
framekey = 1
elseif b == "B" then
framekey = 2
elseif b == "C" then
framekey = 3
elseif b == "D" then
framekey = 4
elseif b == "E" then
framekey = 5
elseif b == "F" then
framekey = 6
-- elseif b == "G" then
-- framekey = 7
-- elseif b == "H" then
-- framekey = 8
-- elseif b == "X" then
-- framekey = 9
end
table.insert(libSyncTable, {a, framekey})
end
Plusieurs logiciels font cela, mais j’ai choisi le logiciel gratuit https://github.com/DanielSWolf/rhubarb-lip-sync.
if not os.path.exists(audioPath_lsc):
print(f"create lcs {audioPath} with text {text}")
with open("../temp/lipsync.txt", 'w') as file:
file.write(text)
command = [
"../src/lib-dev/rhubarb/rhubarb", # Het pad naar het rhubarb-programma
audioPath_ogg, # SOUND_FILE
"--recognizer", "pocketSphinx", # Recognizer instellen
"--exportFormat", "tsv", # Export formaat instellen
"--dialogFile", f"../temp/lipsync.txt", # TEMP_DIR voor dialogFile
"--output", audioPath_lsc, # OUTPUT_FILE
"--datFrameRate", "60", # Data frame rate
"--extendedShapes", "ABCDEF" # Extended shapes
]
result = subprocess.run(command, check=True)
if result.returncode != 0:
print("error")