If you look at the Bible Dictionary for Gentile:
The word Gentiles means “the nations” and eventually came to be used to mean all those not of the house of Israel. It is first used in Genesis with reference to the descendants of Japheth (Gen. 10:2–5). As used throughout the scriptures it has a dual meaning, sometimes to designate peoples of non-Israelite lineage and other times to designate nations that are without the gospel, even though there may be some Israelite blood therein. This latter usage is especially characteristic of the word as used in the Book of Mormon. ...
So there are 2 cases:
- Joseph Smith was a descendant of House of Israel (Not a Gentile, scripture doesn't apply):
In Of the House of Israel it says
President Young identified Joseph Smith as a “pure Ephraimite” in the above quotation, so far as the Prophet’s family or blood lines were concerned, Brigham Young and others have recognized that (1) Joseph Smith was from a Gentile nation and (2) some of Joseph Smith’s progenitors may have come from bloodlines other than that of Ephraim. (See Journal of Discourses, 2:268.)
As this may bring up other potential contradictions about Joseph Smith not being a Gentile please continue reading said article
Thus, Joseph Smith was of the house of Israel so far as his family or blood lines were concerned, but he came from a Gentile nation and thus might also be considered a Gentile in the political or geographical sense.
2. Joseph Smith was/wasn't a descendant of the House of Israel AND was missing the gospel (Gentile-scripture applies)
Expanding the scripture 3 Nephi 15:23-24
23 And they understood me not that I said they shall hear my voice; and they understood me not that the Gentiles should not at any time hear my voice—that I should not manifest myself unto them save it were by the Holy Ghost.
24 But behold, ye have both heard my voice, and seen me; and ye are my sheep, and ye are numbered among those whom the Father hath given me.
I will now offer some speculation or alternate interpretations as I can't find anything by the Church of Jesus Christ of Latter-day Saints specifically about this verse and how it ties to Joseph Smith.
Jesus is saying he will not speak directly to those who haven't been converted or felt the Holy Ghost first. If they have been converted(touched by the Holy Ghost) then Jesus can speak to them. From JSH 1:12 one can see Joseph Smith was moved by the Holy Ghost after reading James 1:5
12 Never did any passage of scripture come with more power to the heart of man than this did at this time to mine. It seemed to enter with great force into every feeling of my heart....
and after his prayer Heavenly Father and Jesus appeared and spoke to him, proving that Joseph Smith (if initially a Gentile) was no longer considered one because he had faith and acted on prompting of the Holy Ghost (so Jesus could appear to him).
In 3 Nephi a similar situation can be seen, some of the survivors before Christ appeared were not faithful followers of Christ (see 3 Nephi 9:24-25), but Jesus appears and teaches the people because they repented.