1

I am developing an app which contains text and recorded audio (in Persian-farsi). Is there any API that sync these two with each other. Is there any way to highlight the text when audio is playing.

2 Answers2

0

I think there isn't any standart api for that, because it sounds like a kind of specific feature. Providing full implementation of it would be so broad, but despite that i can give you a direction for research, because i think it is a good question.

You should create for each audio file some type of subtitles file, like srt, where parcelable words will be mapped with it prononciation time on the audio. After that, you should parse that file in your application to create a Map of period to word. As a result with using MediaPlayer callbacks it wouldn't be a problem to highlight text according to an audio time. This solutions gives you a possibility to add audio files with subtitles to your app dynamically. Of course you could hardcode that subtitles to your application directly and avoid this a bit complicated parsing process if you don't need such flexibility.

Community
  • 1
  • 1
Beloo
  • 9,723
  • 7
  • 40
  • 71
  • data is too large. this would take lots of times – alireza arvandi Oct 25 '16 at 12:48
  • @alirezaarvandi So you could try to [create subtitles automatically](http://softwarerecs.stackexchange.com/questions/4319/how-to-create-automatic-subtitles) and than just edit it. But it could be a bit tricky. Unfortunately you don't have another options except refusing this feature. Speech recognition in runtime is also not an option, because it should be run only for a short time and doesn't work excellent. Not in 2016 year thought – Beloo Oct 25 '16 at 12:59
0

I think i am too late to answer that question, also it is very difficult and time consuming but i suggest you but if you have multiple audios like audio1, audio2, audio3 etc and you are playing all one by one then in loop of Mediaplayer, you can highlight text by keeping record of text[if in array]. For example if text1 [in array] then play audio1. I implement this in listview like:

        mPlayer.start();
            a++;
            z=1;
            mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                public void onCompletion(MediaPlayer mp) {
                    if (a!=b+1) {
                        if(mPlayer != null) {
                            if(mPlayer.isPlaying()) {
                                mPlayer.stop();
                            }
                            mPlayer.reset();
                        }
                        try {
                            mPlayer.setDataSource("/mnt/sdcard/audio/aya(" + a + ").mp3");
                            mPlayer.prepare();
                            quranlst.setFocusableInTouchMode(true);
                            quranlst.setSelection(z);
                            quranlst.requestFocus();
                         quranlst.getChildAt(z).setBackgroundColor(Color.WHITE);




                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        mPlayer.start();

                        a++;
                        z++;

Where z is the text position. Hope this give you idea.

Uzair Qaiser
  • 156
  • 1
  • 11