Metro Stations Announcer (With Chuck)

A Twisted Idea

Ever since my first visit in 2014 in Bucharest (capital city of Romania), I’ve had this twisted idea: I want to hear my voice announcing the metro stations.

Why? Just for fun. It’s such a fun idea to think about. I chuckle thinking about it.

Well, it didn’t happen in real life.

But it doesn’t stop me to write my own Metro Stations Simulator software.

I just need a few elements to come together in the main program. Let’s go!

Playing A Sample With ChucK

Below is the code that plays a sample file with Chuck.

It creates a sound buffer, sets its file name, and then reads it.

I’ve enhanced the code to allow speeding up or slowing down of the sample.

That’s why you see the rate variable involved in the computations.

Play a sample with ChucK

Loading Station Names

I haven’t figured out yet how to load file names from a folder with ChucK.

No worries, I had ChatGPT generate a Python script to list all the .WAV files from a folder.

Then it uses the names to generate the ChucK code for loading station names into the stations array.

Below we have the M2 station names being loaded into an array.

Dispatching The Loading Of Station Names

I want the code to load the correct station names dynamically, depending on the active line name I assign to a variable.

Hence, the need for a dispatcher function. It’s just a bunch of if statements, calling the appropriate loading function.

Perhaps the ChucK language has a switch statement similar to the one the C language has.

But I haven’t figured it out yet. If statements will do for now.

Also, for convenience, all station names are prepended by the actual folder name they exist in.

Main Program (Metro Stations)

And finally, the code to bind them all together.

We first set the active line (in this case, it’s M2).

We then play a sample announcing the line.

We then iterate all the stations, play a sample to say “Next Station” in Romanian.

And finally, play the station name, followed by a brief pause.

That’s what I’ve been working on lately and it’s interesting for me.

Metro Stations Announcer

Here’s the final .WAV file the program has generated, with me reading the M2 line names for the Bucharest Metro.

 
 

Leave a Reply

Your email address will not be published. Required fields are marked *