Archive for the ‘Programs’ Category

Neural Network Learns to Generate Voice (RNN/LSTM)

Tuesday, May 24th, 2016

This is what happens when you throw raw audio (which happens to be a cute voice) into a neural network and then tell it to spit out what it’s learned. (WARNING: Although I decreased the volume and there’s visual indication of what sound is to come, please don’t have your volume too high.)

[Watch in HD]

This is a recurrent neural network (LSTM type) with 3 layers of 680 neurons each, trying to find patterns in audio and reproduce them as well as it can. It’s not a particularly big network considering the complexity and size of the data, mostly due to computing constraints, which makes me even more impressed with what it managed to do.

The audio that the network was learning from is voice actress Kanematsu Yuka voicing Hinata from Pure Pure. I used 11025 Hz, 8-bit audio because sound files get big quickly, at least compared to text files – 10 minutes already runs to 6.29MB, while that much plain text would take weeks or months for a human to read.

I was using the program “torch-rnn“, which is actually designed to learn from and generate plain text. I wrote a program that converts any data into UTF-8 text and vice-versa, and to my excitement, torch-rnn happily processed that text as if there was nothing unusual. I did this because I don’t know where to begin coding my own neural network program, but this workaround has some annoying restraints. E.g. torch-rnn doesn’t like to output more than about 300KB of data, hence all generated sounds being only ~27 seconds long.

It took roughly 29 hours to train the network to ~35 epochs (74,000 iterations) and over 12 hours to generate the samples (output audio). These times are quite approximate as the same server was both training and sampling (from past network “checkpoints”) at the same time, which slowed it down. Huge thanks go to Melan for letting me use his server for this fun project! Let’s try a bigger network next time, if you can stand waiting an hour for 27 seconds of potentially-useless audio. xD

I feel that my target audience couldn’t possibly get any smaller than it is right now…

EDIT: Because I’ve been asked a lot, the settings I used for training were: rnn_size: 680, num_layers: 3, wordvec_size: 110. Also, here are some graphs showing losses during training (click to see full-size versions):


Training loss (at every iteration) (linear time scale)


Training loss (at every iteration) (logarithmic time scale)


Validation loss (at every checkpoint, i.e. 1000th iteration) (linear time scale)


Validation loss (at every checkpoint, i.e. 1000th iteration) (logarithmic time scale)

For sampling, I simply used torch-rnn’s default settings (which is a temperature of 1), specifying only the checkpoint and length and redirecting it to a file. For training an RNN on voice in this way, I think the most important aspect is how “clear” the audio is, i.e. how obvious patterns are against noise, plus the fact that it’s 8-bit so it only has to learn from 256 unique symbols. This relatively sharp-sounding voice is very close to a filtered sawtooth signal, compared to other voices which are more breathy/noisy (the difference is even visible to human eyes just by looking at the waveform), so I think it had an easier time learning this voice than it would some others. There’s also the simple fact that, because the voice is high-pitched, the lengths of the patterns that it needs to learn are shorter.

EDIT 2: I have been asked several times about my binary-to-UTF-8 program. The program basically substitutes any raw byte value for a valid UTF-8 encoding of a character. So after conversion, there’ll be a maximum of 256 unique UTF-8 characters. I threw the program together in VB6, so it will only run on Windows. However, I rewrote all the important code in a C++-like pseudocode here. Also, here is an English explanation of how my binary-to-UTF-8 program works.

EDIT 3: I have released my BinToUTF8 Windows program! Please see this post.

BaWaMI (revision 131)

Sunday, April 10th, 2016

This is a small update which fixes OGG file rendering, and a couple of other superficial things.

  • Fixed tabbing order of controls on “Mod shape” tab of the config window.
  • Writing OGG files works again – I accidentally removed a file needed by the OGG encoder in revision 130. Users who extracted revision 130′s folder over revision 129′s would not have experienced the problem.
  • Stopped warning about buggy controls from being displayed on the “MIDI params” tab of the config window, since it’s no longer true.

You can grab the new version from here (7.87 MB)!

BaWaMI (revision 130)

Wednesday, March 2nd, 2016

This update lets Bawami write WAV files in paths containing non-ASCII characters (something long-overdue), and fixes a bunch of complicated interwoven bugs related to the handling of “bad” MIDI files and of percussive notes. There’s also a load of other fixes, including for portamento-related bugs, crashing in /translator mode, and visual fixes, and a couple of new instruments.

You can grab the latest version from here (7.81 MB), and see details of the changes below the page break:

(more…)

Multi-strike, multi-pass, colour correction (WIP: Dot matrix program)

Wednesday, February 10th, 2016

Showing off a couple more things not possible with the Epson driver: multi-strike printing and “quiet” (not really) mode, along with CMYK colour correction which is nearly invisible to my camcorder, so that part was a waste of video…

This is a program I’m casually working on every now and then to print images on any 24-pin ESC/P2 dot matrix printer (ESC/P2 is Epson’s control language for their dot matrix printers). It directly controls the printer by sending raw commands to it; you just need to tell Windows that it’s a “Generic / Text Only” printer on Windows, not using the official Epson driver, and Windows will pass the commands straight on to the printer without trying to translate them.

[Watch in HD]

This is a standalone program for printing image files, not a driver for printing from any program. I’ve not yet released it, but I intend to some time. Compared to the driver, it currently allows:

  • Printing in (lower) resolutions for high speed (down to 60 DPI).
  • Detailed control over colour dithering/thresholding.
  • Very tall print-outs not restricted to a paper length (e.g. for continuous paper).
  • Printing only individual component colour(s) of an image.
  • * Faster colour printing by doing large blocks of each colour at once.
  • * Multi-strike printing (optionally offsetting each one to fill in the gaps between the earlier ones’ dots).
  • * “Quiet” (multi-pass) printing (unfortunately, I can’t control the actual speed).

*The last three are somewhat “hacks”, abusing commands to try to force unofficial behaviour, and as such, they rarely work properly in combination with each other. In particular, the last two often don’t work when printing colour.

By the way, printing in blocks of colour is no longer done by relying on sending commands with the correct timing (as it did in the previous video), which means it’s now much more reliable and doesn’t get messed-up by pausing the printer, image content, etc.

BaWaMI (revision 129)

Sunday, January 17th, 2016

This is a nice big bunch of fixes – mostly related to /console-mode, but a couple of more serious things (which affect more people) are fixed, too.

You can grab this latest version from here (7.87 MB), and see details of all the changes below.

General bug fixes

  • Fixed bug where button to browse for a new MIDI file remained disabled after opening a MIDI by dropping it onto the main window.
  • Now recognises when a filename is passed on the command line without speech marks (and without any command line parameters). This fixes the problem of Bawami not opening a path+file containing no spaces if such a file was dragged onto its icon (or if Bawami is associated with .MID files), because Windows does not automatically surround such a path+file with speech marks when passing it to the program.

Fixes for when using /console

  • No longer crashes if you’re redirecting Bawami’s output to a file or other program.
  • When using “/infolevel 2“, log file text is now sent to StdOut instead of (accidentally) to StdErr.
  • “Finished.” is now (always) displayed when shutting down.
  • Key prompts for answers to questions are now sent to StdErr instead of StdOut (as was already being done for the question’s title and message), so that they’re visible on the console even if you’re redirecting Bawami’s StdOut to a file.

Visual-related fixes

  • Green “settings” button’s tooltip is now loaded in the chosen language (instead of having no tooltip) (broken in revision 128).
  • Corrected Z-order of several controls on the config window so that the dotted border that indicates a control that has focus isn’t having one of its horizontal edges cut off unnecessarily.
  • Corrected a reference to how green “settings” button appears in info.txt.

Logging (also affects text shown when using /console /infolevel >=1)

  • No longer shows “Closing MIDI input port” when shutting down, if MIDI-in wasn’t in use.
  • No longer shows “Decoding absolute timings” a few lines after the last track has finished being decoded.

BaWaMI (revision 128)

Monday, December 14th, 2015

This version includes a whole load more bug fixes, plus some serious support for running Bawami from the console (command prompt), which also guarantees to never display message boxes, along with several other fun new command line parameters.  It should also start slightly faster (less writing to log file, and some language files are now only loaded when they’re needed), seeking to a different playback position is easier on the ears, and there’s a bunch of safeguards added to the code related to writing OGG files. A few command line parameters have been renamed to make them less long-winded, they all begin with a slash instead of a hyphen now, and Bawami now lets you know exactly which ones it didn’t understand (if any). But despite a lot of work being focussed on command line parameters, there are several GUI-related bug fixes, too!

NOTE: In order for Bawami to be able to output to the Windows console (command prompt) when using /console option, the EXE file is now compiled as a console-mode program. Annoyingly, this causes a console window to appear for a brief moment before Bawami’s main window appears. However, this doesn’t slow anything down; it’s only for part of the amount of time where, previously, nothing at all was displayed.

You can download the new version here (7.87 MB). Full details on all of the changes and bug fixes are below, but allow me to first introduce a new feature of Bawami:

The /console command line parameter

bawami /console /stdmidi 2020

If you run Bawami from the command line, this option should be very useful, and is highly recommended instead of /invisible. Text is output to “standard output” (meaning you can see what Bawami’s doing in the console), and you can respond to any messages by pressing keys on the console, too. In this mode, Bawami also starts faster and is safe to crash in the middle of playback (nothing is leaked – but for now, make sure that you also kill the OGG encoder if you crash it in the middle of writing an OGG file). Just for fun, you can also view every single raw MIDI message scrolling up in the console as it plays (/stdmidi) , and use /infolevel 1 or 2 to get a more in-depth look at exactly what’s going on internally. Of course, these options which spam text to the console will slow Bawami down a bit. Please check the “COMMAND LINE PARAMETERS” section in info.txt for full details, and see below for an overview of all changes/additions.

View all changes below the page break:
(more…)

BaWaMI (revision 127 32-bit fix)

Wednesday, September 23rd, 2015

When I first published revision 127 of Bawami about 25 minutes ago, the download included a 64-bit version of “vcut.exe” (official Vorbis splitter, used by this version of Bawami) which would not work on 32-bit Windows. A universally-compatible, 32-bit version is now included instead.

To avoid problems (OGG file export not working), I highly advise that you re-download it if you downloaded it within the past 25 minutes. I am sorry for the inconvenience.

BaWaMI (revision 127)

Wednesday, September 23rd, 2015

This is essentially a whole bunch of bug fixes, including one that I really should’ve released sooner (no longer freezes at the end of exporting a WAV/OGG file under certain conditions). There aren’t really new features, which should mean that, for once, the total number of bugs has actually decreased! ^^;

Most fixes are regarding WAV/OGG file-writing, click artifacts due to release times, and a couple of visual glitches. Full details are below the page-break.

You can grab the latest version from here (7.86 MB).

EDIT: When I first published this post, the download included a 64-bit version of “vcut.exe” (official Vorbis splitter, used by this version of Bawami) which would not work on 32-bit Windows. A universally-compatible, 32-bit version is now included instead. Sorry for the inconvenience.

(more…)

BaWaMI (revision 126)

Sunday, May 31st, 2015

This release fixes the bug where, if pan changed on a MIDI channel playing more than one note, only the panning of one note would change (bug added in revision 122). I only just noticed this, and it annoyed me a lot, so I’m releasing this version with only this change.

You can get it here (7.82 MB).

BaWaMI (revision 125)

Saturday, May 30th, 2015

Instrument menu appears correctly again (with a circled tick to indicate category of the chosen instrument). Once again, I left this disabled while testing and forgot to re-enable it…

Usual download link is here (7.81 MB)