SPOILER ALERT: Do not read unless you have watched “Top Gun: Maverick,” in theaters now.

“Top Gun” fans knew ahead of time that Val Kilmer would be reprising his role of Tom “Iceman” Kazansky in the sequel, but the specifics of the actor’s return were a question mark considering Kilmer lost the ability to speak after undergoing throat cancer treatment in 2014. The script for Paramount Pictures’ “Top Gun: Maverick” pulls from Kilmer’s real life, with Iceman also having cancer and communicating through typing. Kilmer gets to say one brief line of dialogue. In real life, Kilmer’s speaking voice has been revived courtesy of artificial intelligence.

Kilmer announced in August 2021 that he had partnered with Sonantic to create an A.I.-powered speaking voice for himself. The actor supplied the company with hours of archival footage featuring his speaking voice that was then fed through the company’s algorithms and turned into a model. According to Fortune, this process was used again for the actor’s “Top Gun: Maverick” appearance although a studio sources tells Variety no A.I. was used in the making of the movie.

“In the end, we generated more than 40 different voice models and selected the best, highest-quality, most expressive one,” John Flynn, CTO and cofounder of Sonantic, said in a statement to Forbes about reviving Kilmer’s voice, unrelated to the movie. “Those new algorithms are now embedded into our voice engine, so future clients can automatically take advantage of them as well.”

“I’m grateful to the entire team at Sonantic who masterfully restored my voice in a way I’ve never imagined possible,” Kilmer originally said in a statement about the A.I. “As human beings, the ability to communicate is the core of our existence and the side effects from throat cancer have made it difficult for others to understand me. The chance to narrate my story, in a voice that feels authentic and familiar, is an incredibly special gift.”

As Fortune reports: “After cleaning up old audio recordings of Kilmer, [Sonantic] used a ‘voice engine’ to teach the voice model how to speak like Kilmer. The engine had around 10 times less data than it would have been given in a typical project, Sonantic said, and it wasn’t enough. The company then decided to come up with new algorithms that could produce a higher-quality voice model using the available data.”