Tales from the jar side: Multilingual audio in Java, Cast into the Void, Stages of grief, Light bulb jokes, and the usual social media silliness
The thing about Dorian Gray jokes is they never get old. (rimshot)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of November 10 - 17, 2024. This week I taught my Latest Features in Java course on the O’Reilly Learning Platform and my regular courses at Trinity College.
Multilingual Audio in Java
I recently watched a really good YouTube video that’s part of the AssemblyAI channel:
Unfortunately, other than saying that her name was Misra early in the video, I don’t have any other way to identify her. The only information in the description is for the company (AssemblyAI) rather than her. If you know how to reach her, please leave me a message in the comments or contact me directly. I did join the Discord server and asked there, so maybe they’ll get back to me.
Update: The discord server came through. Her name is Misra Turp, and her website is here.
In the video, Misra live-codes an application in Python that:
Records her voice using the Gradio UI library
Transcribes it to text using AssemblyAI
Translates it to several other languages using a Python module
Generates audio files for each translation using the ElevenLabs API
That seemed like a fun project to do, but of course I wanted to see if I could do it in Java. I did managed to do almost all of it. The part I can’t do right away is the user interface, because Java doesn’t have a natural analog to Gradio. Still, I got everything else working as a command line app, and that’s going to be the subject of my next video.
Normally if I was going to transcribe audio, I would simply use the API from OpenAI. That’s easy to use if your audio file is smaller than 25 MB, which is fine for something like this. The advantage of using ElevenLabs, however, is that they supply dozens, if not hundreds of additional voices you can use, and they even have professional voice cloning if you’re willing to pay for that.
I didn’t plan to do the voice cloning, so in my experiments I picked one of their simple American male voices. At least I did that for a while, until eventually all my experiments used up my free tokens. That meant if I wanted to go on, I needed to subscribe for real, and I finally shrugged and picked the Creator package and started cloning my voice.
That’s in process. I’ll let you know how it comes out.
So far, what I’ve used is:
The built-in
javax.sound.sampled
package in Java to record from the microphone.AssemblyAI to transcribe the audio. They provide libraries in several programming languages, including Java, so that helped.
I found LibreTranslate, which is an open source translation processor. It turned out that if I was willing to run it inside a Docker container, I could run it on my local machine without a key at all. They didn’t have a Java library (other an unofficial one I found), so I just accessed it as a REST web service and went from there. The fun part is I used Java 21 virtual threads to translate my text into six different languages concurrently. That was, as they say, wicked fast. :)
ElevenLabs does the generation of the audio files from each translation. Again, that costs a little, but I had to try out the voice cloning to see how I sound in Hindi, or Polish, or Greek, or whatever.
I hope to finish the video this week and publish it on the Tales from the jar side YouTube channel. I’ll let you know next week how that went.
Incidentally, the Tftjs channel hit another milestone:
I would have thought the next milestone would have been 75K, but hey, I’ll take it.
Cast into the Void
For years I’ve been using that code example in my training courses on Latest Features in Java (that particular one is for LVTI, local variable type inference), but until I posted it on Bluesky I didn’t think to make the “cast null into the void” joke. I’m still shaking my head at how I missed that one for so long. At least it occurred to me when I needed it. Since I’m casting null into Void, is that nihilistic or existentialist?
Reminds me of these old gags:
Q: How many existentialists does it take to change a light bulb?
A: Two. One to screw it in and one to observe how the light bulb itself symbolizes a single incandescent beacon of subjective reality in a netherworld of endless absurdity reaching out toward a maudlin cosmos of nothingness.Q: How many surrealists?
A: Two. One to hold the giraffe and the other to fill the bathtub with brightly colored machine tools.Q: How many nihilists?
A: Who cares? I mean, what’s the point? Nothing matters anyway.
I’m enjoying my transition to Bluesky, which is still growing like a weed. Find me there at https://bsky.app/profile/kousenit.com .
Stages of Grief
Speaking of existential despair, many of the people are know are struggling with that ever since the 5th, and if you have to ask what happened on the 5th you can probably skip this section.
I understand that most psychological models that make it into pop culture are at best oversimplifications and usually wildly inaccurate, but you probably know the one I mean. The so-called Kübler-Ross model of grief suggests that there are five stages of grief, summarized here by good old GPT-4o:
Denial: This stage involves shock and disbelief about the loss. People may struggle to accept what has happened, often feeling numb or detached.
Anger: As reality sets in, it is common to experience frustration and anger. This anger may be directed at themselves, others, or even at the situation or higher powers.
Bargaining: In this stage, people may attempt to regain control by negotiating or making “deals” (e.g., “If only I had done X, this wouldn’t have happened”) in hopes of reversing or lessening the loss.
Depression: Sadness, loneliness, and reflection are prominent during this stage. The person feels the full weight of the loss and may withdraw or feel overwhelmed by grief.
Acceptance: Reaching this stage does not mean one is “over” the loss. Rather, it indicates coming to terms with what has happened and finding a way to move forward with life.
As it concludes, grief is “a highly individualized experience, and people may not go through all the stages, or they might move through them differently.” Yeah, okay, I get that.
Regarding the election, my denial stage lasted a few hours that evening, but passed pretty quickly. Then I quickly went to anger. This week I’m struggling more with depression.
That can lead to some dark humor, especially given the ridiculous cabinet nominations proposed by the Orange One this week. In keeping with that, I suggest that Health and Human Services be reserved for the late, great Hannibal Lecter.
Give him something to sink his teeth into, I guess.
On a totally unrelated note:
Q: How many millennials does it take to change a light bulb?
A: We don’t know. The baby boomer that has the job now can’t retire because they never saved anything, and the millennials all have LED lights that last longer.
That Idiotic Fight
Did you watch the fight? What fight, you ask? Duh. The only one that attracted enough viewers to bring Netflix to its knees.
I really had no intention of watching the stupid Jake Paul / Mike Tyson fight, but then I discovered that the only thing uniting the entire country right now was the desire for Tyson to annihilate an annoying YouTuber.
Also, this turned out to be the week that Netflix realized my son no longer lives with us and therefore cut off his access. I texted him saying there was still time for him to come by and watch, but he had made other arrangements.
Good thing, too. The streaming load on Netflix’s servers was way too much for them to handle. This came after the company advertised that fight constantly for days leading up to it. I never got to see more than a few seconds at a time.
(In other words, I didn’t plan to watch the fight, and as it turned out, I didn’t.)
Fortunately, Steph Curry and the Golden State Warriors were playing at the same time, so I stuck with that. Watching Steph Curry play basketball makes me happy. (Oops, there I go taking joy in everyday things. I’m sure the Orange Clown will do something stupid enough to bring back the depression soon.) Watching some obnoxious kid dance around, hitting a guy nearly in his 60s, does not make me happy.
I would say the big loser was not Tyson, but Netflix, which is planning to host a couple of NFL games on Christmas day this year and now their ability to handle that has been called into question. I suppose the real losers were all of us for getting sucked into what was obviously just a silly cash grab disguised as elder abuse.
As for Iron Mike, I’ll just say that as a (part-time) YouTuber myself, I have no doubt he could still kick my a**. Of course, I’m even older than he is.
Unrelated, but these gags are great section separators:
Q: How many programmers does it take to change a light bulb?
A: None, that’s a hardware problem.
Social Media Posts (formerly, Tweets and Toots)
Now that I’ve moved to Bluesky and Mastodon (and, to a lesser degree, LinkedIn) and have almost completely abandoned Twitter, I need a new name for this section. I’ll go with Social Media Posts until I can think of something better.
I am shocked
Renault: I'm shocked, shocked to find that gambling is going on in here! [a croupier hands Renault a pile of money]
Croupier: Your winnings, sir.
Casablanca, FTW, as always. Twitter’s algorithm was skewed by Musk in the lead up to the election? No way! Whoever would have imagined such a thing by the guy who lives off of rigged demos and empty promises.
I think we all knew this was happening.
At least he passed
Pictures or it didn’t happen. Seriously, I want to see some flying koalas. Oh wait, that’s what AI image generators are for:
I’d give that student an A.
Emus in SC?
I would think “feral” would imply “not trained”, but thanks for the clarification anyway. And of course they’re named Thelma and Louise.
Some time when you’re bored, check out the Great Emu War of 1932. Here’s a YouTube video about it.
Printers are evil, part infinity
Save the cat
Apparently that’s from Martin Rosner, Hot Paper Comics.
Ghosted
Boo!
Finally, an age check:
Hard to paint that
Have a great week, everybody!
Wait, a couple more:
Q: How many birds does it take to change a light bulb?
A: Normally three, but toucanQ: How many people with OCD does it take to change a light bulb?
A: Seven. It has to be seven!Q: How many lawyers does it take to screw in a light bulb?
A: Such number as may be deemed necessary to perform the aforementioned task in a timely and efficient manner within the structure in which said bulb is housed and being dependent on the following variables:Whereas it should be taken in to account that ceiling heights may differ significantly from fixture to fixture, the altitude of defective bulb must first be determined upon which point the lawyer or lawyers shall at their option choose an appropriate means of elevation including but not limited to a chair, stepstool, table, or ladder;
Whereas the height of said means of elevation may require support depending upon the altitude, trajectory, and any encumbrances including but not limited to furniture, stairs, load bearing members, and columns; and
Whereas the bulb must be disposed of depending on the type of bulb in a manner consistent with all applicable state, local and federal statutes;
The answer to the aforementioned question can only be answered in one way.
It depends.
(That last one was for my wife, the retired lawyer.)
Last week:
Latest Features in Java, on the O’Reilly Learning Platform
My regular Trinity College schedule.
This week:
My regular Trinity College schedule.