The Seven Joys and Sorrows of St. Joseph devotion’s origin is traced to an incident involving two Franciscan priests traveling in a ship along the Belgium coast. A storm hit, and the ship was sunk. For three days and three nights, the two priests clung to a plank and prayed to St. Joseph. Then, at one point, in youthful form, the spouse of the Virgin Mary and foster father of Jesus Christ appeared to the priests, guided them to safety, and taught them the practice of reciting seven Our Fathers and seven Hail Marys in honor of his Seven Sorrows and Seven Joys.
Here is the PDF with the words for both the "Short" way that we pray on the podcast episode and the "Longer" way that is prayed traditionally.