Ttwhelper App

ttwhelper.apk version 0.1.1

With the Ttwhelper app you can create your .wav files by importing the makewavs.bat file, which can be found inside the workout.zip archive file (or whatever name you gave to the .zip file when you generated the workout). makewavs.bat will be found in the ifit/Tread folder (for treadmills) or the iFit/Bike folder (for bikes) or the iFit/Incline folder (for incline trainers) or the iFit/Elliptic folder (for elliptical trainers). Ttwhelper is designed as a helper app for the online workout generator at http://mwganson.freeyellow.com/workoutgensdonline, but it can also be used as a standalone text-to-wav generator and as a front end for the ffmpeg file conversion utility.

In order to generate your .wav files for your workout all you need to do is download the generated .zip file and extract it somewhere on your android device (e.g. /sdcard/Download), and then select IMPORT MAKEWAVS.BAT with the Ttwhelper app and navigate to the folder where your makewavs.bat file is located. The Ttwhelper app will parse the makewavs.bat file and use the contents within it to create the text-to-wav files (placing them in the same folder as the makewavs.bat file).

The files will be created using the default text-to-speech engine (and default voice) you already have installed on your android device. There is a Speak button on the app you can use to test the text-to-speech engine. I recommend you download and install the Google Text-To-Speech app from the google play store and set it as your default speech engine. If you dig around in the settings you will find you can also download some other voices, too.

Record Option

If you would prefer to record your own .wav files rather than use a text-to-wav function you can easily do so with your Android device using the microphone and Ttwhelper to record the files. The best way to do this is to use the word "record" as the first word in your text to be synthesized in your play line. Here is an example:

play auto say record we will be increasing the speed here to 3 miles per hour

You can think of "record" as a keyword that the Ttwhelper app will interpret to mean you wish to record this file yourself rather than have it synthesized with the text-to-speech engine. Ttwhelper will bring up a recording screen in which it will use "we will be increasing the speed here to 3 miles per hour" as a prompt for the purpose of helping you remember what it is you wanted to say in this file.

Convert Only Option

If you have an audio file you have already recorded that you would like to convert to the appropriate format for the iFit system you can use the "convert only" option to tell Ttwhelper you wish for it to convert the pre-existing file rather than synthesize or record a new one. In order for this to work you must ensure the file is in the same folder as the makewavs.bat file before importing the script into Ttwhelper. Here is an example of how to use the feature with a pre-existing file named file0001.mp3:

play file0001.mp3 say convert only

Ttwhelper has the ffmpeg file conversion utility embedded as a binary resource. It simply calls ffmpeg and passes the proper parameters for the conversion to the iFit .wav format. It should be able to handle most ffmpeg parameters except for those that require using an external library, such as libmp3lame. For that reason, you cannot output mp3 format, but you can still import an mp3 file and convert it to the iFit .wav format.

Using Ttwhelper as an Ffmpeg Front End

(You do not need to specify any ffmpeg options if you just want to create .wav files for your iFit workouts as these are already set to the necessary defaults.)\n\n For this you will need to edit the makewavs.bat file (or create your own). The script file *must* be named makewavs.bat. The following special ffmpeg options are supported:

ffmpegoutfileparams, ffmpeginfileparams, and ffmpegoutfilename. Here are a few examples:

ffmpegoutfileparams "-c copy"
ttw file0123.wav "convert only"

The above would call ffmpeg as if you entered the following command line:

cp file0123.wav old.file0123.wav
rn file0123.wav file.file0123.wav
ffmpeg -i file.file0123.wav -c copy file0123.wav

Ttwhelper will copy your original file to old.filename, then renames filename to file.filename, and calls ffmpeg with filename as the output file. You can also specify a filename to use as the output file:

ffmpegoutfilename "myfilename.wav"
ttw mymp3file.mp3 "this will be synthesized into myfilename.wav"

If you don't specify an output filename using ffmpegoutfilename Ttwhelper will simply use the same name for the output file and rename the input file as old.filename. The ffmpegoutfilename parameter gets reset after each invocation of ffmpeg, so if you wanted use it multiple times you need to repeat it each time you want to use it.

Note that for recorded files (files you record using Ttwhelper) only the last ffmpeg parameters you specify in makewavs.bat will be used, and those same options would be used for all of the recorded files.

Note also that if the ffmpeg command line calls for the use of quotes or double-quotes you should just leave them out as it will only confuse Ttwhelper as it tries to parse the makewavs.bat file.

In this example, we take a file named myfile.mp4 and convert it to an animated .gif file:

ffmpegoutfileparams "-vf scale=160:90 -s 10"
ffmpegoutfilename "animated.gif"
ttw myvideo.mp4 "convert only"

The scale=160:90 bit tells ffmpeg to set the output file to 160x90 pixels. The -s 10 bit tells ffmpeg we want 10 frames per second in the output file.
(Adapted from an article at http://www.bugcodemaster.com/article/convert-video-animated-gif-using-ffmpeg)

Consider the following command line usage of ffmpeg to speed up a file:

ffmpeg infile.mkv -filter a "atempo = 2" -vn output.mkv

But you would implement that as such using this app:

ffmpegoutfileparams "-filter a atempo=2 -vn"
ffmpegoutfilename "output.mkv"
ttw infile.mkv "convert only"

Notice how even though the double quotes are used in the original command line way of doing it, they are left out when using Ttwhelper.

If your phone is rooted and you'd prefer to use ffmpeg directly from your terminal you can find the ffmpeg binary at:

/data/data/com.mwganson.ttwhelper/files/ffmpeg

You can simply copy it to your /usr/local/bin folder for easy access. You will also find 2 more files in the files folder:

ffmpeg_x86 and ffmpeg_neon. The ffmpeg_x86 file has been compiled for use on x86-based Android devices. The ffmpeg_neon file has been compiled to take advantage of the advanced features some ARM processors have. The only advantage would be (as far as I know) improved performance (faster file conversions) if your processor supports the neon functionality. If you want to be adventurous you can rename either ffmpeg_x86 or ffmpeg_neon to simply ffmpeg and Ttwhelper will use that version of the file for the ffmpeg operations. Of course, you would need to first either delete the original ffmpeg binary or rename it to something like ffmpeg_original before renaming one of the other files. (You would need to repeat this process if you reinstall the app or clear its storage cache.) The binaries can also be found inside the .apk file, inside the assets folder, and extracted using something like 7-zip.

This is my first ever attempt at writing an Android app, so, well... it is what it is. I consider it very much in the beta testing phase of development. If you encounter any issues or if you have any questions or comments, e-mail them to me at mwganson at gmail dot com with ttwhelper in the subject line.

Changelog

New in version 0.1.1

Added ability to call ffmpeg directly from within the makewavs.bat file

Usage: ffmpeg [in file params] -i infile [out file params] outfile

Example: ffmpeg -i /sdcard/Download/myfile.mp4 -vf scale=160:90 -s 10 /sdcard/Download/animated.gif

Note: You must provide absolute file paths, e.g. /sdcard/Download/myfile.mp4.

You can also use ffmpeg_neon or ffmpeg_x86 for perhaps better peformance if your device cpu supports those features.

Also fixed bug (actually just added implementation of copying those files) where ffmpeg_neon and ffmpeg_x86 weren't being copied to the app files folder.