Converting Text Ebooks into Audio ogg files

Text to speechI’ve recently started a job that requires a 1 hour commute each way, and so I decided to make the most of it by listening to audio books.  I’ve finished about 3 audio books so far, but I realize that I will soon run out of interesting content to listen to (I’ve been listening to LibreVox free public domain audio books).

Exploring the world of Text To Speech (TTS) software led me to first examine espeak, which had too much of a robotic tone for my liking.  I then stumbled upon Pico TTS on my cheap android tablet, which sounded too good to be true.  Looking around, I found a linux project that uses it, PicoSpeaker. Pico is a TTS solution from the company SVOX Mobile Voices, which apparently specializes in text to speech solutions for devices.  I’m not sure how the product ended up in linux as the packages sox and libttspico0, but they are their, and they work reasonably well.  The frustrating problem I found, was that PicoSpeaker didn’t accept large files.  So frustrating was this problem, that I continued to look around at different fixes.

I then checked out Festival, installed better voices, and still found the quality lacking in comparison to Pico TTS.  I played with the gain, rate, pitch to make the different voices sound better to me, but it failed to make a difference (I tried out the MBROLA and CMU Arctic voices, samples here).    Even though I could convert a complete file with these, they didn’t sound as good to my subjective ears.

To cut a long story short, much of my Saturday was spent on getting a TTS solution which would help me convert Text books to Audio books.  To fix the file size limitation problem, I split up the file into 100 line parts with:

split -l 100 -d -a 4 Ebook_ Text_To_Convert.txt

This creates a set of text files with no extension, starting at Ebook_0000.  Next I created the following script, which I named convert.sh:

#!/bin/bash

if [ $# -eq 0 ]
then
echo “Type the base name of the file to convert, followed by enter:”
read name

echo “Type name of author: ”
read author

echo “Type name of book: ”
read book
else
name=$1
author=$2
book=$3
fi

for f in $name*;
do
echo “Converting $f ..”
cat $f | ./picospeaker -o $f.ogg;

echo “Now adding tag information”

lltag –yes –clear -a “$author” -A “$book” -t “$f” $f.ogg
done

I run this script by making the script executable (chmod +x convert.sh) and provide it with the base name (Ebook_ in this case), the title of the Author (“Henry Thoreau” for example), and the title of the book.  Note that if any of those have spaces, you need to put the words in quotes.

The end result is a pretty decent sounding audio book, that I can actually play at 120% (with the -r 20 flag provided to picospeaker) with all of the words intelligible. Here is a 6 minute sample of the audio, uploaded on Picosong (Picosong seems to be like the imgur of audio links, pretty nice service).  This is a sample of it as I like to listen to it.

You may need an additional step to convert the audio into an mp3 format, and to do that, add the following before lltag:

ffmpeg -i $f.ogg -ab 128k $f.mp3

Note that this creates a larger file than the ogg, I’m not sure of the settings to make it better, but for now it will work.  Better to ship something working, than nothing at all.

Useful Tools for a Safe Internet Browsing Experience

magnifying-glass-300x200As I posted a few posts ago, Information: You don’t own it unless you take it, now I will provide the tools that will allow you to take control of your browsing experience.   The motivation for this post is that I’m discovering that some of the content that I enjoy on the Internet, is disappearing.

The following steps are listed in the order of most importance/impact, and are recommended by me to improve your browsing experience.

1. Update your Hosts file

A hosts file is used by most devices that access the internet.  When your browser needs to process a URL, it first looks at your hosts file to determine if any special rules exist for that URL.  By updating your Hosts file, you can make any attempt to load a malicious URL fail on your computer. You should consider installing a host file onto all of your computers and smartphones/tablets.

  1. Download a hosts file from http://someonewhocares.org/hosts/.
  2. Follow the instructions provided in the hosts file to install it.  I would recommend deleting the line in the hosts file which blocks adf.ly, since there is a decent amount of content (typically Minecraft mods) which is provided through adf.ly links.

2. Download Firefox and SeaMonkey

Why would you need 2 browsers?  To restrict and control what the websites you view, know about you.  I’ll also recommend some addons that will help protect you from being tracked by the advertising agencies such as Google or Facebook.

firefoxWhile Firefox doesn’t provide as many options as I would like, there are generally addons which fix the shortcomings of the browser.

 

seamonkey

SeaMonkey is a browser which is based on Firefox, but without the unnecessary changes to its User Interface.  It also combines a mail reader and address book to be a unified application for all of your internet correspondence.

3. Tweak Firefox

I recommend the following addons to improve security and your enjoyment of the internet.  Many of these purposefully break websites that you are viewing to allow You to control what content you wish to view.  Once you get these plugins installed and running, you may consider donating to many of them, since they really do make your browsing experience much better.

  1. NoScript blocks scripts from running on websites, many of which are designed to track you.  In the options for this plugin, under the General tab, you should enable “Temporarily allow top-level sites by default” and the option under which is “Base 2nd level Domains (noscript.net)”.  Under the Notifications tab, disable “Display the release notes on updates”. Generally when you visit a webpage, you may have to enable scripts, one at a time, to get the content to display.
  2. Adblock Edge blocks unwanted advertisements, and is based on Adblock. While many websites depend on advertising to remain in business, often they are not selective about what ads are displayed, and as a result, can install Malware and viruses onto your computer just from visiting a website.
  3. Startpage Https search replaces the insecure and privacy violated Google search engine with a search engine based on google, which removes the privacy problems (since Startpage is doing the searching for you).  Google is an advertising agency who releases free products used to gather information and sell their Ads.  Never trust a company who sells your information, and never provide such information freely.  If anyone can recommend a non-Google and non-Bing based search engine, I would be glad to hear it.
  4. Flash Block stops flash videos from automatically playing.  I’m not entirely sure who thought it was a good idea to have videos play automatically, but in my opinion it hampers the web browsing experience.
  5. Cookie Monster allows you to selectively allow, and delete, cookies for websites you go to.  Browsers are pretty broken in their current implementation.  A website like Facebook can not only interact with the cookie they hold, but also access all of your other cookies used in that browser.  Amazon updates your account anytime you search on amazon for anything, so by allowing the Amazon cookie to persist, they keep track of Everything you’ve ever searched.  Target does the same thing with shopping patterns and is very effective with it, detecting pregnancies and mailing targeted advertisements to expectant mothers.
  6. HTTPS everywhere allows you to have a secure connection between your browser, and the website you are trying to view.  With such a HTTPS connection, you can connect to a insecure wifi hotspot (or your work intranet for example) and securely conduct business.  Keep in mind that the URL of the website you are viewing can still be harvested, just not the content on that website.  Non HTTPS sites you view are sent in plain text, as well as all information you enter.  Look for the Lock icon next to the URL in your browser to determine if it is an HTTPS connection.
  7. Redirect Remover allows you to skip the middle man when trying to view links and contents.

The following addons are recommended to allow you to capture content easier, which can range from downloading all of the content on a website, to downloading full ad-free flash videos. One plugin is also provided to improve usability of Firefox.

  1. DownThemAll allows you to download all of the content you are viewing, to a selected folder on your system.  Useful for websites that directly host file downloads (such as a image hoster). Also get DownThemAll Anti-container.
  2. FlashGot allows you to download flash videos from some of the major video hosting sites.  This allowed be to download and keep a version of the video linked above 🙂
  3. Youtube MP3 Podcaster allows you to download flash videos as well, having two options can be pretty useful, I generally install both.
  4. Tree Style Tab shows your tabs on the left side of firefox, rather than across the top.  Given our obsession with wide screen monitors and laptops, I’m not sure why this isn’t more popular.  It allows you to have hundreds of tabs open where you can easily read the title of each (and have sub tabs).

4. Tweak SeaMonkey

Sadly many of my favorite addons available for Firefox, are not available for seamonkey.  Here’s a list of those I have found: Startpage HTTPS searchNoscript, NoRedirect, TrueBlock Plus (like AdBlock), HTTPS Everywhere (select Firefox to download), FlashGot, DownThemAll, DownThemAll Anti-Container, and Complete YouTube Saver.

5. Abandon Webmail

Email which is left on a server such as Google’s GMail, for at least 180 days, is considered abandoned, and can be read by any agency. While not paranoid myself, I do enjoy a certain sense of privacy, and I believe that a Court Order should be required to view my private information.  It is also important to keep in mind that Email is sent in plaintext, meaning everyone between your email server, and the destination email server can and will scan the contents of your email.  Email is just like a Post Card.  I would recommend using SeaMonkey as your email client, and set it up to download all of your email.

6. Secure your passwords

keepassYou should never let Firefox remember your passwords, because if someone gains access to your computer, your passwords will be easily harvested from your browsers.  I would recommend a password manager such as KeePass. Keepass allows you to save your passwords into an encrypted file, so that even if your computer is compromised, your passwords are safe.  It also provides a random password generator that allows you to create super strong passwords which are unique from other passwords you’ve used.

The general problem is that if the username and password for one website is compromised, many times that same username/password is used on different websites.  By having a unique username/password for each site, we limit the damage that can occur from our username/password being compromised.

7. Cleanup your Startup on Windows

ccleanerIf you are using the Windows OS, many programs that you install decide that they should start when windows starts, without providing you the option to disagree. CCleaner seems to me to be a very easy way to not only clean up things, but to remove unnecessary things from startup.  While I disagree strongly with their installation setup (trying to trick you into installing toolbars), there unfortunately doesn’t seem to be a better option.

8.  Perform your chatting using Pidgin

pidginPidgin allows for you to connect to different IM networks such as AIM, MSN, GMail Chat, Facebook, etc, without dealing with the interfaces for each of those.  Many of those IM clients come bundled with Advertisements, which may damage your system. I also download the Off The Record plugin which allows for secure communication over existing IM protocols.

9. Windows 7 Usability Tools

A part of my usual windows install includes installing Find and Run Robot, WinSplit Revolution, VirtuaWin,  and WizMouse.  These utilities allow you to quickly search for things, manipulate your windows, have multiple desktops, and to scroll inactive windows, respectively. I consider Windows quite unusable without these simple applications.

Conclusion

While it will take the reader some time to go through all of the plugins and applications presented, there generally isn’t a rush, so you can take your time to learn what each of them do, and decide if you trust them.  It has taken me over 5 years to find and use each of these tools, and I hope by presenting it in a logical format, it will take you less time to start being proficient in protecting yourself online.

Cheap Breadboard Arduino with Wireless Module

I see that there is a good amount of demand in the community for a cheap “Arduino” clone with wireless. Many people, while grateful of the Arduino community and organizers, are frustrated, because everything seems so darn’ expensive! $30 Arduino Board + $20 wireless thing + $15 proto board makes almost $100 just to get you running. If you somehow found JeeNodes, they are $23. A RBBB, which just has the processor, is $13. We can do better than that though!

If you’ve clicked on the caption, you’ll see that it is possible to make a breadboard Arduino for just $7. The problem is that we still need a wireless module. XBee’s retail for $23, which is a pretty robust solution (configurable up to 19200 baud in real world situations, can communicate just with serial, standard footprint so there are lots of cheap adapters for it). But it’s expensive. You can check out the RF Bee, which is a $20 wireless solution, which actually contains an Atmega168 (running Arduino)! It’s tiny form factor is awesome, but it is $20. A RFM12B radio retails for about $6, which is pretty decent. It even has a good library for Arduino to go with it. But we can do better.

How about a $2.50 wireless module, that has a good library to go with it? That would bring our cost to $9.50, excluding shipping. That’s my cup of coffee. The hard part is finding the individual components you need, which I will help you out. Finding the cheapest parts from 20 different places is great, but the shipping will kill you. I’ll attempt to minimize the shipping cost, by ordering from a few places, getting what we need from each.

Parts:

Extra:

That brings the total for the required parts to $5.44…  wow.  Shipping would be about $5 from each place (roughly), but it isn’t included in our consideration.  Getting some different colored wire wrapping wire will help you out a lot, as well as getting a wire wrapping tool (which can be very useful).  Adding the $2.50 wireless module would bring you to $8, pretty nice!  This number scales down as you buy more, so if you buy enough parts to build 3 or 5 of them, it will be cheaper. Consider the pricing levels of the ATmega328p chips to figure out how many you should buy (you should always get spare protoboards 😛 )

I’ll do a post sometime soon on my recommended set of parts to have.  A quick update on the Carduino: I still haven’t put it in, I need to get up the motivation to start modifying wires and integrating it into my car.  I know eventually I’ll get to it, but in the mean time, I’m exploring the idea of making my own Watt Meter, with SD logging.  It would be hard to compete with that, but if I’m smart, I can end up with a meter that can work in RV’s, like this one does, using an external Shunt (small value, high wattage, precision resistor).  Till then!

Edit:  If I could make a schematic for this cheap Arduino breadboard, I would take the parts required to make it work, and customize it for each application after it.  The arduino is great as a platform, but for completed projects, typically the soldering connection is constant.    Here is a quick guide on wiring up the nRF24L01+ to a Arduino.  By following the Instructables post, you can get a general idea of how to wire it up.  I got the idea for the voltage regulator + resonator from JeeLabs, so the v5 schematic would be what you use to wire up the rest of it.  I hope this helps!

Carduino completed, now I need to test it (as well as wire up ethernet cable for display)

This slideshow requires JavaScript.

If you notice I rearranged things a little bit, and I added a temperature sensor to the display (to record car temp, why not?). Wiring everything up with wire-wrap wire is so much easier than before. Tomorrow I’ll need to do some testing (detecting shorts, seeing if the voltage regulator is working), and once everything is cleared, I’ll put a processor in it and flash it with the latest firmware 🙂

Presumably later this week I’ll be putting it into one of my car’s. I plan to use a 2 part epoxy to attach the temperature sensors to the engine, transmission, and radiator. Considering JB-Weld, but I’ll need to check its upper temperature.

Looking forward to getting this project out the door, so I can start on the next one (Automated Gardening – Sati).

Carduino main board layed out – Part 2 of 3

This slideshow requires JavaScript.

Spent longer than I anticipated organizing how everything would fit. I typically take a picture before I start soldering things, because often, things will have to come off before I can solder everything on.

As you can see, I bought some surface mount parts to use, since through-hole packages weren’t available. It looks like just soldering wires onto them will work out 🙂

This is the idea that has driven me this far in my robotics: When making decisions, do not base your choice on what you want, base it on who you want to become. A short example would be choosing between making a circuit, and playing some Minecraft. You may want to play the game, but you want to be the person with plenty of projects that not only make you more experienced, but actually solve real world problems that you face.

Because of how our brains work, we will either establish or re-enforce the pattern of making things (in this case some electronics :P). If you do this enough, it will be a natural choice, ensuring that you are who you want to become (because you would be doing all of the things the person you want to become, do). Progress!

Carduino Half-way Done (well, just the display)

This slideshow requires JavaScript.

The main reason I haven’t posted in about a week, was that the complexities of the Carduino project made it harder for me to start building the project. I got the GPS working with the TinyGPS library, but I ran out of ram (again), so I considered (again) if I should rewrite it to make it fit. It was bogging me down I decided that I didn’t need that feature (it was on the nice-to-have list anyways).

The next thing that bogged me down was attempting to determine how much protection I would need to protect it against transients on the battery lines. There are chips out there that you can use, TVS, but ultimately I decided to just use protection diodes, like here. I’m also not only using a reverse blocking diode, but a zener diode to handle transients above 15V (the regulator only takes up to 16V, MCP1703-3302E). I have no idea if this will protect it adequately, but I’m not afraid of taking risks.

The last thing that bogged me down was trying to figure out how to sleep non-essential circuitry. My plan was to use a N-channel mosfet to do it, but when I did a very rudimentary test (physically disconnecting ground from display board), the LED’s still remained lit, and even changed. Apparently the two shift registers got enough low voltage from the control pins. When I tried it on the wireless module, reconnecting it reset the board, not good. So I’m going to use a switch to turn it off and on.

Cue story about Russians using pencils in space, whereas NASA redesigned a ink pin for millions. IF I want to improve on it, I can add any of these features, but for a first revision board, this does the job, and does it well.

A quick explanation on the display board. It requires 6 lines for now, and I will use ethernet cable to connect it to the Carduino. It will be placed near my instrument panel, and it is tuned so the brightness at night time won’t blind me (hopefully). It has two shift registers (74HC595) which control an 8 segment BCD display (single bcd digit with decimal point), and 8 LED’s. The Carduino will quickly cycle through the various readings (4 temp, 1 voltage, 1 ?) and display it’s level, as well as a number associated with it. If any over-temperature event occurs, it will sound an alarm using a Piezo speaker. It will also light up the decimal point, so i can quickly see if any reading is abnormal.

Tomorrow I’ll wire up the main board for the Carduino. Putting it in my car will be a fun challenge as well.

Coming up i’ll be starting a new project, a Garden automated with Arduino (controlling watering, lighting, and more). A quick update for the Controller 2.0 project, I received two different wireless nunchuck’s, and both of them work flawlessly with it 🙂

Progress update on Carduino

So these past few days I have been working on the Carduino. Adding the GPS, parsing the output, saving it and displaying it. But adding that library, which works, increases the usage of the flash. Since I only have 2kB of flash on this MCU, it resulted in using more memory than I have, never a good thing.

So to wrap up this project, and move onto others, I’ll be settling on not having GPS data saved. The main things, temperature monitoring and displaying / alerting, is complete. I even save it to an SD card, which is a nice feature. As I’ve heard before, the first iteration of a device shouldn’t be perfect, nor strive for perfection, since doing so will make the project drag on and on (which has sort of been happening with this carduino project).

So I’ll be making the circuits in the next few days (1 board with BCD, LED’s, and 2 shift regs, 2nd board having processor + BT serial, and SD card), housed in a cheap $0.24 case mounted in my glovebox. The BCD board will be mounted near the speedometer with dimly lit LED’s so that I’m not blinded at night. Ethernet cable will connect the BCD board to the main board, another cable will connect the temperature sensors to the main board (with a diode + resistor protection).

Sometimes you’ve got to abandon a idea or feature in order to get a project built,and many times this is good, since you can always make improvements in the second version.

Sleeping Carduino

Thanks to the great examples here, I now have the Carduino set to monitor the battery voltage (A0) and if it detects that the battery voltage is below a certain level, it sleeps. Once I get the BSS123’s, I’ll be able to control the power going to the BT serial as well as everything else (power off everything, then sleep, wake up, power on everything). Pretty awesome!

I updated the RTTTL example to correct two bugs I found, with the end result that it works better, without messing up on the first note. The updated example is on the same pastebin link as the original.

I also got news that my 3 wireless nunchucks have shipped, so I can expect to be getting them at the end of the month. That’s all for tonight 🙂

Future projects:
Garden monitor + watering (using windshield washer pumps)
Slash Arduino (if I get the FPV camera stuff) Pan/tilt servos, Gyro
PCB-ize the Controller (with options for different wireless modules) will have Nunchuck and maybe PS2 connector
Make OpenCurrent Version 2, with MCU + voltage monitoring, made to be in-line like many power monitoring solutions currently available

My Arduino ran out of RAM!

With the SD card enabled, and a modest size buffer for songs I want to play, when I ran the code on the arduino, it would just keep on resetting.  Very bazaar, I thought it was because of the Tone library conflicting, but it wasn’t! I reduced the song buffer size to 55, and poof, it worked!

Using the avr-size function bundled with Arduino (pointing to the elf file that avrdude generates while compiling), I see the following sections: text = 21840, data = 254, .bss = 1079. The Ram is data + .bss, in this case about 1300. But if you have a 500 byte array, plus other variables within the same function, you have the chance of causing a buffer overflow. You can actually look at the size of the global variables as explained here.

My new general strategy: Monitor ram size with avr-size, make sure my ram usage is below the allowable level in each function I use (and for all functions I’m nested in). I bet this explains why I couldn’t get the Tones working for the controller. Awesome!

I noticed this great video showing someone racing their RC car through the house, with a streaming camera on board that let them see things in real time. Very tempting to get a similar setup for my RC cars… The $300 price tag has me hesitating.

This is why it wasn’t working! BTM-182 output voltage out of Spec!

Determined not to give up, I continued on. The next step I came up with, was to swap BTM-182 modules, since maybe there is something fishy with that one? Swapping them didn’t help. So I thought, maybe its a voltage level issue.

And it was.

Apparently the BTM-182 module outputs a high of 1.4V, whereas the ATMega328 expects at least 0.9*Vcc (2.97) when operating at 3.3V (I’m operating at 3.3V). Apparently it worked with Software Serial because the change was enough to trigger an interrupt. A quick solution will be to set the TX of the BTM-182 module as the base input of a BJT, when high, triggers a pullup on whatever I’m controlling. And I’ll verify that it works, before trying everything out.

So ultimately, this chip, for some reason, output 1.4V as the high instead of 2.9 as expected. Looking at the datasheet, it seems that it believes that it is operating at 1.8V, not 3.3V. Quite strange. Lesson: Fully understand your parts, before you try to start working with them, because things may be go smoothly until you hit an unexplained snag. I hope to not make this mistake again!

The problem of SW serial dropping things will be still present on the controller, so I may need to change the usage of my packets to be more of a ask-give relationship, rather than give, give, get (occasionally).