The first half of the year was a turbulent one for stocks in general amid concern President Trump's planned import tariffs would hurt the economy. And this problem weighed most heavily on stocks that depend on growth and investment -- such as those in the field of artificial intelligence (AI).

These particular players led indexes higher over the past two years on optimism about spending and the technology's potential, but they lost momentum in March and April. Since, though, the U.S. has made progress on trade talks, and this has lifted market sentiment. Meanwhile, tech companies' earnings reports show no signs of a slowdown in AI spending.

This has spurred new gains in AI stocks, and if the U.S. trade situation resolves without excessively high tariffs, these players could continue to advance. With this in mind, here are my top five AI stocks to buy before the second half.

Two investors smile while working on a laptop in a living room.

Image source: Getty Images.

1. Nvidia

Nvidia (NVDA 1.75%) soared more than 800% over the past two years as investors piled into this stock driving the AI revolution. The company dominates the AI chip market, and these chips are used for the most essential AI tasks. Nvidia hasn't had to wait to benefit from the AI market. The company already has delivered double- or triple-digit growth, with revenue attaining record levels.

This momentum is likely to continue as Nvidia is well positioned to power AI across every stage of development, from training through the creation of humanoid robots. I'm confident about this thanks to Nvidia's commitment to innovation -- it's already set out a calendar of chip updates through 2028. This makes it very difficult for rivals to upset its position.

Now is a great time to get in on this high-potential player as it's on sale, trading for 33 times forward earnings estimates -- down from more than 50 earlier in the year.

2. Amazon

Amazon (AMZN 1.04%), which sells some imported goods on its e-commerce site and also works with sellers that import goods, may benefit as trade tensions ease. The company also is winning from AI in two ways: Amazon uses AI tools to streamline operations, resulting in lower costs and greater efficiency. And Amazon, through its cloud unit Amazon Web Services (AWS), sells AI services to customers. AI services already have helped AWS reach a $117 billion annual revenue run rate.

All of this could make Amazon a winner in the second half of this year and beyond. On top of this, the company already has demonstrated its earnings strength, growing revenue and profit over time. And its overhaul of its cost structure in recent years should drive even more gains moving forward.

Amazon's valuation has fallen from more than 40 times forward earnings estimates earlier this year to 34 times expected earnings, offering investors a bargain entry point right now.

A person talks on the phone while sitting at a computer.

Image source: Getty Images.

3. SoundHound AI

SoundHound AI (SOUN 5.28%) shares have dropped more than 50% this year -- not as a result of any negative news, but primarily as investors rotated out of younger growth stocks, seen as risky. This company isn't yet profitable, which is standard at this stage of development, but revenue is soaring -- advancing more than 150% in the latest quarter. This is as customers rush to get in on SoundHound's voice AI technology.

The company specializes in this area and has quickly progressed from serving mainly the automobile market to now working with a wide variety of industries, from healthcare to restaurants and financial services. To further emphasize the diversification of its customer base, SoundHound says each single customer represents 10% or less of its revenue.

Now is a fantastic time to get in on SoundHound because it's trading for a lower price than earlier this year, and this company still is in the early days of its growth story -- the total addressable market for voice AI is more than $140 billion -- suggesting there's plenty of room for revenue expansion over time.

4. Palantir Technologies

Palantir Technologies (PLTR 3.62%) has soared over the past year even as valuation has reached mind-boggling levels. The stock trades for more than 200 times forward earnings estimates. But aggressive investors with a long-term view shouldn't necessarily stay away from this high-flyer.

Palantir's earnings also have soared, and the ongoing strong demand even prompted the company to lift its revenue, adjusted income from operations, and adjusted free cash flow guidance for the year. What makes this company stand out? Through its software platforms, Palantir helps customers easily harness the power of AI and their own data to streamline their operations, make better and faster decisions, and much more.

The company has relied on government customers for years, but in recent times, as the AI boom strengthened and Palantir launched an AI platform, commercial customers knocked on the door. Today, commercial growth is soaring -- and this could be the motor to drive earnings and the stock higher in the quarters to come. This makes Palantir a great growth stock to buy now and hold -- in spite of its lofty valuation.

5. Apple

Apple (AAPL 0.94%) produces most of its iPhones in China and also manufactures products in India and Vietnam -- and that's why investors have worried about an eventual tax on imports. Even the company's plan to move much of its production of iPhones for the U.S. out of China -- the country most affected by tariffs -- to India won't totally insulate Apple from these extra costs.

And Trump recently threatened Apple with a specific tariff of 25% on its imported iPhones. Considering this, why should you buy this tech giant now? The U.S. currently is involved in trade negotiations and potentially even considering the situation of technology players -- it's unlikely the Trump administration will make a decision that would sink Apple or any other U.S. tech giant, so once these times of uncertainty are over, I'm optimistic Apple stock will rebound.

Apple has a solid brand moat, or competitive advantage, and that's helped the company steadily grow earnings over time. Today, services offer this powerhouse a new revenue driver that could boost growth for many years down the road considering Apple's base of 2.2 billion active devices -- and this top tech company is in the early stages of AI innovation across its devices. That's why, trading at 27 times forward earnings estimates, Apple is a top stock to buy before the second half.