system
Given the following post, respond as if you're commenting on Reddit:
human
How do we know how to pronounce ancient Egyptian and Sumerian names?
gpt
For Egyptian, at least, it's because of the Ptolemaic pharaohs: Greeks who were pharoahs of Egypt.

During analysis of the Rosetta stone, which had Greek, Demotic, and Hieroglyphs on it. linguists realized it contained the exact same message in three languages. The importance is that they could read the Greek in its entirety because it's a known language. So, they knew the entirety of the message written in the other languages (though had no idea which symbols meant what yet) and could use that as a starting point. The Greek text contained the name "Ptolemy" and the Egyptians had encircled words in their hieroglyphs on the Rosetta Stone. The meaning of the circling wasn't known, but one guy thought that it might be because the word was an important name. Further, the only important name in the Greek text was "Ptolemy" and it stands to reason that the pharaoh's name would be pronounced the same in both Greek and Egyptian. So, he assigned the letters inside the cartouches to the sounds in the name "Ptolemy".

Fast forward a few years and someone notices an obelisk with the same word from the Rosetta Stone thought to be "Ptolemy" and another unknown name in a cartouche. Applying the sounds for the symbols in the "Ptolemy" cartouche to the new cartouche, the sounds matched up with what they should be if the name in the second cartouche was "Cleopatra", another of the Ptolemaic line with a Greek name. Following the same reasoning that the pharoah's name will be the same in Greek and Egyptian, The "Cleopatra" cartouche allowed them to match a couple more symbols with sounds. Now, people started looking at cartouches and applying this technique of replacing known symbols in the cartouches with their already identified sounds looking for partially translated words that could possibly be known famous Greek and Roman names of the time that could then be used to assign more sounds to remaining unknown hieroglyphic symbols in the cartouches.

Still, people believed that hieroglyphs were still not all phonetic and had some pictographs. Further, they thought that these cartouches may only be used for foreign names. Along the way, people naturally encountered more words in cartouches and when they started filling in the phonetic sounds for them, they usually made no sense because these were four thousand year old texts and not everyone who was important enough to get a cartouche then was important enough to be remembered all these millennia later. However, someone stumbled on a name in a cartouche that had some unknown symbols with some "esses" at the end. It had a sun symbol at the front and the guy (named Champollion) made a leap of intuition. He knew the Coptic language and knew that the Coptic word for sun is "re".  What's important is that Coptic is a language spoken in the near East well after the Egyptians who wrote hieroglyphs were gone, but Coptic was derived from Egyptian. Making the leap of applying that Coptic "re" sound to the sun symbol, he saw that the word in the cartouche he was working on could possibly be "Ramesses", the name of an EGYPTIAN born pharaoh with an Egyptian name. Making that assumption, he was able to assign a sound of "em" to an unknown symbol in the middle of that cartouche. He turned his attention to another name and saw an ibis at the front. Knowing that the word for ibis in Coptic was pronounced "thoth" and applying the sounds for the other symbols he thought he knew, he came up with the name "Thothmosis". These were both known to be names of ancient EGYPTIAN pharaohs. This not only proved that the cartouche was not just for foreign names but were also used for Egyptian names with Egyptian phonics. It also hinted at a close connection between Coptic and Egyptian Hieroglyphics. Champollion went back to the Rosetta Stone and would find a word in Greek and translate it to Coptic. He'd then find the word in Hieroglyphics that should match the Greek word and apply sounds to the symbols he knew and discovered that the sounds were in the proper positions for many of the Coptic translations. Ancient Egyptian was not Coptic, but he had proven that the two languages were REAL close.

The realization that Coptic held the key to the unknown sounds of the Egyptian language was huge; it allowed Champollion to read a word in Greek off a tablet like the Rosetta Stone, and use what he knew about the Coptic translation of the Greek words to start confidently filling in sounds for words that didn't have a name attached to them. It would be analogous to you speaking Russian and Italian, having a stone with the same message in Russian and French, making the connection between Italian and French, and using your knowledge of Russian to Italian translation to fill in unknown sounds in the French text. Over time, as he used Coptic translations to fill in more and more sounds, he got a fuller and fuller knowledge of what each symbol sounded like.

Still, because Ancient Egyptian wasn't Coptic and was only closely related, not every sound they assigned to a symbol was correct. They'd often come across words that were gibberish using this method and over time learned that some of their guesses at sounds were flat wrong. However, as more texts with repeated messages were discovered, they were able to use new cartouches to get new names they could verify and error correct the assignments the Coptic translations were generating. Further, the language DOES have pictographic elements, as well as some symbols that could be different sounds in different uses (think of how many ways you can pronounce the English letter 'g'), also some sounds that have different symbols in different uses (like English 'c' and 'k'), groupings of symbols that sound different from their individual sounds put together (similar to the english letters 'ght' in words like 'height'), etc. Over time, they could error correct and fill in these details as they really started to uncover the secrets of the langauge and ultimately master it.

That's the rough bastardized version of how Hieroglyphs went from an inscrutable pictorial language to a completely deciphered and known semi-phonetic language.

Read up on Thomas Young and Jean-Francois Champollion for the full story. It's fascinating if you're into codebreaking, which is literally what they did to decipher the Egyptian language. They had a plaintext in the Greek, a ciphertext in the Hieroglyphics, and cribs in the form of the cartouches and the Ptolemys and the connection between Coptic and the Egyptian language.