问题
I would like to create music player, with a textView displaying lyrics of MP3 being played. The lyrics should displayed in sync with music.
I want to know that how to get lyrics and for display the text I refer this example.
Any suggestions on how I can do this? I am stuck in this.
Thanks in advance.
回答1:
Use the following music metadata library.
http://javamusictag.sourceforge.net/
You can go to documentation and look for Lyrics tag and follow it. Normally you would open the mp3 file and extract the vaule of the Lyrics tag. Note that this may or may not be available inside the mp3. (I suggest you use a tagged mp3 for testing) If the info is there. You will be able to extract it as a String or a buffer.
That info will look like this
[00:02]Let's talk about time
[00:05]tickin away every day
Now you just need to display the line according to the time given at the front of the line. This should be simple enough, just do some string operations.
回答2:
As brandall wrote in this answer, there is no native way to convert audio files to text in Android. However, you could use the libraries he suggests in his answer (Nuance and A&T look good to me).
As an alternative, I would use an API to get the lyrics for the song such as chartlyrics.com.
Now you have the lyrics, but syncing them with the song is very difficult. I don't know how to do it and would display the whole lyrics to let the user scroll through.
回答3:
you can use speechToText for this
回答4:
I think the best way would be to use lyrics as subtitles. If you look at a subtitles file, you will see that it has the following format
time string
You need a lyrics file to be like that. Read in the lyrics file and then display lyrics on the screen at those specified times.
Hope it was helpful.
来源:https://stackoverflow.com/questions/16939223/how-to-display-lyrics-as-per-song-playing-in-android