Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

The AssemblyAI Java SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, audio intelligence models, as well as the latest LeMUR models.

License

NotificationsYou must be signed in to change notification settings

AssemblyAI/assemblyai-java-sdk

Repository files navigation

Maven Centralfern shieldGitHub LicenseAssemblyAI TwitterAssemblyAI YouTubeDiscord

Important

As of April 2025, AssemblyAI Java SDKhas been discontinued and will no longer be maintained.

While the SDK will no longer be updated, any previously published releases will remain available.

Going forward, see theAssemblyAI API reference for information on how to integrate with our API directly.

We know this is a disruptive change. If you need help with this transition,reach out to our Support team and we'll help you in any way we can.

Documentation

API reference documentation is availablehere.

Requirements

Java 8+

Installation

Gradle

Add the dependency in yourbuild.gradle:

dependencies {    implementation'com.assemblyai:assemblyai-java:x.x.x'}

Maven

Add the dependency in yourpom.xml:

<dependency>    <groupId>com.assemblyai</groupId>    <artifactId>assemblyai-java</artifactId>    <version>x.x.x</version></dependency>

HTTP Client Usage

The SDK exports a vanilla HTTP client,AssemblyAI. You canuse this to call into each of our API endpoints and get typedresponses back.

importcom.assemblyai.api.AssemblyAI;AssemblyAIaai =AssemblyAI.builder()  .apiKey("YOUR_API_KEY")  .build();Transcripttranscript =aai.transcripts().get("transcript-id");System.out.printlin("Received response!" +transcript);

Handling Errors

When the API returns a non-success status code (4xx or 5xx response),a subclass ofApiErrorwill be thrown:

importcom.assemblyai.api.core.ApiError;try {aai.transcript().get("transcript-id");}catch (ApiErrorerror) {System.out.println(error.getBody());System.out.println(error.getStatusCode());}

Creating a transcript

When you create a transcript, you can either pass in a URL to an audio fileor upload a file directly.

importcom.assemblyai.api.resources.transcripts.types.Transcript;// Transcribe file at remote URLTranscripttranscript =aai.transcripts().transcribe("https://assembly.ai/espn.m4a");// Upload a file via local path and transcribetranscript =aai.transcripts().transcribe(newFile("./news.mp4"));

transcribe queues a transcription job and polls it until the status is completed or error.If you don't want to wait until the transcript is ready, you can use submit:

importcom.assemblyai.api.resources.transcripts.types.Transcript;// Transcribe file at remote URLTranscripttranscript =aai.transcripts().submit("https://assembly.ai/espn.m4a");// Upload a file via local path and transcribetranscript =aai.transcripts().submit(newFile("./news.mp4"));

Using the Realtime Transcriber

The Realtime Transcriber can be used to process any liveaudio streams and sends data over websockets. The Realtime Transcriberwill take event handlers

importcom.assemblyai.api.RealtimeTranscriber;RealtimeTranscriberrealtime =RealtimeTranscriber.builder()  .apiKey("YOUR_API_KEY")  .onPartialTranscript(partial ->System.out.println(partial))  .onFinalTranscript(finalTranscript ->System.out.println(finalTranscript))  .build();realtime.sendAudio(newbyte[]{...});realtime.close();

Staged Builders

The generated builders all follow the staged builder pattern.Read morehere.Staged builders only allow you to construct the object once all requiredproperties have been specified.

For example, in the snippet below, you will not be able to access the buildmethod onCreateTranscriptParameters until you have specified the mandatoryaudioUrl variable.

importcom.assemblyai.api.resources.transcripts.requests.TranscriptParams;TranscriptParamsparams =TranscriptParams.builder()        .audioUrl("https://...")        .build();

Timeouts

The SDK uses the default timeouts of OkHttpClient:

  • 10 seconds for connection timeout
  • 10 seconds for read timeout
  • 10 seconds for write timeout
  • No timeout for call timeout

However, there areno timeouts for any LeMUR HTTP request.

To specify your own timeout, you can passRequestOptions to each request method:

importcom.assemblyai.api.core.RequestOptions;// initialize clientclient.transcripts()        .get("50c54d73-7a3f-44dc-af6b-f4579841b1ce",RequestOptions.builder()                        .timeout(30,TimeUnit.SECONDS)                        .build()        );

For this operation, the call timeout will be 30 seconds, and the other timeouts will be turned off.

The default timeout should be sufficient for most use cases.However, depending on your network speed and distance, you may occasionally experience timeouts, in which case you can increase the timeout.

Android

If you've enabledCode shrinking usingminifyEnabled, you need to add the following ProGuard configuration to keep R8 from incorrectly marking the SDK classes as unused.

-keep class com.assemblyai.api.** { *; }

Contributing

While we value open-source contributions to this SDK, this libraryis generated programmatically. Additions made directly to this librarywould have to be moved over to our generation code, otherwise they wouldbe overwritten upon the next generated release. Feel free to open a PR as aproof of concept, but know that we will not be able to merge it as-is.We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

About

The AssemblyAI Java SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, audio intelligence models, as well as the latest LeMUR models.

Topics

Resources

License

Stars

Watchers

Forks

Contributors11

Languages


[8]ページ先頭

©2009-2026 Movatter.jp