Sincronizzazione labiale
Cosa dici?

Renderlo più realistico
Ci sono alcuni personaggi che parleranno, e al momento vedi solo un fumetto. Avevo già la possibilità di usare anche l’audio, ma non era ancora bello da vedere. Quando qualcuno parla, la bocca deve muoversi, per questo ho studiato come si fa nei cartoni animati.
Per farla breve, con almeno 6 a 9 immagini diverse della bocca puoi far sembrare che parli davvero. Esistono vari programmi che trasformano l’audio nell’immagine da mostrare.
Input audio > programma > output [ABBFGG].
Poi nel gioco per ogni lettera viene mostrato un fotogramma diverso della testa.
-- 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
Ci sono diversi programmi che lo fanno, ma io ho scelto il programma gratuito 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")