Best Practice - How to use audio on the internet in DAB

L.S.
Our team have recorded over 2000 lexemes and example sentences in FLEX and these can be played in the DAB created app if the media is included in the .apk as .wav. FLEX records in the .wav file format, but according to DAB it is possible to use a smaller .mp3 file instead:

My question is, what is best practice here:
1.) include .wav files in as media in DAB? Expecting the app to be able to find the .mp3 file with the same name?
2.) include converted .mp3 files as media in DAB? Again expecting the app to be able to find the file?

Any help from your experience will be greatly appreciated.
Bart.

1 Like

WAV files are usually (always?) uncompressed, so not a good choice for either including in the APK or streaming. I would convert them to mp3s (perhaps with audacityā€™s Macro feature) and make them mono, maybe 24 bit, 44 or 32 khz and see how they sound. Add the mp3s to DAB. You can also try webm which can potentially save you quite a bit of space. Select the audio files in DAB, right click and choose Convert Audio Filesā€¦ Choose webm as the file format and perhaps leave the other settings the same. Note where DAB creates the files. You will need to remove the mp3s and add the webm files in DAB.
Disclaimer: I donā€™t use DAB so Iā€™m assuming it works the same way as SAB with regards to converting files!

Thanks for these ideas Andrew. Indeed, using the .wav files makes for a very big application. But I was hoping to use downloading or streaming from the Internet. Although DAB offers that possibility, I cannot get it to work. Maybe it does not work and it could still be an unsupported feature.

I had already done the conversion to mp3 with other software to be able to include the smaller files. Sadly, SAB still lacks several of the audio features that SAB already has. The audio edit menu currently has this:


So no webm support I think (although it is mentioned in the text there ā€¦) At least there is no convert to webm option.

One assumes that basic (new) SAB features trickle down to the other family members, but I think it has been a while ā€¦

If audio is imported into flex, it can not be used by DAB. (I have no idea why this is so). So, currently only audio recorded (not imported) with Flex (22.000Hz mono) can later be played by DAB.

In any case, even though flex uses .wav file internally, the files to specify in DAB are the .mp3 files like you pointed out.

L.S.

It would be nice to know if there is evidence of the feature that was announced in version 8.2 of DAB actually works:

  • Added support for download and streaming of audio files

I have tried to set this up for audio recorded with Flex (not imported), and am using the same internet ā€œbucketā€ as with SAB ā€¦

If there is a way to make this work, I would really be good to know.

So, any confirmation (from experience) that DAB can actually stream or download audio recorded by flex would be greatly appreciated.

Bart.

Hi Bart,
I can convert the audio to webm for you if can post it somewhere for me to grab. Regarding downloading and/or streaming, Iā€™ll have to defer to someone else for that. I know youā€™ll need it on an https site.

Thanks for your offer to help Andrew. But I would want to know beforehand if DAB can actually play webm files. The problem seems to be that not many DAB users have used audio. So I am waiting for some kind of confirmation.

Iā€™ve been trying to tinker with audio downloaded/streamed for a few months. I have been able to get the dictionary audio to download and stream successfully with a LIFT dictionary. However, I canā€™t get it to work with an XHTML configured dictionary. I have the audio files stored in a git repository. In the long run this isnā€™t what git is for, but it works well enough for a few audio test words. Iā€™ll post more if I manage to work it out.

Hello Dave,

Thanks for sharing that success. I also started with LIFT based dictionary creation. But since, I have not tried a lift based output again since it is much less flexible compared what one can do with xhtml.

So far, I have not heard that downloading and/or streaming works with an xhtml created dictionary. (could it be a bug?)

So I think I figured it out to some degree. I ran the XHTML based dictionary app in debug mode in Android Studio. And when I clicked on the play audio icon, the logcat gave me this:

Unexpected exception loading stream
java.lang.SecurityException: Permission denied (missing INTERNET permission?)

And on and on with the rest of the downstream errors.

Since Iā€™m not much of a programmer, a quick look up seemed to indicate the AndroidManifest.xml should have - uses-permission android:name=ā€œandroid.permission.INTERNETā€ in the file. It was nowhere to be found in the app built off of XHTML.

However, when I loaded the dictionary based on the LIFT file, which does play audio, uses-permission android:name=ā€œandroid.permission.INTERNETā€ was right there in the manifest.

When I compared the two I realized that I had analytics set up for the LIFT version but not the XHTML. And analytics requires an internet connection. Once I added analytics to the XHTML version, it added the permission.INTERNET to the AndroidManifest.xml file and now it works.

So I think the intention is that when weā€™re in the Media>Audio>File Source tab, when we make the source ā€˜downloadā€™ it should automatically add internet permission to the AndroidManifest. But itā€™s not. But the internet permission can be added by forcing it via the analytics tab. You would just be stuck if you donā€™t have analytics setup unless they fix things with an update (as if I know what Iā€™m talking about :slight_smile:

The one thing I canā€™t tell you Bart, is whether webm files will play. Mine are .mp3.

Thanks a lot for that help Dave.

I indeed did not have analytics activated. I added it and this is what happened:

  • at tapping to play audio (stream) the app notices when internet is off:

image

Switching it on then reveals an error message which seems to come from SAB code: (as if the code expects the audio reference to reside in a book collection ā€¦)

But sadly, that audio does not download or play: (also not in bluestacks ā€¦)

I tried all the combinations of 1) just streaming 2) both and 3) download only. In none of these will the audio play from the internet.

I feel like throwing in the towel at this point ā€¦ and just go with including the audio in the app.

Would you want to attach your apk? Iā€™d be happy to throw it into Android Studio and see if thereā€™s anything I can see. Iā€™m not great at creating things from scratchā€¦ but I can usually follow the bread crumbs backwards and sometimes arrive at answers.

A second question would be, where are you storing your audio files on the internet? Sounds like youā€™ve got them working to download from the internet from SAB. If you give me a link, I could see if I can get them to work on this end with a setup Iā€™ve got working here.

Hereā€™s a summary of some of the things weā€™ve discussed in public and private messages if it may help others get audio streamed/downloaded from the web into their configured dictionary projects:

-audio files have to be on the web in a place with a static url address
-the storage location must be public
-some hosts have added information in a URL that is required to access the static file. For example, GitHub requires adding raw.githubusercontent.com to the URL to get the static address of the files. This would need to be noted when you set your Audio>files source URL. Also all URLs have to be https and not just http.
-The app requires internet permission in the AndroidManifest.xml to stream/download audio. But just marking that the files should be stored on the internet in the Audio>File Source does not seem to turn this on. It can be forced to add the permission by adding analytics to the project. Perhaps there are other ways but I donā€™t know them.
-The process for audio files moves like this: Flex>DAB Audio File source window>Web Host

The audio file name generated in your Flex AudioVisual folder cannot be changed. It must be the same when used in all three of these locations. The AudioVisual folder is also exported from Flex to the same location as your XHTML file whenever you export. The audio file type can be converted. Mixing file types can have mixed results. This is what Iā€™ve seen:

Flex>DAB>Repo
.wav>.wav>.wav - works
.mp3>.mp3>.mp3 - works
.wav>.mp3>.mp3 - works
.wav>.wav>.mp3 - does not work

Supposedly DAB supports webM. but Iā€™ve not experimented with it or other possible configurations of wav and mp3

1 Like

Gentlemen, this is tremendous work, this must have taken a lot of effort. Thank you all from us present and future audio users!

I forgot to put one other important thing in the summary post above. It doesnā€™t seem possible to use audio files that use unicode characters (ex. ŋ or nĢ°) in the file name. But Flex automatically saves itā€™s .wav recordings with whatever unicode characters are used for an entry. In this sense you do need to change the flex generated file name before you begin the process of moving things to DAB and your web host. I use the windows app Bulk Rename Utility.

  1. In bulk rename utility, browse to the AudioVisual folder inside your Flex project folder (not the one exported with the configured dictionary)
  2. Find and replace the letters you need to. For me I have to change ŋ>ng and nĢ°>ny
  3. Since you changed the filename of the audio Flex would reference, now you need to make sure to relink Flexā€™s database references to the new file name.
  4. In Flex go to bulk edit entries>bulk replace. Make sure to add columns for any category with audio entry. Then set up your audio column as your target field and run the same find replace you did in Bulk Rename Utility.
  5. If you decide to bulk convert your Flex generated .wav files to .mp3, you would also need to use Flexā€™s bulk edit entries>bulk replace to change the file extension in each possible audio column. Otherwise, it will continue to read, and export, the .wav files with your XHTML. And if you keep the .mp3 and delete the .wav files without making the change, I believe Flex just wonā€™t do anything since it wonā€™t be able to find the referenced file.

Just as in the above post, the renamed file name without the unicode characters needs to be used for all three sectionsā€“Flex, DAB, Repo.

1 Like

Hi Dan, thanks again for your help with this. I hope to be able to try it all out tomorrow. I will keep you posted.
Bart

@bart_eenkhoorn1 , Iā€™ve been following this thread and thats because Iā€™m looking at streamline a workflow for language learners while they are doing these isolated recordings in the early days and having an easy way to set them aside and eventually incorporate them into DAB. Thank you for posting what youā€™ve found. Iā€™ll be digging into the details of XHTML and LIFT formats as I might be avoiding FLEX altogetherā€¦at least right now. Iā€™m wanting to use DAB in the beginning more as an audio reference for language learning where I could easily search in English/French/vernacular for an entry and then immediately listen to its audio recording(s).

Was the reason youā€™re wanting to use the downloading/internet option so that you can limit the .APK file size? Iā€™m working in a more limited internet context and especially when showing this to new people, it would be very important that one phone that had DAB with all the audios would be able to send that to another phone locally without internet. Is there an easy way to do this? Perhaps someone else, could direct me elsewhere where they specify this.

Hello Tyler, I thought I would write down step by step what I did to make the audio playable. Basically following DaveRā€™s advice, but with some added screen shots. See pdf here.

To answer your questions:

Was the reason youā€™re wanting to use the downloading/internet option so that you can limit the .APK file size? > YES (with +1000 example phrases recorded, the app becomes big)

Iā€™m working in a more limited internet context and especially when showing this to new people, it would be very important that one phone that had DAB with all the audios would be able to send that to another phone locally without internet. Is there an easy way to do this?
Yes and no. If the audio in inside the app, the copy-app feature of the app does the trick. If the audio is not inside the app but you can distribute the audio with the app on SD or USB sticks, then the audio can be located in a folder on the phone. Thus no download is needed.
Whichever way, the 1st thing I would propose is to convert to mp3 and use that with DAB. (Flex uses .wav only). It will make you app much smaller if you include the audio.
Then, you could (also?) offer a small(er) app with audio included or an app with audio in a folder on the phone that need to be copied with the app. The fact that a user may not beware of the need to also copy the audio is a problem, therefore offering download as well could be a (good) solution for these situations ā€¦