Batch processing files with Audacity

In my last post Using Text to Speech online tools to create audio files for Arduino projects I had some info about online text to audio sites I have been using to create audio alert files for projects. The files produced by ttsmp3.com seemed to have a lower audio level than I expected. I found I could run all the files through a batch process in Audacity to normalize them. I spent a lot more time trying to find out how to do it so I’m making this quick post so I have the info for next time.

I was running Audacity 2.1.3 which is now an old version. The terminology and location of the feature changed in 2.3.0. Essentially the pre 2.3 version seems to call it ‘chains’ whereas it became ‘macros’ in 2.3. I’ll include info for both as I made notes for the older versions first.

The relevant info is available on the Audacitiy site.

There are two parts to the process

  1. Create a chain/macro with the processes that will be run during the batch process. This only needs to be set up once.
  2. Select files and run the task.

There are a lot of other changes that can be included. I’ve also added Mono to one as I found some of my files created another way were stereo and others mono. My project only had a single speaker so I converted them all to mono for consistancy.

Pre 2.3 version

In these versions the batch process is referred to as a chain.

To create a chain

  • Go to File
  • Select Edit chains…
  • Add button
  • Set a name, e.g. Normalize to -0.1dB
  • Insert Normalize – Tweak settings if desired. I didn’t
  • Insert ExportMP3 – This is required otherwise the files are not saved
The chain should look something like this

To use the chain

  • Go to File
  • Select Apply chains…
  • Select the chain, in my case ‘Normalize to -0.1dB’
  • Select Apply to files
  • Browse to the file folder and choose files
  • Select Open
  • Converted files will be placed in a folder called cleaned inside the folder of the selected files

Current version

In later versions it is called a macro.

To create a macro

  • Go to Tools
  • Select Macros…
  • New button
  • Set a name, e.g. Normalize
  • Insert Normalize. There is also an option ‘Normalize (Macro_Normalize)’ that I have not tried

  • Insert Export as MP3 – This is required otherwise the files are not saved

To use the macro

  • Go to Tools
  • Select Macros…
  • Select the macro, in my case Normalize
  • Select Files
  • Browse to the file folder and choose files
  • Select Open
  • Converted files will be placed in a folder called macro-output inside the folder of the selected files

Before and after

Here is a before and after shot. The before is the one at the top.

As always if let me know if you find inaccuracies in my info.

Using Text to Speech online tools to create audio files for Arduino projects

I’ve made a couple of projects that play audio alerts using a dfplayer and MP3 files. One in a clock that plays announcements and the other a countdown timer. When I did those, I used onlinetonegenerator.com to convert text to speech. I liked the voices but it doesn’t have an option to save the audio as an MP3 file. I ended up using Audacity to record the computers audio. It worked but was very tedious. Since then, I’ve been looking for a simpler way.

The important criteria in a text to speech service for me is:

  • Ability to enter text, listen to the converted audio in the browser and then download it as an mp3 file.
  • Sufficient audio quality.
  • Volume level ok.
  • Suitable lead in and end dead time to allow multiple files to be played in sequence with the  result sounding as a smooth sentence. For example these four files together; “The time is”, “eleven”, “thirty two”, “am”.
  • A suitable voice. They don’t all have the same voices. I prefer some more than others.
  • Free or good value.
  • Ability to change speed, pitch and emphasis a bonus.

Here are a few I’ve looked at.

Online Tone Generator (onlinetonegenerator.com/voice-generator.html)

This is the first one I used. Its:

  • Free.
  • Has a good range of voices; mostly Google, plus a few Microsoft ones I presume are built into my Windows PC. I particularly like Google français.
  • Lots of other audio tools, including; noise generator, sweep generator, DTMF signals.
  • But, no MP3 download.

From Text To Speech (fromtexttospeech.com)

I briefly looked at this one. It is:

  • Free.
  • Has a 50 000 character limit per file.
  • I’m unable to listen in browser. No play button displays until a file is created and then the player presented appears to use flash and is blocked by my browser. The file can be downloaded and used.
  • MP3 download.
  • Different speed and voices.

TTSMP3 (ttsmp3.com)

This is the one that I am intending to use in my next project. Lots of features, MP3 file output and a fair amount of free usage. It is:

  • Free for 3,000 characters (~375 words) per day.
  • Lots of different voices.
  • Supports speed, pitch and other effects using tags.
  • Multiple voices can be used in the one piece of text by using tags.
  • MP3 file download.

TTSMP3 uses Amazon Polly and comes with quite a few voices and features. Additional effects can be used by using tags in your text. More info about tags is available on this Amazon page.

Here is an example of the voices.

That audio file was created by pasting the text below into the converter. Beware if you do this it will use up most of your daily 3000 word limit.

[speaker:Zeina] Hi, I'm Arabic Zeina
[speaker:Russell] Hi, I'm Russell Australian English Russell
[speaker:Nicole] Hi, I'm Australian English Nicole
[speaker:Camila] Hi, I'm Brazilian Portuguese Camila
[speaker:Ricardo] Hi, I'm Brazilian Portuguese Ricardo
[speaker:Vitória] Hi, I'm Brazilian Portuguese Vitória
[speaker:Emma] Hi, I'm British English Emma
[speaker:Amy] Hi, I'm British English Amy
[speaker:Brian] Hi, I'm British English Brian
[speaker:Chantal] Hi, I'm Canadian French Chantal
[speaker:Enrique] Hi, I'm Castilian Spanish Enrique
[speaker:Lucia] Hi, I'm Castilian Spanish Lucia
[speaker:Conchita] Hi, I'm Castilian Spanish Conchita
[speaker:Zhiyu] Hi, I'm Chinese Mandarin Zhiyu
[speaker:Mads] Hi, I'm Danish Mads
[speaker:Naja] Hi, I'm Danish Naja
[speaker:Ruben] Hi, I'm Dutch Ruben
[speaker:Lotte] Hi, I'm Dutch Lotte
[speaker:Céline] Hi, I'm French Céline
[speaker:Léa] Hi, I'm French Léa
[speaker:Mathieu] Hi, I'm French Mathieu
[speaker:Vicki] Hi, I'm German Vicki
[speaker:Marlene] Hi, I'm German Marlene
[speaker:Hans] Hi, I'm German Hans
[speaker:Karl] Hi, I'm Icelandic Karl
[speaker:Dóra] Hi, I'm Icelandic Dóra
[speaker:Aditi] Hi, I'm Indian English Aditi
[speaker:Raveena] Hi, I'm Indian English Raveena
[speaker:Carla] Hi, I'm Italian Carla
[speaker:Giorgio] Hi, I'm Italian Giorgio
[speaker:Bianca] Hi, I'm Italian Bianca
[speaker:Takumi] Hi, I'm Japanese Takumi
[speaker:Mizuki] Hi, I'm Japanese Mizuki
[speaker:Seoyeon] Hi, I'm Korean Seoyeon
[speaker:Mia] Hi, I'm Mexican Spanish Mia
[speaker:Liv] Hi, I'm Norwegian Liv
[speaker:Ewa] Hi, I'm Polish Ewa
[speaker:Jan] Hi, I'm Polish Jan
[speaker:Maja] Hi, I'm Polish Maja
[speaker:Jacek] Hi, I'm Polish Jacek
[speaker:Inês] Hi, I'm Portuguese Inês
[speaker:Cristiano] Hi, I'm Portuguese Cristiano
[speaker:Carmen] Hi, I'm Romanian Carmen
[speaker:Maxim] Hi, I'm Russian Maxim
[speaker:Tatyana] Hi, I'm Russian Tatyana
[speaker:Astrid] Hi, I'm Swedish Astrid
[speaker:Filiz] Hi, I'm Turkish Filiz
[speaker:Joey] Hi, I'm US English Joey
[speaker:Kimberly] Hi, I'm US English Kimberly
[speaker:Salli] Hi, I'm US English Salli
[speaker:Ivy] Hi, I'm US English Ivy
[speaker:Matthew] Hi, I'm US English Matthew
[speaker:Kendra] Hi, I'm US English Kendra
[speaker:Joanna] Hi, I'm US English Joanna
[speaker:Justin] Hi, I'm US English Justin
[speaker:Miguel] Hi, I'm US Spanish Miguel
[speaker:Lupe] Hi, I'm US Spanish Lupe
[speaker:Penélope] Hi, I'm US Spanish Penélope
[speaker:Gwyneth] Hi, I'm Welsh Gwyneth
[speaker:Geraint] Hi, I'm Welsh English Geraint

Comparisons

Compared with the original audio files that I created by using Audacity to record the PC audio and onlinetonegenerator.com, ttsmp3.com had lower volume. I may have had the record level a bit high when I used Audacity so not sure that the ttsmp3 level is too low.

The bit rate is also different, with the Audacity ones higher. That’s probably because I unnecessarily chose a higher bitrate in Audacity. TTSMP3 was 48kbs.

And that affected the file size. The TTSMP3 is much smaller.

Here are a couple of examples for comparison. For each I created four separate files and then joined them together to see how smooth the transition was. The four files were “The time is”, “11”, “32”, “AM”. I had to be a bit creative with the AM for French Celine as it was pronounced as “am”.

onlinetonegenerator.com Voice is Google français. I like this voice. It has added a lot of character to my speaking clock.

ttsmp3.com Voice is French Celine. It was much easier to create and the timing between files is ok, but the voice doesn’t have the same character to the one above in my opinion

ttsmp3.com This is British Amy. This was just for comparison to see how the same text would sound with an English voice.

Do you have other methods? Let me know.

Update 13/4/2021: I have added a post with info about how to increase the audio level in a batch of files Batch processing files with Audacity

Finally, a decent quality prototype breadboard for a reasonable cost

Getting decent quality prototype breadboards for a reasonable cost is something that has eluded me for years. I think I have finally found a reliable source. Those advertised on eBay or at least the cheaper ones seem that I have previously purchased too often have poor metal connectors inside. It can be difficult to insert pins in and if the pin is thick the contacts don’t completely spring back. I have not found a way to determine which of these are ok as just looking at the breadboard doesn’t seem to be reliable method.

The new ones I’ve got are BB830 by BusBoard. I found out about them by Ben Eaters in this video. Skip to about 1:18 if you want to hear him talk about them.

Ben sells them and has more information about them on his breadboard page, however I must confess I got them from Mouser as I am outside of the US and was preparing an order with Mouser anyway. Here is a shot of a bread board fastened to a cheese board.

The breadboard on the bottom is the new one. Those little ones at the top are just old ones that have been cut.

I’m very happy with them. They cost more than those I’ve previously purchased on eBay but if they don’t work then any price is too much. Also, I want to support producers of decent quality items. So far, I’m very happy with the BusBoard ones.

IR remote control mute button

I recently built a simple one button Arduino based IR remote control to mute our TV and Computer amp. I am quite happy with the results. The idea to use half a stress ball for the mute button I thought was inspired. The timber case built using with the aid of some jigs I made for my old saw bench came out better than expected.

To save power the voltage regulator and the current limiting resistor to the power LED were removed. The other onboard LED was left connected and ended up using it to flash with the IR LED just for diagnostics. As the case doesn’t have a bottom it displays a nice red flash in use. I decided to be a bit naughty and drive the IR LED without a limiting resistor through a transistor to drive it hard and get a bit more range. I thought the quick pulses would mean the LED should probably survive, but I ended up adding the resistor back in.

As is often the case, at least with my projects much time was spent trying to determine what was causing some unexpected behaviour. While it often worked correctly. Sometimes pressing the button didn’t seem to do anything. I used a number of different batteries I had laying around. I eventually discovered the IR LED was staying on, this was with some old batteries. My current assumption is that when the voltage drops too far the processor stops and the LED pin either goes high or it is stopping when it is high. As I don’t have a proper solution, I added the resistor back in series with the IR LED to at least reduce the current flow if it does happen again. With the resistor out I didn’t find the range was improved very much anyway.

The code

The code is fairly simple and is really designed to be able to support multi button remotes. After completing it I read that the TV begone just uses the reset button to wake up the processor, it then sends out it’s codes and then goes back to sleep. That’s an interesting way to do it that never occurred to me. I went with the traditional method of using a button and interrupt.

I mentioned earlier that it was designed to mute both a TV and a computer amp. These are in different rooms. The button simply sends out the mute pulses for one after the other. It could mute both at the same time, but due to location of the amp and TV that doesn’t happen in practice.

The code really needs further work to resolve the case where the LED stays on, but if you are interested you can check it out on my Github garrysblog/IR-Remote-Mute-Button

The circuit

Here is the circuit diagram. I used a PN2222A transistor, but that was because I have a lot of those. I presume it would work with a lot of other types. Other than that it is fairly simple

The case and button

The case was made mostly from a pine timber lining board. Like many of the reasons for my choices I did it this way as another project was to create some jigs to create clean precise 45 degree cuts on an old table saw. I don’t think I could have made it this way without the jigs. While most of the joints were glued using PVA glue the piece that holds in the switch and spring was glued in using hot melt glue to allow a about the right amount of time for jiggling before it hardened.

I needed a couple of thin discs to mount to the top and bottom of the ball that holds the ball. I tried some ply first but my results weren’t great. I had an old circuit board from a project that I abandoned years ago and after scraping off the old tracks found that it works well. See it’s worth hanging on to some things for 20+ years and now it is bringing me joy 🙂

Final results

It has been in use for a couple of months now. It’s still going well but I’m not sure how long the batteries will last. I still don’t haven’t fixed the issue with the LED, but other projects are calling. Maybe one day I’ll come back to it. I hope it gives you some inspiration.

Timber breadboards and serving boards with Arduino

Originally, according to Wikipedia and other articles I’ve read wooden kitchen breadboards were used for electronics, which is where the term started. I’ve started using them too. I had a couple of accidents where they magic smoke was released from a couple of Arduino boards when an Arduino module was bumped and moved over a screwdriver in one case and a piece of metal in another. That smoke can escape pretty quickly. I also got tired of connections coming loose when moving the project between sessions. I thought I would share some of my results as they may help someone.

I started by trying to make my own boards, but found I didn’t really have any suitable timber, but I may come back and look at options later.

I found our local Kmart had suitable items. The first is a beautiful acacia serving board. Originally it had a timber handle. I cut that off as it made it a bit long and awkward. It’s not the easiest timber to cut, but I do have some good tools for that and the results were ok. For this one I attached a 20×4 LCD display, battery holder, rotary encoder and joystick. I tried to include items that wouldn’t plug into the solderless breadboard, but adding all these may have been a mistake. I doubt I will use the joystick, but that’s ok. The dark timber looks great. What I hadn’t expected was how much more pleasing it made working on a project when everything is held together on such a beautiful piece of timber.

Acacia serving board with handle removed

Kmart no longer have the exact same board but they did get these Anko bamboo serving boards. They came in a pack of 3 boards for $6, so the price was right. They are not as beautiful as the first board and they are smaller, but they are made of bamboo which I presume is more environmentally friendly and their size and thickness make them ideal for smaller projects. I made up several with solderless breadboards attached. This one includes a 16×2 LCD display.

Smaller bamboo serving board

I like these LCD displays a lot so I included one on this board. I bought the I2C board and LCDs separately as I didn’t want them pre-soldered together. This allowed me to solder them together with greater distance between the LCD and backpack module. I could then carefully bend the pins so that the LCD sat at a useful angle and the I2 C board was easily accessible for adjusting the contrast and reading the pin connections.

LCD is held down with two screws. The plastic tube spacers are used to get the height at the front correct.

To mount modules to the board I’ve found a couple of different sized plastic tubing. It’s easy to cut to different lengths. There are probably lots of tools to cut it with but I usually use a pair of heavy duty wire strippers, not because it requires a lot of force, but as it has just the right sized cutter that makes it easy to do a neat cut. The tubing can squash a bit so if their lengths are not identical it doesn’t really matter.

Plastic tube and wire strippers

Overall, this has made tinkering much more enjoyable. I’m still looking out for improvements.

A deceptively simple but not very secure security key

I recently recalled an interesting security key for a building car park at a block of units we stayed at a few years ago. It was a small block of units with maybe 10 – 20 units in the whole complex, probably built in the 1970s. Underneath was a carpark with a roller door to prevent unauthorised access. A small box stood near the entrance with a receptacle for the key.
In other places we have visited we were usually given a remote control to gain access or sometimes a card to insert. This place had a 6.5mm audio plug attached to a key ring to insert in a socket near the door.

The key

I found it particularly curious as the plug only had two connections, that is it was a mono plug. I wondered how they had implemented security with it. I unscrewed it to reveal a deceptively simple circuit… a wire.

With cover removed and circuit revealed

I have to give the creators full marks for simplicity, but not so many for security.