BEIJING — During President Trump’s visit to Beijing, he appeared on screen for a special address at a tech conference.

First he spoke in English. Then he switched to Mandarin Chinese.

Mr. Trump doesn’t speak Chinese. The video was a publicity stunt, designed to show off the voice capabilities of iFlyTek, a Chinese artificial intelligence company with both innovative technology and troubling ties to Chinese state security. IFlyTek has said its technology can monitor a car full of people or a crowded room, identify a targeted individual’s voice and record everything that person says.

“IFlyTek,” the image of Mr. Trump said in Chinese, “is really fantastic.”

As China tests the frontiers of artificial intelligence, iFlyTek serves as a compelling example of both the country’s sci-fi ambitions and the technology’s darker dystopian possibilities.

The Chinese company uses sophisticated A.I. to power image and voice recognition systems that can help doctors with their diagnoses, aid teachers in grading tests and let drivers control their cars with their voices. Even some global companies are impressed: Delphi, a major American auto supplier, offers iFlyTek’s technology to carmakers in China, while Volkswagen plans to build the Chinese company’s speech recognition technology into many of its cars in China next year.