Transcribing Audio in Java with Assembly AI API
Learn to transcribe audio using Assembly AI's Java SDK. Create projects, handle keys, and generate transcripts with speaker labels efficiently.
File
Convert Speech to Text In Java (Basic Tutorial)
Added on 01/29/2025
Speakers
add Add new speaker

Speaker 1: In this video, I'm going to show you exactly how you can transcribe an audio file in Java using Assembly AI's speech-to-text API. So let's get started. The first thing you want to do is create an empty Java project. I've done this in IntelliJ, but feel free to use any other Java ID that you want. So open build.gradle. And once you're in build.gradle, we want to import Assembly AI's Java SDK. You can check out this website right here, which gives you instructions on exactly how you can import the latest version of Assembly AI's Java SDK. Since I'm using Gradle, I'm going to select that and click copy to clipboard and paste it right here. Once I've done that, I'm going to build the Gradle file. Once that's done, we want to go into main and then start writing our code. The first thing we want to do is create an Assembly AI transcriber object. So let's do Assembly AI. Assembly AI equals to Assembly AI dot builder dot API key dot build. And right here is where you should be entering your Assembly AI API key. If you don't already have an API key, you can get one for free by going on to Assembly AI's website and creating an account. Once you've done that, you can copy your API key and then paste it back into our code. Now that the Assembly AI transcriber object has been created, what we want to do is define our URL which contains the audio file. Now that we've defined our Assembly AI object and the URL of the audio that we plan on transcribing, let's actually get started with the transcription. So let's do transcript equals to AAI equals to Assembly AI dot transcripts dot transcribe. And in here, we're going to pass the URL that we just created. Next, all we have to do is print out the transcript. So once you have all this written down, you can just hit run. Once that completes running, you're going to get an output which looks something like this. As you can see, this is a transcript of the audio file that we just passed. Now that we have this, let's actually build on top of this by generating speaker labels from the audio file that we've passed. So to do that, what we want to do is pass some extra parameters into our Assembly AI object. So let's create a config variable. So let's create a config variable. And we want to make use of the transcript optional params class dot builder dot speaker labels. And let's turn this to true dot build. Once you have this config object, inside of this transcribe method, we want to pass this config object as well. So let's do URL comma config. And this right here will generate speaker labels in our transcript that is being returned from Assembly AI's API. So so with this chunk of code right here, what we're doing is we'll be printing out line by line every single sentence which has been uttered by different speakers. Once we have all of this, we can hit run again. Once we run this, we will get our initial transcript that we have printed out. But we also get the transcript which is split up amongst different speakers. So speaker A and speaker B. So this is really great at also identifying different speakers in the audio and giving labels to each one of them. If you're interested in building more with Assembly AI speech to text in Java, check out the documentation that I'll be linking in the description box below. It contains a lot of different examples of how you can make use of Assembly AI's Java SDK.

ai AI Insights
Summary

Generate a brief summary highlighting the main points of the transcript.

Generate
Title

Generate a concise and relevant title for the transcript based on the main themes and content discussed.

Generate
Keywords

Identify and highlight the key words or phrases most relevant to the content of the transcript.

Generate
Enter your query
Sentiments

Analyze the emotional tone of the transcript to determine whether the sentiment is positive, negative, or neutral.

Generate
Quizzes

Create interactive quizzes based on the content of the transcript to test comprehension or engage users.

Generate
{{ secondsToHumanTime(time) }}
Back
Forward
{{ Math.round(speed * 100) / 100 }}x
{{ secondsToHumanTime(duration) }}
close
New speaker
Add speaker
close
Edit speaker
Save changes
close
Share Transcript