I am currently working on an IOS spelling app, where I am calling the merriam-webster dictionary API and populating my firestore database with words, their definitions, part of speech, pronunciations, etc. In the app, there are quizzes. When each word is asked, a pronunciation needs to be played. However, I am struggling with fetching the right url from my firestore database and playing it.
If you can help, please reply and I will share my code. Thank you
@Akr1040317
Hi Akshat,
What does the url contain that you are having trouble accessing in Firebase?
So essentially, the url is a call to fetch an audio file of the pronunciation of the word being asked. for example, to get the pronunciation of the word voluminous, you would go to the following url. https://media.merriam-webster.com/audio/prons/en/us/mp3/v/volumi02.mp3 . The issue is, to access the specific file, you have to change the “volumi02” part and replace it with the audio file name of each word. I have all of the audio file names stored in firestore already, but am just having trouble pulling the name, concatenating it to the url, and then playing the audio when quizzes are run.
That seems to be a bit of a problem in that the mp3 file is named volumi02.mp3
yet the word is voluminous
so I’m not sure how you are going to map that word to that filename unless you have some kind of translation table set up.
For the sake of argument, let’s assume that this example above is a word the person wanted to get the pronunciation for.
The word is voluminous
and let’s assume, again for the sake of argument and simplicity, that the audio filename is voluminous.mp3
let wordToPronounce = "voluminous"
let urlString = "https://media.merriam-webster.com/audio/prons/en/us/mp3/v/\(wordToPronounce).mp3"
where \(wordToPronounce)
is using string interpolation.
If the audio files don’t match the word exactly then you’ve got to have some sort of translation table which is looked up to return the actual name of the audio file.
The could be done using a dictionary which you would have to populate up front. It would be a massive dictionary since the Mirriam Webster has 470,000 words.
I am using the merriam webster api to populate my firestore database. The api returns the file name for the word. The issue is in dynamically playing the pronunciation in my app. If possible, could I get your email and show you my code so you can have a better idea.
Why fill your db with data that exists and can be fetched from the API? You should just use the API directly
You store sound files in Firebase Storage and a reference to the file in Firestore too (not sure if you specifically said this) but you wouldn’t put the audio file directly into Firestore
I will direct message you and you can respond to that private thread.