I read up a little on Edison's invention and a couple runners-up, and it seems to me unlikely that anyone before an 1800 level of general scientific and engineering development would stumble upon a mechanical means of both recording and replicating sound.
I believe the kind of sounds one gets rubbing sticks along various surfaces are categorized as "stridulations," and perhaps a kind of sonic writing or printing might be developed, sort of analogous to a player piano, whereby strips of metal or tablets of ceramic or some such means can play scripted sound sequences, as a kind of music. This is entirely different from making a devise that can record sound in reproduceable form on some medium.
Edison himself was led to the project of making direct audio recordings via the process of developing means of recording and then replaying telegraphic signals. So actually in his case the telegraph and telephone were necessary precursor tech. Now other people than Edison had a different mental path leading perhaps toward a comparable system had he not preempted them. But in all cases the concept of sound as a kind of wave was preexisting.
Then, assuming that some philosopher in a world considerably less advanced in general science and tech than say 1820 OTL just stumbles for personal reasons on the wild notion sound is a kind of wave, would they require the level of analysis the most advanced scientists and mathematicians of the late 17th century brought to bear on it? Or is the merely intuitive notion of a rise and fall of some not too well defined quantity they might or might not realize was air pressure sufficient? One thing we should bear in mind when we visualize sound as a wave on a graph of some kind is the concept of constant flow of time faithfully reproduced. It is one thing to have a general picture of sound as waves and another to successfully reproduce sound by faithfully recording the
rate of change of pressure at any instant. Theory need not be too esoteric if one has a means of recording on a medium that faithfully maintains a constant relationship between the pressure level recorded and the passage of time. So--at a minimum we need for the recording machinery to be advancing along a medium at a constant rate, or anyway if it changes, for the change to be reproducible. We therefore need pretty sophisticated mechanical engineering, to guarantee that the rate at which say a needle cuts into wax along some track to record the sound is constant, and that playback happens at the same rate.
Then, assuming for the moment that someone comes out of the woodwork bearing the
Antikythera device and says hah, complex gear work was well known and precision made in the Hellenic age already, I would say yes, clearly a few very fine craftsworkers, presumably affiliated with some temple or library under the patronage of a handful of very great kings or tyrants could achieve it for obscure purposes, but then note that such precision vanished from the European world until the 14th century developments of various clock works. But the crucial thing here is, turning or advancing a bar or something like that at a precise rate, and I think for that true clockwork in the sense of actual timekeeping devices--such as the springs inside a mechanical watch, or the pendulum, are needed to regulate the rate of motion. Was that kind of knowlege and craft available in the Classical era?
Meanwhile while some sort of clocklike escapement mechanism strictly and reproducibly regulating the rate of advancement on a recording medium must exist, so too must a suitable recording medium. The OP seems to assume that suitably perfectly round cylinders, and suitable forms of wax to coat them uniformly in, or sheets of tinfoil (which Edison first used) are just lying around waiting for some inventor to order them combined into suitable phonographic cylinders. What is the warrant for that?
That is exactly the difference between an inventor in the Hellenistic age and one in the age of the Industrial Revolution; in the former, only a very few great centers of learning under the patronage of a very few mighty and rich kings would have a great many oddities of strange goods from around the known world stockpiled there, and armies of more or less skilled craftsmen to be ordered to make things at the whim of some philosopher. Whereas in the early 19th century, after several centuries development of preferential access to global markets, European developed cities tied into these global trades would display a range of curiosities grander than any great Hellenistic tyrant replicated in thousands of dusty, musty obscure little shops. I suggest that to get an invention, it is not enough to have a few dozen instances of the predecessor tech lying around in some region as vast as say the Mediterranean. We need a certain critical density of availability of necessary elements for a combination of them into a new invention.
Therefore I think it stretches probability to have an invention of a phonograph earlier than the era in which clockwork became common in Europe, and then the invention must focus on the problems of how to get a predictably uniform batch of some recording medium mounted on a suitable device. Very easy to do the latter in the mid-19th century, much harder some 2000 years before.