Tales from the jar side: Translations to Hindi, Spring and AI without Spring AI, Java 21 features, Today's students are SO young, and the usual silly tweets and toots
I just invented the first thought-controlled air freshener. It makes scents when you think about it (rimshot, h/t to @dadsaysjokes)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of September 24 - October 1, 2023. This week I taught my Upgrade to Modern Java course as an NFJS virtual workshop.
Regular readers of (and listeners to, and now video viewers of) this newsletter are affectionately known as jarheads, and are far more intelligent, sophisticated, and attractive than the average newsletter reader or listener or viewer. If you wish to become a jarhead, please subscribe using this button:
As a reminder, when this message is truncated in email, click on the title to open it in a browser tab formatted properly for both the web and mobile.
Tftjs in Hindi?
There’s yet another AI service I found out about this week (from Matt Wolfe’s YouTube channel), called HeyGen Labs. If you give it a video, it not only translates it to another language, it changes your mouth to make it look like you’re speaking the translated words.
Let me say that again: It alters the video to make it look like you’re speaking another language.
Whoa. I had to try that out, at least on the free tier. For registering, I was awarded 2 credits (whoo), which is good for 2 minutes of video (whoo again). I therefore took one of my old YouTube shorts, entitled Spy Master: Unveiling the Mysteries of Mockito Spies in 60 seconds. I uploaded that to the HeyGen service, which informed me that I was now approximately 77,500th place (!) in the queue.
I did that upload before last week’s newsletter, but I didn’t mention it because by then it still hadn’t reached the front. It took about 6 or 7 days to get there, after which the processing happened rather quickly. When I had to pick a language, I chose Hindi, because I have a lot of Indian friends, and India is also the country with the second highest concentration of jarheads, believe it or not.
Here is the result:
I had to make some modifications to it. First, HeyGen removed the background music from my original video, so I had to add a different audio track. I also reformatted it a bit and added the logo at the bottom. But otherwise, you’re seeing the translation of the original pretty faithfully.
I didn’t share it around too much, preferring to let people stumble across it. I did, however, send a link to my friend Dilip Thomas, who had coincidentally contacted me to remind me about the GIDS Conference (Great International Developer Conference) in Bengaluru next April and wanted some abstracts.
To punish him for bugging me about them, I sent him the link to my Hindi short. Here’s his response:
Your YouTube Short in Hindi had me in stitches :-)! You've got the voice of a Bollywood star, but the translation was way off. It's a literal translation from English to Hindi, so for example, it translated "Class" into "Kaksha," which is more like a class of students in a lecture hall.
It's a funny reminder that AI translation still has some kinks to work out.
The other comments I got directly on the Short were:
You know what Ken, your Hindi is hard to follow even for native Hindi speakers. Man this is a gem 😍😍🤣 Sounds like 60s and 🤣😜
Pretty good Ken 👍 I am from India, it certainly reminded me of talking hat from harry potter series 😂
Hmm. I’m happy my voice was oddly appealing, but I’d hoped for better from the translation service. Still, the fact that native Hindi speakers had issues with it probably saved me a fortune, because that service wants a LOT of money:
Yeah, no. Somehow $50/month for 5 minutes of video seems like a lot, and no, we’re not going to talk about the business plan, thank you very much. Still, the overall effect — my voice really does change and adjust to the translated words — is like most powerful AI services: amazing and creepy at the same time.
If you decide to try this silliness yourself, please use this link to sign in so I can get a credit.
Btw, the only Bollywood movie I know is actually from Tollywood — the brilliant RRR movie, which is available on Netflix. My son and I watched that last year, after seeing so many favorable recommendations. We really enjoyed it, though it was a little violent in parts for my tastes.
OpenAI Translations
The episode did give me an opportunity to try out a feature of the OpenAI service that I hadn’t used yet. In my YouTube playlist called AI Tools from Java, I have videos that access ChatGPT, generate images with DALL-E, and transcribe audio from a wav file using Whisper. The one feature I hadn’t done yet was the translation service, which is limited to translating audio into English only. Given how international the world is these days, that seems like quite a limitation, but so be it. Until now, I didn’t have anything in a different language for it to translate.
Now I do. I extracted an audio (WAV) file from the video short (mp4) using the ffmpeg
tool and I wrote the code to call the translation service on it. That turned out to be easier than I expected, because the translation service takes the same parameters as the transcription service, just for a different endpoint.
Here’s what Whisper returned:
Welcome to the Spymaster to reveal the secrets of the Mockito spies in 60 seconds. What is Mockito Spy? Unveil the mystery. Use Mockito Spy to confirm their conversations. I have a room in which there is a logger. I have to test the method which does not return. How do you test the thing? Nothing is coming back. What do you do? And I wrap the logger in a spy in this test. When you call this method, the message was sent to the spy that the information message can be verified. For more information and similar videos, please subscribe to the Tales from the Jar side YouTube channel. Thank you very much.
That actually doesn’t seem too bad, but I have no idea how much “interpretation” the translation tool is doing.
I have to admit, my favorite part of the whole experiment was how HeyGen gave me an Indian accent (of sorts) and then didn’t translate either “Tales from the jar side” or “YouTube channel”, so I recognized those phrases.
Wild. I wonder how long it will take for this capability to wind up embedded in the bigger tools out there. Maybe HeyGen is right to grab the money while it can.
Update: I decided to use up another free credit. I uploaded my Mockito Additional Answers short and translate it into Dutch. More about that next week when it’s done.
Spring & AI without Spring AI
I saw some strange behavior on the Tales from the jar side YouTube channel last week. First, the good news. My friend Dan Vega posted a tweet that said he was collecting recommendations, and here’s one of the responses:
I hadn’t said anything, because I know Dan and I figured he already had Tftjs in mind. But I’ve been subscribed to the SivaLabs channel for a long time, though we’ve never actually connected. He’s got over 3700 subscribers. I certainly never expected him to recommend my channel. That happened on Thursday, and suddenly my subscriber count jumped. By Friday night I’d gained almost 60 (!) new subscribers.
Yay! Or it was yay until the next morning, when I’d lost almost 20. Then I gained about a dozen, and lost several of them again. That’s all kind of weird, because I didn’t do anything on the channel during that time.
According to my analytics, this is what my subscribers numbers did over the last week:
I’m not sure what to make of this, if anything. I did post that Hindi short (see the little icons below the graph), but I can’t believe that had much to do with it. Or maybe it did. I have no idea. I didn’t post anything else until yesterday evening. In case you’re wondering, the subscriber numbers jumped from 705 to 762, then fell back to 741, and now sits at 747, for which I should probably make an airplane joke (something like, I hope it makes a soft landing at some point).
My guess is that while SivaLabs no doubt contributed, it’s just one of those random YouTube things. I don’t think I should change what I do or how I do it in response, though I did make sure to thank Siva on X/Twitter, which I rarely visit any more. Maybe when Dan releases his recommendations video I’ll see another burst, or maybe nothing will happen at all.
The video I released yesterday is about accessing the OpenAI API’s without using the experimental Spring AI project:
Let me tell you, when you ask Midjourney for robots jumping on Springs (for the pun value, of course), you get some weird images. I don’t understand this one either, but I laughed so I thought you might.
My plan was for this to be a thorough video going through all the API’s, taking advantage of the following features:
Http exchange interfaces (Spring)
Jackson 2 JSON parsing (supplied by Spring)
Dependency injection, mostly of properties like the base URL or my authorization key (Spring)
Records, text blocks, lvti, pattern matching, collection factory methods, switch expressions (Java)
Testing (AssertJ, JUnit, and Spring)
As it happened, the video wound up being 12 minutes long, and I don’t like to go much above that (except for newsletter videos, which are what they are), so I stopped after setting up the project, customizing the WebClient
class to add the authorization header, showing a few demos, mapping the models into records, and listing them. I already have the code worked out for ChatGPT interactions, DALL-E image generation, and Whisper audio-to-text transcription, so expect those soon enough.
If you’re interested, all the code is in this GitHub repository.
Other Notes
Cay Horstmann has a new blog post available, called Java 21: The Nice, The Meh, and the … Momentous. It’s great, because everything he publishes is great.
Unlike the Spring-based one described above, my openaidemo GitHub repository shows how to connect to OpenAI services with regular Java HTTP Client + Google’s Gson parser. It also has a class called
ImageCarousel
, which shows all the images in thesrc/main/resources
folder, switching every 3 seconds. That’s a JavaFX class, and I’ve always had trouble with JavaFX classes in IntelliJ. At least until this weekend, when I switched the JVM for that project to Azul System’szulu-21.fx
, which includes the JavaFX libraries automatically. Now I can even run that class as a regular Java class, and it works like a charm. :) Thanks to Geertjan Wielenga for the suggestion.Part of the challenge of teaching undergraduates is that they’re so very, very young. (For some perspective, they were all born after 9/11.) That means they’re naturally unaware of a lot of the history of the tools they use every day.
For example, I mentioned Java applets, and they had never heard of them (ouch). So I told them how in the early days of the web, Marc Andreessen created the Netscape browser (more blank stares, whoa) and he built a JVM into the browser itself, enabling Java to run on the client side inside a sandbox. Legend had it that one day Bill Gates was wandering around the Microsoft offices and noticed that everyone was running Netscape (which had about an 80% market share at that point), turned the company on a dime and Internet-enabled everything. Also how Brendan Eich threw together a language for the client side in about a month, which was supposed to be called LiveScript but eventually was renamed … JavaScript.
They knew none of this, so suddenly it was story time. Yet I wonder how I have so little time to cover the topics I want to discuss in class. At least they haven’t heard all my jokes yet.
Social Media Posts
Ghoulish, but possibly true
No doubt that’s in poor taste, but I laughed.
(In the past couple of weeks, we’ve lost her, the other Dumbledore, and my favorite baseball player while growing up, Brooks Robinson. Sometimes it’s tough getting old.)
We’ve all been there
Oof. I’m sure there’s a story there, too.
You decorated my life
Food for thought, but now I have that Kenny Rogers song going through my head.
Estimates
Two thoughts:
“I’ll gladly pay you next Tuesday for a hamburger today.” (Wimpy)
“I love deadlines. I like the whooshing sound they make as they fly by.” (Douglas Adams)
Changing seasons
After so much rain that I was thinking it was time to start building that ark, the sun finally came out today. So, yeah.
They what?
At least I think they do. I certainly think that they think they do.
Probably too early for this, but…
In case you’re having trouble, the creature on his shoulder is called Cthulhu.
Have a great week everybody!
The video version of this newsletter will be on the Tales from the jar side YouTube channel tomorrow.
Last week:
Upgrade to Modern Java, an NFJS Virtual Workshop
Software Design, my course for undergrads at Trinity College
This week:
Two-day, Functional Programming in Java course on the O’Reilly Learning Platform
Software Design, my course for undergrads at Trinity College
This week is the calm before the storm. Next week I’m flooded with classes, and given the rain we’ve had lately, I use that term knowing what it means