mirror of
https://github.com/Andrewcpu/elevenlabs-api.git
synced 2026-05-06 03:00:23 -04:00
Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa4c8bf5db | ||
|
|
96fc45920d | ||
|
|
b9c74c1bd7 | ||
|
|
f2f3915c6c | ||
|
|
79e570f989 | ||
|
|
0a4a221b5c | ||
|
|
cc360a258e | ||
|
|
9c7fffbb9a | ||
|
|
4cfd14fb95 | ||
|
|
a8630ceeb0 | ||
|
|
7593f3a3f1 | ||
|
|
5288fde44e | ||
|
|
ce86914f71 | ||
|
|
4a212c7721 | ||
|
|
f46bb6878e | ||
|
|
81cdf05152 | ||
|
|
6e5ae633a6 | ||
|
|
a6163fd67f | ||
|
|
26a4ab1fa4 | ||
|
|
72f35c14b7 | ||
|
|
90a092aa81 | ||
|
|
02d7ec0685 | ||
|
|
75f1c40f59 | ||
|
|
3ac42a330b | ||
|
|
f4fe38166b | ||
|
|
3e2458b482 | ||
|
|
334a903c83 | ||
|
|
d7a710e197 | ||
|
|
15db53e81e | ||
|
|
bc6ee1306f | ||
|
|
8199e766ef | ||
|
|
688b469f6b | ||
|
|
388d059af7 | ||
|
|
1f9c48eac6 | ||
|
|
b3ea0e2a09 | ||
|
|
75eb64a077 |
372
README.md
372
README.md
@@ -3,10 +3,9 @@
|
||||
|
||||
## Getting Started
|
||||
So you wanna make custom voices, huh? Well you've come to the right place.
|
||||
|
||||
### Note: This repo is undergoing an upgrade to v2.0
|
||||
If any of the documentation is out of place or issues occur, please submit a PR or create an issue.
|
||||
I downgraded the repo from JDK 17 to JDK 11 as well.
|
||||
This library should cover all the ElevenLabs API endpoints as of 11/15/23.
|
||||
**Update**
|
||||
It seems I jumped the gun (or happened to bump into an accidental push of the speech to speech API docs), but the original documentation that my implementation was based on has now been removed or hidden. It may reappear as is, or will require changes.
|
||||
|
||||
### Installation
|
||||
**Maven**
|
||||
@@ -14,14 +13,11 @@ I downgraded the repo from JDK 17 to JDK 11 as well.
|
||||
To add `elevenlabs-api` to your Maven project, use:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>net.andrewcpu.elevenlabs</groupId>
|
||||
<groupId>net.andrewcpu</groupId>
|
||||
<artifactId>elevenlabs-api</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<version>2.7.8</version>
|
||||
</dependency>
|
||||
```
|
||||
The most up-to date package information can be found on the [Packages tab](https://github.com/AndrewCPU/elevenlabs-api/packages/)
|
||||
|
||||
|
||||
**JAR**
|
||||
|
||||
Compiled JARs are available via the [Releases tab](https://github.com/AndrewCPU/elevenlabs-api/releases)
|
||||
@@ -32,55 +28,106 @@ To access your ElevenLabs API key, head to the [official website](https://eleven
|
||||
To set up your ElevenLabs API key, you must register it with the ElevenLabsAPI Java API like below:
|
||||
```java
|
||||
ElevenLabs.setApiKey("YOUR_API_KEY_HERE");
|
||||
|
||||
|
||||
ElevenLabs.setDefaultModel("eleven_monolingual_v1"); // Optional, defaults to: "eleven_monolingual_v1"
|
||||
```
|
||||
*For any public repository security, you should store your API key in an environment variable, or external from your source code.*
|
||||
|
||||
- - -
|
||||
|
||||
<!-- TOC -->
|
||||
### Table of Contents
|
||||
* [Getting Started](#getting-started)
|
||||
* [Installation](#installation)
|
||||
* [Setting up your API Key](#setting-up-your-api-key)
|
||||
* [Voices](#voices)
|
||||
* [Accessing your List of Available Voices](#accessing-your-list-of-available-voices)
|
||||
* [Accessing the Default Voice Settings](#accessing-the-default-voice-settings)
|
||||
* [Getting a Voice by ID](#getting-a-voice-by-id)
|
||||
* [Deleting a voice](#deleting-a-voice)
|
||||
* [Retrieving an Updated VoiceSettings for a Voice](#retrieving-an-updated-voicesettings-for-a-voice)
|
||||
* [Updating the VoiceSettings for a Voice](#updating-the-voicesettings-for-a-voice)
|
||||
* [Editing a Voice](#editing-a-voice)
|
||||
* [Creating a Voice](#creating-a-voice)
|
||||
* [Generating Audio](#generating-audio)
|
||||
* [Samples](#samples)
|
||||
* [Accessing Voice Samples](#accessing-voice-samples)
|
||||
* [Downloading a Sample](#downloading-a-sample)
|
||||
* [Deleting a Sample](#deleting-a-sample)
|
||||
* [History](#history)
|
||||
* [Getting Generation History](#getting-generation-history)
|
||||
* [Getting a History Item](#getting-a-history-item)
|
||||
* [Downloading History](#downloading-history)
|
||||
* [Deleting a HistoryItem](#deleting-a-historyitem)
|
||||
* [Requesting the Voice for a HistoryItem](#requesting-the-voice-for-a-historyitem)
|
||||
* [Downloading a HistoryItem Audio](#downloading-a-historyitem-audio)
|
||||
* [User Management](#user-management)
|
||||
* [Getting your Subscription](#getting-your-subscription)
|
||||
* [Getting your User](#getting-your-user)
|
||||
* [Exceptions](#exceptions)
|
||||
* [*ElevenLabsAPINotInitiatedException*](#elevenlabsapinotinitiatedexception)
|
||||
* [*ElevenLabsValidationException*](#elevenlabsvalidationexception)
|
||||
* [Misc](#misc)
|
||||
|
||||
* [Links to ElevenLabs](#links-to-elevenlabs)
|
||||
* [**ElevenLabs Website**: https://elevenlabs.io](#elevenlabs-website--httpselevenlabsio)
|
||||
* [**ElevenLabs API Documentation**: https://api.elevenlabs.io/docs](#elevenlabs-api-documentation--httpsapielevenlabsiodocs)
|
||||
<!-- TOC -->
|
||||
|
||||
## Links to ElevenLabs
|
||||
### **ElevenLabs Website**: https://elevenlabs.io
|
||||
### **ElevenLabs API Documentation**: https://api.elevenlabs.io/docs
|
||||
|
||||
- - -
|
||||
|
||||
## Simplified Generation Handling with Builders
|
||||
### v2.7.8 now includes SpeechGenerationBuilder.java
|
||||
|
||||
[//]: # (### Speech to Speech)
|
||||
|
||||
[//]: # (```java)
|
||||
|
||||
[//]: # (//File output)
|
||||
|
||||
[//]: # (SpeechGenerationBuilder.speechToSpeech())
|
||||
|
||||
[//]: # ( .file() // output type of file (or use .streamed() for an InputStream))
|
||||
|
||||
[//]: # ( .setInputFile(File))
|
||||
|
||||
[//]: # ( .setGeneratedAudioOutputFormat(GeneratedAudioOutputFormat.MP3_44100_128))
|
||||
|
||||
[//]: # ( .setVoiceId("voiceIdString"))
|
||||
|
||||
[//]: # ( .setVoiceSettings(VoiceSettings))
|
||||
|
||||
[//]: # ( .setVoice(Voice) // or use a voice object, which will pull settings / ID out of the Voice)
|
||||
|
||||
[//]: # ( .setModelId("modelIdString"))
|
||||
|
||||
[//]: # ( .setModel(ElevenLabsVoiceModel.ELEVEN_ENGLISH_STS_V2))
|
||||
|
||||
[//]: # ( .setLatencyOptimization(StreamLatencyOptimization.NONE))
|
||||
|
||||
[//]: # ( .build();)
|
||||
|
||||
[//]: # (//Streamed output)
|
||||
|
||||
[//]: # (SpeechGenerationBuilder.speechToSpeech())
|
||||
|
||||
[//]: # ( .streamed())
|
||||
|
||||
[//]: # ( .setInputFile(File))
|
||||
|
||||
[//]: # ( .setGeneratedAudioOutputFormat(GeneratedAudioOutputFormat.MP3_44100_128))
|
||||
|
||||
[//]: # ( .setVoiceId("voiceIdString"))
|
||||
|
||||
[//]: # ( .setVoiceSettings(VoiceSettings))
|
||||
|
||||
[//]: # ( .setVoice(Voice) // or use a voice object, which will pull settings / ID out of the Voice)
|
||||
|
||||
[//]: # ( .setModelId("modelIdString"))
|
||||
|
||||
[//]: # ( .setModel(ElevenLabsVoiceModel.ELEVEN_ENGLISH_STS_V2))
|
||||
|
||||
[//]: # ( .setLatencyOptimization(StreamLatencyOptimization.NONE))
|
||||
|
||||
[//]: # ( .build();)
|
||||
|
||||
[//]: # (```)
|
||||
|
||||
### Text to Speech
|
||||
```java
|
||||
//File output
|
||||
SpeechGenerationBuilder.textToSpeech()
|
||||
.file() // output type of file (or use .streamed() for an InputStream)
|
||||
.setText(String text)
|
||||
.setGeneratedAudioOutputFormat(GeneratedAudioOutputFormat.MP3_44100_128)
|
||||
.setVoiceId("voiceIdString")
|
||||
.setVoiceSettings(VoiceSettings)
|
||||
.setVoice(Voice) // or use a voice object, which will pull settings / ID out of the Voice
|
||||
.setModelId("modelIdString")
|
||||
.setModel(ElevenLabsVoiceModel.ELEVEN_ENGLISH_STS_V2)
|
||||
.setLatencyOptimization(StreamLatencyOptimization.NONE)
|
||||
.build();
|
||||
//Streamed output
|
||||
SpeechGenerationBuilder.textToSpeech()
|
||||
.streamed()
|
||||
.setText(String text)
|
||||
.setGeneratedAudioOutputFormat(GeneratedAudioOutputFormat.MP3_44100_128)
|
||||
.setVoiceId("voiceIdString")
|
||||
.setVoiceSettings(VoiceSettings)
|
||||
.setVoice(Voice) // or use a voice object, which will pull settings / ID out of the Voice
|
||||
.setModelId("modelIdString")
|
||||
.setModel(ElevenLabsVoiceModel.ELEVEN_ENGLISH_STS_V2)
|
||||
.setLatencyOptimization(StreamLatencyOptimization.NONE)
|
||||
.build();
|
||||
```
|
||||
|
||||
- - -
|
||||
|
||||
## Voices
|
||||
### Accessing your List of Available Voices
|
||||
To retrieve your list of accessible Voices, you can statically utilize `Voice#getVoices()`. This will return both ElevenLab's pregenerated `Voice` models, as well as any personal `Voices` you have generated.
|
||||
@@ -163,23 +210,208 @@ builder.withLabel("accent", "American");
|
||||
voice = builder.create();
|
||||
```
|
||||
|
||||
### Generating Audio
|
||||
### Generating Audio (TTS + STS)
|
||||
To generate an audio file with a given `Voice`, you can utilize the `Voice#generate(...)` functions.
|
||||
Depending on how you access your `Voice`, (with or without settings), will decide whether you can use the implicit `voiceSettings` or if you have to specify the `VoiceSettings` object to use. Unless explicitly requesting the `Voice` without settings, every `Voice` object SHOULD contain its default `VoiceSettings`.
|
||||
```java
|
||||
|
||||
Voice voice;
|
||||
File file = voice.generate(String text);
|
||||
File file = voice.generate(String text, VoiceSettings settings);
|
||||
File file = voice.generate(String text, String model, VoiceSettings settings);
|
||||
File file = voice.generate(String text, String model);
|
||||
|
||||
InputStream inputStream = voice.generateStream(String text);
|
||||
InputStream inputStream = voice.generateStream(String text, VoiceSettings settings);
|
||||
InputStream inputStream = voice.generateStream(String text, String model, VoiceSettings settings);
|
||||
InputStream inputStream = voice.generateStream(String text, String model);
|
||||
File file = voice.generate("Hello world!", "my_favorite_model");
|
||||
...
|
||||
//Available Functions:
|
||||
public File generate(String text, String model);
|
||||
|
||||
public File generate(String text, String model, VoiceSettings settings);
|
||||
|
||||
public File generate(String text, String model, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||
|
||||
public File generate(String text, String model, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat);
|
||||
|
||||
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat);
|
||||
|
||||
public File generate(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization);
|
||||
|
||||
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||
|
||||
public File generate(String text, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||
|
||||
public File generate(String text, StreamLatencyOptimization streamLatencyOptimization);
|
||||
|
||||
public File generate(String text, VoiceSettings settings);
|
||||
|
||||
public File generate(String text);
|
||||
|
||||
public InputStream generateStream(String text, String model);
|
||||
|
||||
public InputStream generateStream(String text, String model, VoiceSettings settings);
|
||||
|
||||
public InputStream generateStream(String text, VoiceSettings settings);
|
||||
|
||||
public InputStream generateStream(String text);
|
||||
|
||||
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||
|
||||
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings settings);
|
||||
|
||||
public InputStream generateStream(String text, VoiceSettings settings, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||
|
||||
public InputStream generateStream(String text, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization);
|
||||
|
||||
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization);
|
||||
|
||||
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings settings);
|
||||
|
||||
public InputStream generateStream(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization);
|
||||
|
||||
public InputStream generateStream(String text, StreamLatencyOptimization streamLatencyOptimization);
|
||||
|
||||
```
|
||||
- - -
|
||||
|
||||
[//]: # (public File speechToSpeech(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId, VoiceSettings voiceSettings);)
|
||||
|
||||
[//]: # ()
|
||||
[//]: # (public File speechToSpeech(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId);)
|
||||
|
||||
[//]: # ()
|
||||
[//]: # (public File speechToSpeech(File audioFile, String modelId);)
|
||||
|
||||
[//]: # ()
|
||||
[//]: # (public InputStream speechToSpeechStream(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId, VoiceSettings voiceSettings);)
|
||||
|
||||
[//]: # ()
|
||||
[//]: # (public InputStream speechToSpeechStream(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId);)
|
||||
|
||||
[//]: # ()
|
||||
[//]: # (public InputStream speechToSpeechStream(File audioFile, String modelId);)
|
||||
|
||||
|
||||
- - -
|
||||
## Audio Native Projects
|
||||
### Creating an Audio Native Project
|
||||
You can create audio native projects using the AudioNative API.
|
||||
```java
|
||||
CreateAudioEnabledProjectRequest request = new CreateAudioEnabledProjectRequest()
|
||||
.setName("Project name")
|
||||
.setImage("https://...com/img.png")
|
||||
.setAuthor("Andrew")
|
||||
.setSmall(true)
|
||||
.setTextColor("red")
|
||||
.setBackgroundColor("black")
|
||||
.setSessionization(3)
|
||||
.setVoiceId("aso23809")
|
||||
.setModelId("my_favorite_model")
|
||||
.setFile(new File("input.dat"))
|
||||
.setAutoConvert(true);
|
||||
|
||||
CreateAudioEnabledProjectModelResponse response = ElevenLabs.getAudioNativeAPI()
|
||||
.createAudioEnabledProject(request);
|
||||
```
|
||||
|
||||
- - -
|
||||
## Projects
|
||||
## Create a project
|
||||
You can create a new project using the AddProjectRequest builder.
|
||||
```java
|
||||
AddProjectRequest request = new AddProjectRequest()
|
||||
.setName("name")
|
||||
.setFromUrl("...")
|
||||
.setFromDocument(new File("file.dat"))
|
||||
.setDefaultTitleVoiceId("voiceA")
|
||||
.setDefaultParagraphVoiceId("voiceB")
|
||||
.setDefaultModelId("the_default_model_of_your_dreams")
|
||||
.setProjectOutputQuality(ProjectOutputQuality.STANDARD)
|
||||
.setTitle("Big Title")
|
||||
.setAuthor("Best Author")
|
||||
.setIsbnNumber("THE. ISBN.")
|
||||
.setAcxVolumeNormalization(true);
|
||||
|
||||
Project project = Project.addProject(request);
|
||||
|
||||
```
|
||||
|
||||
## Get a Project
|
||||
Get a project by it's specific project ID.
|
||||
```java
|
||||
Project project = Project.getProjectById(projectId);
|
||||
```
|
||||
|
||||
## Get all Projects
|
||||
Get all of the projects associated with your account.
|
||||
```java
|
||||
List<Project> projects = Project.getProjects();
|
||||
```
|
||||
|
||||
## Interacting with Projects
|
||||
```java
|
||||
Project project;
|
||||
// Delete a project
|
||||
String deleteResult = project.delete();
|
||||
|
||||
// Convert a project
|
||||
String conversionResult = project.convertProject();
|
||||
|
||||
//Get the project's snapshots.
|
||||
List<ProjectSnapshot> snapshots = project.getSnapshots();
|
||||
|
||||
// Access your chapters from memory
|
||||
List<Chapter> chapters = project.getChapters();
|
||||
|
||||
// Refresh your local Project's chapters from the API
|
||||
chapters = project.fetchUpdatedChapters(); // This will update the existing project object and return the list of new chapters
|
||||
|
||||
// Get a chapter by ID
|
||||
Chapter chapter = project.getChapterById(chapterId);
|
||||
|
||||
// Delete a chapter
|
||||
String result = project.deleteChapter(chapter);
|
||||
|
||||
// Convert a chapter
|
||||
String result = project.convertChapter(chapter);
|
||||
|
||||
// Get chapter snapshots
|
||||
List<ChapterSnapshot> snapshots = project.getChapterSnapshots(chapter);
|
||||
|
||||
```
|
||||
|
||||
## Interacting with Chapters
|
||||
```java
|
||||
Project project;
|
||||
Chapter chapter = project.getChapterById("chapter_id");
|
||||
|
||||
// Delete a chapter
|
||||
chapter.deleteChapter(project.getProjectId());
|
||||
|
||||
// Convert a chapter
|
||||
chapter.convertChapter(project.getProjectId());
|
||||
|
||||
// Get a chapter's snapshots
|
||||
List<ChapterSnapshot> snapshots = chapter.getChapterSnapshots(project.getProjectId());
|
||||
|
||||
//
|
||||
|
||||
```
|
||||
|
||||
## Accessing Snapshot Audio
|
||||
Accessing a ProjectSnapshot audio stream:
|
||||
```java
|
||||
Project project;
|
||||
List<ProjectSnapshot> projectSnapshots = project.getSnapshots();
|
||||
ProjectSnapshot first = projectSnapshots.get(0);
|
||||
InputStream audio = first.getAudioStream();
|
||||
```
|
||||
|
||||
Accessing a ChapterSnapshot audio stream:
|
||||
```java
|
||||
Project project;
|
||||
Chapter chapter;
|
||||
List<ChapterSnapshot> chapterSnapshots = project.getChapterSnapshots(chapter);
|
||||
ChapterSnapshot first = chapterSnapshots.get(0);
|
||||
InputStream audio = first.getAudioStream();
|
||||
```
|
||||
|
||||
Both ProjectSnapshot and ChapterSnapshot are of type Snapshot.
|
||||
- - -
|
||||
## Samples
|
||||
A `Sample` is used as the training data for a given `Voice` model.
|
||||
### Accessing Voice Samples
|
||||
@@ -212,6 +444,19 @@ To get your ElevenLabs generation `History`, you can utilize `History#get()`. (Y
|
||||
History history = History.get();
|
||||
```
|
||||
|
||||
|
||||
### Getting all History Items
|
||||
The History endpoint accepts page size parameters and a start-after-history-id parameter. We can use this to fetch all of our HistoryItems.
|
||||
```java
|
||||
History history = History.get(); // the latest history object
|
||||
Optional<History> hist = Optional.of(history);
|
||||
List<HistoryItem> items = new ArrayList();
|
||||
do {
|
||||
items.addAll(hist.get().getHistoryItems());
|
||||
hist = hist.get().next();
|
||||
} while(hist.isPresent() && hist.hasMore());
|
||||
```
|
||||
|
||||
### Getting a History Item
|
||||
To retrieve a `HistoryItem` from your `History`, you can use `History#getHistoryItem(String itemId)`.
|
||||
```java
|
||||
@@ -248,6 +493,10 @@ A `HistoryItem` is a previous TTS generation. You can download the generation as
|
||||
HistoryItem item;
|
||||
File file = item.downloadAudio();
|
||||
```
|
||||
- - -
|
||||
### Projects
|
||||
The `Projects`
|
||||
|
||||
- - -
|
||||
|
||||
## User Management
|
||||
@@ -278,6 +527,11 @@ If you like what you see, give it a star! :)
|
||||
|
||||
- - -
|
||||
|
||||
## Todo
|
||||
I will probably rework the 2 new builders I added when I added projects support. Their usage should be more clear, though the documentation covers their use cases I believe.
|
||||
|
||||
- - -
|
||||
|
||||
#### Unit Testing
|
||||
Unit tests have been created, these endpoints are destructive and not included in the testing:
|
||||
* deleteHistoryItem - WONT TEST
|
||||
|
||||
100
pom.xml
100
pom.xml
@@ -6,6 +6,7 @@
|
||||
|
||||
<name>Unofficial Java ElevenLabs Voice API</name>
|
||||
<description>An API level interaction between Java and the ElevenLabs Voice Generation Web API.</description>
|
||||
<url>https://github.com/AndrewCPU/elevenlabs-api</url>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>Andrewcpu</id>
|
||||
@@ -24,17 +25,42 @@
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>github</id>
|
||||
<name>GitHub AndrewCPU Apache Maven Packages</name>
|
||||
<url>https://maven.pkg.github.com/AndrewCPU/elevenlabs-api</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>github</id>
|
||||
<name>GitHub AndrewCPU Apache Maven Packages</name>
|
||||
<url>https://maven.pkg.github.com/AndrewCPU/elevenlabs-api</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>ossrh</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>ossrh</id>
|
||||
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/projectSnapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
||||
<groupId>net.andrewcpu</groupId>
|
||||
<artifactId>elevenlabs-api</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<version>2.7.8</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
@@ -54,17 +80,17 @@
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.13.4.1</version>
|
||||
<version>2.15.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.13.4</version>
|
||||
<version>2.15.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.13.4</version>
|
||||
<version>2.15.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
@@ -94,6 +120,20 @@
|
||||
<build>
|
||||
<finalName>elevenlabs-api-${version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
@@ -114,6 +154,46 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Generates JAR's source file -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.13</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Generates Javadoc JAR file -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -1,126 +1,83 @@
|
||||
package net.andrewcpu.elevenlabs;
|
||||
|
||||
import net.andrewcpu.elevenlabs.model.history.History;
|
||||
import net.andrewcpu.elevenlabs.model.history.HistoryItem;
|
||||
import net.andrewcpu.elevenlabs.model.request.TextToSpeechRequest;
|
||||
import net.andrewcpu.elevenlabs.model.response.CreateVoiceResponse;
|
||||
import net.andrewcpu.elevenlabs.model.response.GenerationTypeModel;
|
||||
import net.andrewcpu.elevenlabs.model.user.Subscription;
|
||||
import net.andrewcpu.elevenlabs.model.user.User;
|
||||
import net.andrewcpu.elevenlabs.model.voice.Voice;
|
||||
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||
import net.andrewcpu.elevenlabs.requests.ElevenLabsRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.history.*;
|
||||
import net.andrewcpu.elevenlabs.requests.models.GetModelsRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.samples.DeleteSampleRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.samples.GetSampleRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.tts.PostTextToSpeechRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.tts.PostTextToSpeechStreamedRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.user.GetSubscriptionRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.user.GetUserRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.voices.*;
|
||||
import net.andrewcpu.elevenlabs.util.ElevenNetworkUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import net.andrewcpu.elevenlabs.api.impl.*;
|
||||
|
||||
public class ElevenLabs {
|
||||
private static String API_KEY = null;
|
||||
private static HistoryAPI historyAPI;
|
||||
private static ModelsAPI modelsAPI;
|
||||
private static ProjectsAPI projectsAPI;
|
||||
private static SampleAPI sampleAPI;
|
||||
private static SpeechToSpeechAPI speechToSpeechAPI;
|
||||
private static TextToSpeechAPI textToSpeechAPI;
|
||||
private static UserAPI userAPI;
|
||||
private static VoiceAPI voiceAPI;
|
||||
private static AudioNativeAPI audioNativeAPI;
|
||||
|
||||
public static String getApiKey() {
|
||||
return API_KEY;
|
||||
}
|
||||
private static String defaultModel = "eleven_monolingual_v1";
|
||||
|
||||
public static String getDefaultModel() {
|
||||
return defaultModel;
|
||||
}
|
||||
|
||||
public static void setDefaultModel(String defaultModel) {
|
||||
ElevenLabs.defaultModel = defaultModel;
|
||||
}
|
||||
|
||||
public static void setApiKey(String apiKey) {
|
||||
API_KEY = apiKey;
|
||||
initializeSubclasses();
|
||||
}
|
||||
|
||||
private static <T> T sendRequest(ElevenLabsRequest<T> request) {
|
||||
return ElevenNetworkUtil.sendRequest(request.getType(),request.getEndpoint(), request.getPayload(),request.getResponseClass());
|
||||
private static void initializeSubclasses() {
|
||||
ElevenLabs.historyAPI = new HistoryAPI();
|
||||
ElevenLabs.modelsAPI = new ModelsAPI();
|
||||
ElevenLabs.projectsAPI = new ProjectsAPI();
|
||||
ElevenLabs.sampleAPI = new SampleAPI();
|
||||
ElevenLabs.speechToSpeechAPI = new SpeechToSpeechAPI();
|
||||
ElevenLabs.textToSpeechAPI = new TextToSpeechAPI();
|
||||
ElevenLabs.userAPI = new UserAPI();
|
||||
ElevenLabs.voiceAPI = new VoiceAPI();
|
||||
ElevenLabs.audioNativeAPI = new AudioNativeAPI();
|
||||
}
|
||||
|
||||
public static History getHistory() {
|
||||
return sendRequest(new GetHistoryRequest());
|
||||
public static AudioNativeAPI getAudioNativeAPI() {
|
||||
return audioNativeAPI;
|
||||
}
|
||||
|
||||
public static User getUser() {
|
||||
return sendRequest(new GetUserRequest());
|
||||
public static HistoryAPI getHistoryAPI() {
|
||||
return historyAPI;
|
||||
}
|
||||
|
||||
public static Subscription getSubscription() {
|
||||
return sendRequest(new GetSubscriptionRequest());
|
||||
public static ModelsAPI getModelsAPI() {
|
||||
return modelsAPI;
|
||||
}
|
||||
|
||||
public static HistoryItem getHistoryItem(String historyItemId) {
|
||||
return sendRequest(new GetHistoryItemByIdRequest(historyItemId));
|
||||
public static ProjectsAPI getProjectsAPI() {
|
||||
return projectsAPI;
|
||||
}
|
||||
|
||||
public static String deleteHistoryItem(String historyItemId) {
|
||||
return sendRequest(new DeleteHistoryItemRequest(historyItemId));
|
||||
public static SampleAPI getSampleAPI() {
|
||||
return sampleAPI;
|
||||
}
|
||||
|
||||
public static File getHistoryItemAudio(String historyItemId) {
|
||||
return sendRequest(new GetHistoryItemAudioRequest(historyItemId));
|
||||
public static SpeechToSpeechAPI getSpeechToSpeechAPI() {
|
||||
return speechToSpeechAPI;
|
||||
}
|
||||
|
||||
public static File getHistoryItemAudio(String... historyItemIds) {
|
||||
return sendRequest(new PostDownloadHistoryItemsRequest(historyItemIds));
|
||||
public static TextToSpeechAPI getTextToSpeechAPI() {
|
||||
return textToSpeechAPI;
|
||||
}
|
||||
|
||||
public static String deleteSample(String voiceId, String sampleId) {
|
||||
return sendRequest(new DeleteSampleRequest(voiceId, sampleId));
|
||||
public static UserAPI getUserAPI() {
|
||||
return userAPI;
|
||||
}
|
||||
|
||||
public static File getAudioSample(String voiceId, String sampleId) {
|
||||
return sendRequest(new GetSampleRequest(voiceId, sampleId));
|
||||
}
|
||||
|
||||
public static List<Voice> getVoices() {
|
||||
return sendRequest(new GetVoicesRequest()).getVoices();
|
||||
}
|
||||
|
||||
public static VoiceSettings getDefaultVoiceSettings() {
|
||||
return sendRequest(new GetDefaultVoiceSettingsRequest());
|
||||
}
|
||||
|
||||
public static VoiceSettings getVoiceSettings(String voiceId) {
|
||||
return sendRequest(new GetVoiceSettingsRequest(voiceId));
|
||||
}
|
||||
|
||||
public static Voice getVoice(String voiceId) {
|
||||
return sendRequest(new GetVoiceRequest(voiceId));
|
||||
}
|
||||
|
||||
public static Voice getVoice(String voiceId, boolean withSettings) {
|
||||
return sendRequest(new GetVoiceRequest(voiceId, withSettings));
|
||||
}
|
||||
|
||||
public static String deleteVoice(String voiceId) {
|
||||
return sendRequest(new DeleteVoiceRequest(voiceId));
|
||||
}
|
||||
|
||||
public static String editVoiceSettings(String voiceId, VoiceSettings settings) {
|
||||
return sendRequest(new PostEditVoiceSettingsRequest(voiceId, settings));
|
||||
}
|
||||
|
||||
public static CreateVoiceResponse createVoice(String name, File[] files, String description, Map<String, String> labels) {
|
||||
return sendRequest(new PostAddVoiceRequest(name, files, description, labels));
|
||||
}
|
||||
public static String editVoice(String voiceId, String name, File[] files, String description, Map<String, String> labels) {
|
||||
return sendRequest(new PostEditVoiceRequest(voiceId, name, files, description, labels));
|
||||
}
|
||||
|
||||
public static GenerationTypeModel[] getAvailableModels() {
|
||||
return sendRequest(new GetModelsRequest());
|
||||
}
|
||||
|
||||
public static File generateTextToSpeech(String voiceId, String text, String modelId, VoiceSettings voiceSettings) {
|
||||
return sendRequest(new PostTextToSpeechRequest(voiceId, new TextToSpeechRequest(text, modelId, voiceSettings)));
|
||||
}
|
||||
|
||||
public static InputStream generateTextToSpeechStreamed(String voiceId, String text, String modelId, VoiceSettings voiceSettings) {
|
||||
return sendRequest(new PostTextToSpeechStreamedRequest(voiceId, new TextToSpeechRequest(text, modelId, voiceSettings)));
|
||||
public static VoiceAPI getVoiceAPI() {
|
||||
return voiceAPI;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.andrewcpu.elevenlabs.api;
|
||||
|
||||
import net.andrewcpu.elevenlabs.requests.ElevenLabsRequest;
|
||||
import net.andrewcpu.elevenlabs.util.ElevenNetworkUtil;
|
||||
|
||||
public abstract class ElevenLabsAPI {
|
||||
public ElevenLabsAPI() {
|
||||
}
|
||||
|
||||
protected <T> T sendRequest(ElevenLabsRequest<T> request) {
|
||||
return ElevenNetworkUtil.sendRequest(request.getType(),request.getEndpoint(), request.getPayload(),request.getResponseClass());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.andrewcpu.elevenlabs.api.impl;
|
||||
|
||||
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||
import net.andrewcpu.elevenlabs.model.request.CreateAudioNativeProjectRequest;
|
||||
import net.andrewcpu.elevenlabs.model.response.CreateAudioEnabledProjectModelResponse;
|
||||
import net.andrewcpu.elevenlabs.requests.audionative.PostCreateAudioNativeProjectRequest;
|
||||
|
||||
public class AudioNativeAPI extends ElevenLabsAPI {
|
||||
public CreateAudioEnabledProjectModelResponse createAudioEnabledProject(CreateAudioNativeProjectRequest request) {
|
||||
return sendRequest(new PostCreateAudioNativeProjectRequest(request));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.andrewcpu.elevenlabs.api.impl;
|
||||
|
||||
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||
import net.andrewcpu.elevenlabs.model.history.History;
|
||||
import net.andrewcpu.elevenlabs.model.history.HistoryItem;
|
||||
import net.andrewcpu.elevenlabs.requests.history.*;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class HistoryAPI extends ElevenLabsAPI {
|
||||
|
||||
public History getHistory() {
|
||||
return sendRequest(new GetHistoryRequest());
|
||||
}
|
||||
|
||||
public History getHistory(int pageSize, String afterHistoryId) {
|
||||
return sendRequest(new GetHistoryRequest(pageSize, afterHistoryId));
|
||||
}
|
||||
|
||||
public History getHistory(String afterHistoryId) {
|
||||
return sendRequest(new GetHistoryRequest(afterHistoryId));
|
||||
}
|
||||
|
||||
public HistoryItem getHistoryItem(String historyItemId) {
|
||||
return sendRequest(new GetHistoryItemByIdRequest(historyItemId));
|
||||
}
|
||||
|
||||
public String deleteHistoryItem(String historyItemId) {
|
||||
return sendRequest(new DeleteHistoryItemRequest(historyItemId));
|
||||
}
|
||||
|
||||
public File getHistoryItemAudio(String historyItemId) {
|
||||
return sendRequest(new GetHistoryItemAudioRequest(historyItemId));
|
||||
}
|
||||
|
||||
public File getHistoryItemAudio(String... historyItemIds) {
|
||||
return sendRequest(new PostDownloadHistoryItemsRequest(historyItemIds));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.andrewcpu.elevenlabs.api.impl;
|
||||
|
||||
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||
import net.andrewcpu.elevenlabs.model.response.GenerationTypeModel;
|
||||
import net.andrewcpu.elevenlabs.requests.models.GetModelsRequest;
|
||||
|
||||
public class ModelsAPI extends ElevenLabsAPI {
|
||||
|
||||
public GenerationTypeModel[] getAvailableModels() {
|
||||
return sendRequest(new GetModelsRequest());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package net.andrewcpu.elevenlabs.api.impl;
|
||||
|
||||
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||
import net.andrewcpu.elevenlabs.model.projects.Chapter;
|
||||
import net.andrewcpu.elevenlabs.model.projects.ChapterSnapshot;
|
||||
import net.andrewcpu.elevenlabs.model.projects.Project;
|
||||
import net.andrewcpu.elevenlabs.model.projects.ProjectSnapshot;
|
||||
import net.andrewcpu.elevenlabs.model.request.AddProjectRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.projects.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectsAPI extends ElevenLabsAPI {
|
||||
public List<Project> getProjects() {
|
||||
return sendRequest(new GetProjectsRequest()).getProjects();
|
||||
}
|
||||
|
||||
public Project addProject(AddProjectRequest addProjectRequest) {
|
||||
return sendRequest(new PostAddProjectRequest(addProjectRequest)).getProject();
|
||||
}
|
||||
|
||||
public Project getProject(String id) {
|
||||
return sendRequest(new GetProjectByIdRequest(id));
|
||||
}
|
||||
|
||||
public String deleteProject(String projectId) {
|
||||
return sendRequest(new DeleteProjectByIdRequest(projectId));
|
||||
}
|
||||
|
||||
public String convertProject(String projectId) {
|
||||
return sendRequest(new PostConvertProjectRequest(projectId));
|
||||
}
|
||||
|
||||
public List<ProjectSnapshot> getProjectSnapshots(String projectId) {
|
||||
return sendRequest(new GetProjectSnapshotsRequest(projectId)).getSnapshots();
|
||||
}
|
||||
|
||||
public InputStream getProjectSnapshotAudioStream(String projectId, String projectSnapshotId) {
|
||||
return sendRequest(new PostStreamProjectSnapshotAudioRequest(projectId, projectSnapshotId));
|
||||
}
|
||||
|
||||
public List<Chapter> getChapters(String projectId) {
|
||||
return sendRequest(new GetProjectChaptersRequest(projectId)).getChapters();
|
||||
}
|
||||
|
||||
public Chapter getChapterById(String projectId, String chapterId) {
|
||||
return sendRequest(new GetChapterByIdRequest(projectId, chapterId));
|
||||
}
|
||||
|
||||
public String deleteChapter(String projectId, String chapterId) {
|
||||
return sendRequest(new DeleteChapterByIdRequest(projectId, chapterId));
|
||||
}
|
||||
|
||||
public String convertChapter(String projectId, String chapterId) {
|
||||
return sendRequest(new PostConvertChapterRequest(projectId, chapterId));
|
||||
}
|
||||
|
||||
public List<ChapterSnapshot> getChapterSnapshots(String projectId, String chapterId) {
|
||||
return sendRequest(new GetChapterSnapshotsRequest(projectId, chapterId)).getSnapshots();
|
||||
}
|
||||
|
||||
public InputStream getChapterSnapshotAudioStream(String projectId, String chapterId, String chapterSnapshotId) {
|
||||
return sendRequest(new PostStreamChapterSnapshotAudioRequest(projectId, chapterId, chapterSnapshotId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.andrewcpu.elevenlabs.api.impl;
|
||||
|
||||
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||
import net.andrewcpu.elevenlabs.requests.samples.DeleteSampleRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.samples.GetSampleRequest;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SampleAPI extends ElevenLabsAPI {
|
||||
|
||||
public String deleteSample(String voiceId, String sampleId) {
|
||||
return sendRequest(new DeleteSampleRequest(voiceId, sampleId));
|
||||
}
|
||||
|
||||
public File getAudioSample(String voiceId, String sampleId) {
|
||||
return sendRequest(new GetSampleRequest(voiceId, sampleId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.andrewcpu.elevenlabs.api.impl;
|
||||
|
||||
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||
import net.andrewcpu.elevenlabs.enums.ElevenLabsVoiceModel;
|
||||
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
||||
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||
import net.andrewcpu.elevenlabs.requests.sts.PostSpeechToSpeechRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.sts.PostSpeechToSpeechStreamedRequest;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class SpeechToSpeechAPI extends ElevenLabsAPI {
|
||||
public File generateSpeechToSpeech(String voiceId, VoiceSettings voiceSettings, String modelId, File audio) {
|
||||
return generateSpeechToSpeech(voiceId, voiceSettings, modelId, audio, StreamLatencyOptimization.getDefault());
|
||||
}
|
||||
|
||||
public File generateSpeechToSpeech(String voiceId, VoiceSettings voiceSettings, String modelId, File audio, StreamLatencyOptimization latencyOptimization) {
|
||||
return sendRequest(new PostSpeechToSpeechRequest(voiceId, voiceSettings,audio, modelId, latencyOptimization));
|
||||
}
|
||||
|
||||
public InputStream generateSpeechToSpeechStream(String voiceId, VoiceSettings voiceSettings, String modelId, File audio, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return sendRequest(new PostSpeechToSpeechStreamedRequest(voiceId, voiceSettings, audio, modelId, streamLatencyOptimization));
|
||||
}
|
||||
|
||||
public InputStream generateSpeechToSpeechStream(String voiceId, VoiceSettings voiceSettings, String modelId, File audio) {
|
||||
return generateSpeechToSpeechStream(voiceId, voiceSettings, modelId, audio, StreamLatencyOptimization.getDefault());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public File generateSpeechToSpeech(String voiceId, VoiceSettings voiceSettings, ElevenLabsVoiceModel model, File audio) {
|
||||
return generateSpeechToSpeech(voiceId, voiceSettings, model.getModelId(), audio, StreamLatencyOptimization.getDefault());
|
||||
}
|
||||
|
||||
public File generateSpeechToSpeech(String voiceId, VoiceSettings voiceSettings, ElevenLabsVoiceModel model, File audio, StreamLatencyOptimization latencyOptimization) {
|
||||
return sendRequest(new PostSpeechToSpeechRequest(voiceId, voiceSettings,audio, model.getModelId(), latencyOptimization));
|
||||
}
|
||||
|
||||
public InputStream generateSpeechToSpeechStream(String voiceId, VoiceSettings voiceSettings, ElevenLabsVoiceModel model, File audio, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return sendRequest(new PostSpeechToSpeechStreamedRequest(voiceId, voiceSettings, audio, model.getModelId(), streamLatencyOptimization));
|
||||
}
|
||||
|
||||
public InputStream generateSpeechToSpeechStream(String voiceId, VoiceSettings voiceSettings, ElevenLabsVoiceModel model, File audio) {
|
||||
return generateSpeechToSpeechStream(voiceId, voiceSettings, model.getModelId(), audio, StreamLatencyOptimization.getDefault());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.andrewcpu.elevenlabs.api.impl;
|
||||
|
||||
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||
import net.andrewcpu.elevenlabs.enums.GeneratedAudioOutputFormat;
|
||||
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
||||
import net.andrewcpu.elevenlabs.model.request.TextToSpeechRequest;
|
||||
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||
import net.andrewcpu.elevenlabs.requests.tts.PostTextToSpeechRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.tts.PostTextToSpeechStreamedRequest;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class TextToSpeechAPI extends ElevenLabsAPI {
|
||||
|
||||
public File generateTextToSpeech(String voiceId, String text, String modelId, VoiceSettings voiceSettings) {
|
||||
return sendRequest(new PostTextToSpeechRequest(voiceId, new TextToSpeechRequest(text, modelId, voiceSettings)));
|
||||
}
|
||||
|
||||
public File generateTextToSpeech(String voiceId, String text, String modelId, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings voiceSettings) {
|
||||
return sendRequest(new PostTextToSpeechRequest(voiceId, new TextToSpeechRequest(text, modelId, voiceSettings), streamLatencyOptimization, outputFormat));
|
||||
}
|
||||
public InputStream generateTextToSpeechStreamed(String voiceId, String text, String modelId, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings voiceSettings) {
|
||||
return sendRequest(new PostTextToSpeechStreamedRequest(voiceId, new TextToSpeechRequest(text, modelId, voiceSettings), streamLatencyOptimization, outputFormat));
|
||||
}
|
||||
|
||||
public InputStream generateTextToSpeechStreamed(String voiceId, String text, String modelId, VoiceSettings voiceSettings) {
|
||||
return sendRequest(new PostTextToSpeechStreamedRequest(voiceId, new TextToSpeechRequest(text, modelId, voiceSettings)));
|
||||
}
|
||||
|
||||
}
|
||||
19
src/main/java/net/andrewcpu/elevenlabs/api/impl/UserAPI.java
Normal file
19
src/main/java/net/andrewcpu/elevenlabs/api/impl/UserAPI.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package net.andrewcpu.elevenlabs.api.impl;
|
||||
|
||||
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||
import net.andrewcpu.elevenlabs.model.user.Subscription;
|
||||
import net.andrewcpu.elevenlabs.model.user.User;
|
||||
import net.andrewcpu.elevenlabs.requests.user.GetSubscriptionRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.user.GetUserRequest;
|
||||
|
||||
public class UserAPI extends ElevenLabsAPI {
|
||||
|
||||
|
||||
public User getUser() {
|
||||
return sendRequest(new GetUserRequest());
|
||||
}
|
||||
|
||||
public Subscription getSubscription() {
|
||||
return sendRequest(new GetSubscriptionRequest());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package net.andrewcpu.elevenlabs.api.impl;
|
||||
|
||||
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||
import net.andrewcpu.elevenlabs.model.response.CreateVoiceResponse;
|
||||
import net.andrewcpu.elevenlabs.model.response.ProjectsModelResponse;
|
||||
import net.andrewcpu.elevenlabs.model.voice.Voice;
|
||||
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||
import net.andrewcpu.elevenlabs.requests.projects.GetProjectsRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.voices.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class VoiceAPI extends ElevenLabsAPI {
|
||||
|
||||
public List<Voice> getVoices() {
|
||||
return sendRequest(new GetVoicesRequest()).getVoices();
|
||||
}
|
||||
|
||||
public VoiceSettings getDefaultVoiceSettings() {
|
||||
return sendRequest(new GetDefaultVoiceSettingsRequest());
|
||||
}
|
||||
|
||||
public VoiceSettings getVoiceSettings(String voiceId) {
|
||||
return sendRequest(new GetVoiceSettingsRequest(voiceId));
|
||||
}
|
||||
|
||||
public Voice getVoice(String voiceId) {
|
||||
return sendRequest(new GetVoiceRequest(voiceId));
|
||||
}
|
||||
|
||||
public Voice getVoice(String voiceId, boolean withSettings) {
|
||||
return sendRequest(new GetVoiceRequest(voiceId, withSettings));
|
||||
}
|
||||
|
||||
public ProjectsModelResponse getProjects() {
|
||||
return sendRequest(new GetProjectsRequest());
|
||||
}
|
||||
|
||||
public String deleteVoice(String voiceId) {
|
||||
return sendRequest(new DeleteVoiceRequest(voiceId));
|
||||
}
|
||||
|
||||
public String editVoiceSettings(String voiceId, VoiceSettings settings) {
|
||||
return sendRequest(new PostEditVoiceSettingsRequest(voiceId, settings));
|
||||
}
|
||||
|
||||
public CreateVoiceResponse createVoice(String name, File[] files, String description, Map<String, String> labels) {
|
||||
return sendRequest(new PostAddVoiceRequest(name, files, description, labels));
|
||||
}
|
||||
public String editVoice(String voiceId, String name, File[] files, String description, Map<String, String> labels) {
|
||||
return sendRequest(new PostEditVoiceRequest(voiceId, name, files, description, labels));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.andrewcpu.elevenlabs.builders;
|
||||
|
||||
public class SpeechGenerationBuilder {
|
||||
public static SpeechToSpeechBuilder speechToSpeech() {
|
||||
return new SpeechToSpeechBuilder();
|
||||
}
|
||||
|
||||
public static TextToSpeechBuilder textToSpeech() {
|
||||
return new TextToSpeechBuilder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.andrewcpu.elevenlabs.builders;
|
||||
|
||||
import net.andrewcpu.elevenlabs.builders.impl.s2s.SpeechToSpeechFileBuilder;
|
||||
import net.andrewcpu.elevenlabs.builders.impl.s2s.SpeechToSpeechStreamedBuilder;
|
||||
|
||||
public class SpeechToSpeechBuilder {
|
||||
|
||||
public SpeechToSpeechStreamedBuilder streamed() {
|
||||
return new SpeechToSpeechStreamedBuilder();
|
||||
}
|
||||
|
||||
public SpeechToSpeechFileBuilder file() {
|
||||
return new SpeechToSpeechFileBuilder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.andrewcpu.elevenlabs.builders;
|
||||
|
||||
|
||||
import net.andrewcpu.elevenlabs.builders.impl.tts.TextToSpeechFileBuilder;
|
||||
import net.andrewcpu.elevenlabs.builders.impl.tts.TextToSpeechStreamedBuilder;
|
||||
|
||||
public class TextToSpeechBuilder {
|
||||
public TextToSpeechStreamedBuilder streamed() {
|
||||
return new TextToSpeechStreamedBuilder();
|
||||
}
|
||||
|
||||
public TextToSpeechFileBuilder file() {
|
||||
return new TextToSpeechFileBuilder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package net.andrewcpu.elevenlabs.builders.abstracts;
|
||||
|
||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.builders.SpeechToSpeechBuilder;
|
||||
import net.andrewcpu.elevenlabs.builders.TextToSpeechBuilder;
|
||||
import net.andrewcpu.elevenlabs.enums.ElevenLabsVoiceModel;
|
||||
import net.andrewcpu.elevenlabs.enums.GeneratedAudioOutputFormat;
|
||||
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
||||
import net.andrewcpu.elevenlabs.model.voice.Voice;
|
||||
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||
|
||||
public abstract class AbstractSpeechGenerationBuilder<T, F> {
|
||||
private String voiceId;
|
||||
private VoiceSettings voiceSettings;
|
||||
private String modelId = ElevenLabs.getDefaultModel();
|
||||
private StreamLatencyOptimization latencyOptimization = StreamLatencyOptimization.getDefault();
|
||||
private GeneratedAudioOutputFormat generatedAudioOutputFormat = GeneratedAudioOutputFormat.getDefault();
|
||||
public abstract T self();
|
||||
|
||||
public abstract F build();
|
||||
|
||||
|
||||
public GeneratedAudioOutputFormat getGeneratedAudioOutputFormat() {
|
||||
return generatedAudioOutputFormat;
|
||||
}
|
||||
|
||||
public T setGeneratedAudioOutputFormat(GeneratedAudioOutputFormat generatedAudioOutputFormat) {
|
||||
this.generatedAudioOutputFormat = generatedAudioOutputFormat;
|
||||
return self();
|
||||
}
|
||||
|
||||
public String getVoiceId() {
|
||||
return voiceId;
|
||||
}
|
||||
|
||||
public T setVoiceId(String voiceId) {
|
||||
this.voiceId = voiceId;
|
||||
return self();
|
||||
}
|
||||
|
||||
public VoiceSettings getVoiceSettings() {
|
||||
return voiceSettings;
|
||||
}
|
||||
|
||||
public T setVoiceSettings(VoiceSettings voiceSettings) {
|
||||
this.voiceSettings = voiceSettings;
|
||||
return self();
|
||||
}
|
||||
|
||||
public String getModelId() {
|
||||
return modelId;
|
||||
}
|
||||
|
||||
public T setModelId(String modelId) {
|
||||
this.modelId = modelId;
|
||||
return self();
|
||||
}
|
||||
|
||||
public StreamLatencyOptimization getLatencyOptimization() {
|
||||
return latencyOptimization;
|
||||
}
|
||||
|
||||
public T setLatencyOptimization(StreamLatencyOptimization latencyOptimization) {
|
||||
this.latencyOptimization = latencyOptimization;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setVoice(Voice voice) {
|
||||
this.voiceId = voice.getVoiceId();
|
||||
if(voice.getSettings() == null) voice.fetchSettings();
|
||||
this.voiceSettings = voice.getSettings();
|
||||
return self();
|
||||
}
|
||||
|
||||
public T setModel(ElevenLabsVoiceModel voiceModel) {
|
||||
this.modelId = voiceModel.getModelId();
|
||||
return self();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.andrewcpu.elevenlabs.builders.impl.s2s;
|
||||
|
||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.builders.abstracts.AbstractSpeechGenerationBuilder;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class SpeechToSpeechFileBuilder extends AbstractSpeechGenerationBuilder<SpeechToSpeechFileBuilder, File> {
|
||||
private File inputFile;
|
||||
|
||||
public File getInputFile() {
|
||||
return inputFile;
|
||||
}
|
||||
|
||||
public SpeechToSpeechFileBuilder setInputFile(File inputFile) {
|
||||
this.inputFile = inputFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpeechToSpeechFileBuilder self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File build() {
|
||||
return ElevenLabs
|
||||
.getSpeechToSpeechAPI()
|
||||
.generateSpeechToSpeech(getVoiceId(), getVoiceSettings(),getModelId(),getInputFile(),getLatencyOptimization());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.andrewcpu.elevenlabs.builders.impl.s2s;
|
||||
|
||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.builders.abstracts.AbstractSpeechGenerationBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class SpeechToSpeechStreamedBuilder extends AbstractSpeechGenerationBuilder<SpeechToSpeechStreamedBuilder, InputStream> {
|
||||
private File inputFile;
|
||||
|
||||
public File getInputFile() {
|
||||
return inputFile;
|
||||
}
|
||||
|
||||
public SpeechToSpeechStreamedBuilder setInputFile(File inputFile) {
|
||||
this.inputFile = inputFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpeechToSpeechStreamedBuilder self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream build() {
|
||||
return ElevenLabs
|
||||
.getSpeechToSpeechAPI()
|
||||
.generateSpeechToSpeechStream(getVoiceId(), getVoiceSettings(),getModelId(),getInputFile(),getLatencyOptimization());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.andrewcpu.elevenlabs.builders.impl.tts;
|
||||
|
||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.builders.abstracts.AbstractSpeechGenerationBuilder;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class TextToSpeechFileBuilder extends AbstractSpeechGenerationBuilder<TextToSpeechFileBuilder, File> {
|
||||
private String text;
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public TextToSpeechFileBuilder setText(String text) {
|
||||
this.text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextToSpeechFileBuilder self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File build() {
|
||||
return ElevenLabs
|
||||
.getTextToSpeechAPI()
|
||||
.generateTextToSpeech(getVoiceId(), getText(),getModelId(), getGeneratedAudioOutputFormat(),getLatencyOptimization(), getVoiceSettings());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.andrewcpu.elevenlabs.builders.impl.tts;
|
||||
|
||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.builders.abstracts.AbstractSpeechGenerationBuilder;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class TextToSpeechStreamedBuilder extends AbstractSpeechGenerationBuilder<TextToSpeechStreamedBuilder, InputStream> {
|
||||
private String text;
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public TextToSpeechStreamedBuilder setText(String text) {
|
||||
this.text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextToSpeechStreamedBuilder self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream build() {
|
||||
return ElevenLabs
|
||||
.getTextToSpeechAPI()
|
||||
.generateTextToSpeechStreamed(getVoiceId(), getText(),getModelId(), getGeneratedAudioOutputFormat(),getLatencyOptimization(), getVoiceSettings());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.andrewcpu.elevenlabs.enums;
|
||||
|
||||
public enum ElevenLabsVoiceModel {
|
||||
ELEVEN_MULTILINGUAL_V2("eleven_multilingual_v2", "Eleven Multilingual v2"),
|
||||
ELEVEN_ENGLISH_V2("eleven_english_v2", "Eleven English v2"),
|
||||
ELEVEN_MULTILINGUAL_V1("eleven_multilingual_v1", "Eleven Multilingual v1"),
|
||||
ELEVEN_MONOLINGUAL_V1("eleven_monolingual_v1", "Eleven English v1"),
|
||||
ELEVEN_TURBO_V2("eleven_turbo_v2", "Eleven Turbo v2"),
|
||||
ELEVEN_ENGLISH_STS_V2("eleven_english_sts_v2", "Eleven English v2", true),
|
||||
;
|
||||
final String modelId;
|
||||
final String modelLabel;
|
||||
final boolean supportsSpeechToSpeech;
|
||||
|
||||
ElevenLabsVoiceModel(String modelId, String modelLabel, boolean supportsSpeechToSpeech) {
|
||||
this.modelId = modelId;
|
||||
this.modelLabel = modelLabel;
|
||||
this.supportsSpeechToSpeech = supportsSpeechToSpeech;
|
||||
}
|
||||
|
||||
ElevenLabsVoiceModel(String modelId, String modelLabel) {
|
||||
this(modelId, modelLabel, false);
|
||||
}
|
||||
|
||||
public String getModelId() {
|
||||
return modelId;
|
||||
}
|
||||
|
||||
public String getModelLabel() {
|
||||
return modelLabel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.andrewcpu.elevenlabs.enums;
|
||||
|
||||
public enum GeneratedAudioOutputFormat {
|
||||
MP3_44100_64,
|
||||
MP3_44100_96,
|
||||
MP3_44100_128,
|
||||
MP3_44100_192,
|
||||
PCM_16000,
|
||||
PCM_22050,
|
||||
PCM_24000,
|
||||
PCM_44100,
|
||||
ULAW_8000;
|
||||
|
||||
|
||||
// Method to get the default value
|
||||
public static GeneratedAudioOutputFormat getDefault() {
|
||||
return MP3_44100_128;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package net.andrewcpu.elevenlabs.enums;
|
||||
|
||||
public enum HttpRequestType {
|
||||
POST, GET, PUT, DELETE;
|
||||
POST, GET, PUT, DELETE
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.andrewcpu.elevenlabs.enums;
|
||||
|
||||
public enum ProjectOutputQuality {
|
||||
STANDARD,
|
||||
HIGH,
|
||||
ULTRA;
|
||||
|
||||
public static ProjectOutputQuality getDefault() {
|
||||
return STANDARD;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.andrewcpu.elevenlabs.enums;
|
||||
|
||||
public enum StreamLatencyOptimization {
|
||||
//0 - default mode (no latency optimizations)
|
||||
NONE(0),
|
||||
//1 - normal latency optimizations (about 50% of possible latency improvement of option 3)
|
||||
NORMAL(1),
|
||||
//2 - strong latency optimizations (about 75% of possible latency improvement of option 3)
|
||||
STRONG(2),
|
||||
// 3 - max latency optimizations
|
||||
MAX_TEXT_NORMALIZATION(3),
|
||||
// 3 - max latency optimizations with text normalizer turned off
|
||||
MAX_NO_TEXT_NORMALIZATION(4);
|
||||
private final int value;
|
||||
|
||||
StreamLatencyOptimization(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static StreamLatencyOptimization getDefault() {
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,25 @@ import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class History extends ElevenModel {
|
||||
|
||||
public static final int DEFAULT_HISTORY_PAGE_SIZE = 100;
|
||||
public static History get() {
|
||||
return ElevenLabs.getHistory();
|
||||
return ElevenLabs.getHistoryAPI().getHistory();
|
||||
}
|
||||
public static History get(String afterHistoryId) {
|
||||
return ElevenLabs.getHistoryAPI().getHistory(afterHistoryId);
|
||||
}
|
||||
public static History get(int pageSize, String afterHistoryId) {
|
||||
return ElevenLabs.getHistoryAPI().getHistory(pageSize, afterHistoryId);
|
||||
}
|
||||
|
||||
public static History get(int pageSize) {
|
||||
return ElevenLabs.getHistoryAPI().getHistory(pageSize, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@JsonProperty("history")
|
||||
private List<HistoryItem> historyItems;
|
||||
@@ -57,11 +70,18 @@ public class History extends ElevenModel {
|
||||
}
|
||||
|
||||
public File downloadHistory(String... historyIds) {
|
||||
return ElevenLabs.getHistoryItemAudio(historyIds);
|
||||
return ElevenLabs.getHistoryAPI().getHistoryItemAudio(historyIds);
|
||||
}
|
||||
|
||||
public File downloadHistory(HistoryItem... items) {
|
||||
return ElevenLabs.getHistoryItemAudio(Arrays.stream(items).map(HistoryItem::getHistoryItemId).toArray(String[]::new));
|
||||
return ElevenLabs.getHistoryAPI().getHistoryItemAudio(Arrays.stream(items).map(HistoryItem::getHistoryItemId).toArray(String[]::new));
|
||||
}
|
||||
|
||||
public Optional<History> next(int pageSize) {
|
||||
if(!hasMore) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(ElevenLabs.getHistoryAPI().getHistory(pageSize, lastHistoryItemId));
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
import net.andrewcpu.elevenlabs.util.ElevenNetworkUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
@@ -124,11 +125,15 @@ public class HistoryItem extends ElevenModel {
|
||||
}
|
||||
|
||||
public String delete() {
|
||||
return ElevenLabs.deleteHistoryItem(historyItemId);
|
||||
return ElevenLabs.getHistoryAPI().deleteHistoryItem(historyItemId);
|
||||
}
|
||||
|
||||
public File downloadAudio() {
|
||||
return ElevenLabs.getHistoryItemAudio(historyItemId);
|
||||
return ElevenLabs.getHistoryAPI().getHistoryItemAudio(historyItemId);
|
||||
}
|
||||
|
||||
public String getDownloadUrl() {
|
||||
return ElevenNetworkUtil.getHistoryItemUrl(historyItemId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package net.andrewcpu.elevenlabs.model.projects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Chapter extends ElevenModel {
|
||||
|
||||
public String deleteChapter(String projectId) {
|
||||
return ElevenLabs.getProjectsAPI().deleteChapter(projectId, chapterId);
|
||||
}
|
||||
|
||||
public String convertChapter(String projectId) {
|
||||
return ElevenLabs.getProjectsAPI().convertChapter(projectId, chapterId);
|
||||
}
|
||||
|
||||
public List<ChapterSnapshot> getChapterSnapshots(String projectId) {
|
||||
return ElevenLabs.getProjectsAPI().getChapterSnapshots(projectId, chapterId);
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty("chapter_id")
|
||||
private String chapterId;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("last_conversion_date_unix")
|
||||
private long lastConversionDateUnix;
|
||||
|
||||
@JsonProperty("conversion_progress")
|
||||
private double conversionProgress;
|
||||
|
||||
@JsonProperty("can_be_downloaded")
|
||||
private boolean canBeDownloaded;
|
||||
|
||||
@JsonProperty("state")
|
||||
private String state;
|
||||
|
||||
@JsonProperty("statistics")
|
||||
private Statistics statistics;
|
||||
|
||||
public Chapter() {
|
||||
}
|
||||
|
||||
public Chapter(String chapterId, String name, long lastConversionDateUnix, double conversionProgress, boolean canBeDownloaded, String state, Statistics statistics) {
|
||||
this.chapterId = chapterId;
|
||||
this.name = name;
|
||||
this.lastConversionDateUnix = lastConversionDateUnix;
|
||||
this.conversionProgress = conversionProgress;
|
||||
this.canBeDownloaded = canBeDownloaded;
|
||||
this.state = state;
|
||||
this.statistics = statistics;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getChapterId() {
|
||||
return chapterId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getLastConversionDateUnix() {
|
||||
return lastConversionDateUnix;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public double getConversionProgress() {
|
||||
return conversionProgress;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isCanBeDownloaded() {
|
||||
return canBeDownloaded;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Statistics getStatistics() {
|
||||
return statistics;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "Chapter{" +
|
||||
"chapterId='" + chapterId + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", lastConversionDateUnix=" + lastConversionDateUnix +
|
||||
", conversionProgress=" + conversionProgress +
|
||||
", canBeDownloaded=" + canBeDownloaded +
|
||||
", state='" + state + '\'' +
|
||||
", statistics=" + statistics +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package net.andrewcpu.elevenlabs.model.projects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ChapterSnapshot extends Snapshot {
|
||||
|
||||
@Override
|
||||
public InputStream getAudioStream() {
|
||||
return ElevenLabs.getProjectsAPI().getChapterSnapshotAudioStream(projectId, chapterId, chapterSnapshotId);
|
||||
}
|
||||
|
||||
public ChapterSnapshot() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ChapterSnapshot(String chapterSnapshotId, String projectId, String chapterId, long createdAtUnix, String name) {
|
||||
super(projectId, createdAtUnix, name);
|
||||
this.chapterSnapshotId = chapterSnapshotId;
|
||||
this.chapterId = chapterId;
|
||||
}
|
||||
|
||||
@JsonProperty("chapter_snapshot_id")
|
||||
private String chapterSnapshotId;
|
||||
|
||||
@JsonProperty("chapter_id")
|
||||
private String chapterId;
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public String getChapterSnapshotId() {
|
||||
return chapterSnapshotId;
|
||||
}
|
||||
@JsonIgnore
|
||||
public String getChapterId() {
|
||||
return chapterId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "ChapterSnapshot{" +
|
||||
"chapterSnapshotId='" + chapterSnapshotId + '\'' +
|
||||
", projectId='" + projectId + '\'' +
|
||||
", chapterId='" + chapterId + '\'' +
|
||||
", createdAtUnix=" + createdAtUnix +
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package net.andrewcpu.elevenlabs.model.projects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
import net.andrewcpu.elevenlabs.model.request.AddProjectRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Project extends ElevenModel {
|
||||
|
||||
public static List<Project> getProjects() {
|
||||
return ElevenLabs.getProjectsAPI().getProjects();
|
||||
}
|
||||
|
||||
public static Project addProject(AddProjectRequest builder) {
|
||||
return ElevenLabs.getProjectsAPI().addProject(builder);
|
||||
}
|
||||
|
||||
public static Project getProjectById(String projectId) {
|
||||
return ElevenLabs.getProjectsAPI().getProject(projectId);
|
||||
}
|
||||
|
||||
public List<Chapter> fetchUpdatedChapters() {
|
||||
this.chapters = ElevenLabs.getProjectsAPI().getChapters(projectId);
|
||||
return this.chapters;
|
||||
}
|
||||
|
||||
public String deleteChapter(Chapter chapter) {
|
||||
return chapter.deleteChapter(projectId);
|
||||
}
|
||||
|
||||
public String convertChapter(Chapter chapter) {
|
||||
return chapter.convertChapter(projectId);
|
||||
}
|
||||
|
||||
public List<ChapterSnapshot> getChapterSnapshots(Chapter chapter) {
|
||||
return chapter.getChapterSnapshots(projectId);
|
||||
}
|
||||
|
||||
public String deleteProject() {
|
||||
return ElevenLabs.getProjectsAPI().deleteProject(projectId);
|
||||
}
|
||||
|
||||
public String convertProject() {
|
||||
return ElevenLabs.getProjectsAPI().convertProject(projectId);
|
||||
}
|
||||
|
||||
public List<ProjectSnapshot> getSnapshots() {
|
||||
return ElevenLabs.getProjectsAPI().getProjectSnapshots(projectId);
|
||||
}
|
||||
|
||||
public Chapter getChapterById(String chapterId) {
|
||||
return ElevenLabs.getProjectsAPI().getChapterById(projectId, chapterId);
|
||||
}
|
||||
|
||||
public Project(String projectId, String name, long unixCreateDate, String defaultTitleVoiceId, String defaultParagraphVoiceId, String defaultModelId, long lastConversionDateUnix, boolean canBeDownloaded, String state, List<Chapter> chapters) {
|
||||
this.projectId = projectId;
|
||||
this.name = name;
|
||||
this.unixCreateDate = unixCreateDate;
|
||||
this.defaultTitleVoiceId = defaultTitleVoiceId;
|
||||
this.defaultParagraphVoiceId = defaultParagraphVoiceId;
|
||||
this.defaultModelId = defaultModelId;
|
||||
this.lastConversionDateUnix = lastConversionDateUnix;
|
||||
this.canBeDownloaded = canBeDownloaded;
|
||||
this.state = state;
|
||||
this.chapters = chapters;
|
||||
}
|
||||
|
||||
public Project() {
|
||||
}
|
||||
|
||||
@JsonProperty("project_id")
|
||||
private String projectId;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("create_date_unix")
|
||||
private long unixCreateDate;
|
||||
|
||||
@JsonProperty("default_title_voice_id")
|
||||
private String defaultTitleVoiceId;
|
||||
|
||||
@JsonProperty("default_paragraph_voice_id")
|
||||
private String defaultParagraphVoiceId;
|
||||
|
||||
@JsonProperty("default_model_id")
|
||||
private String defaultModelId;
|
||||
|
||||
@JsonProperty("last_conversion_date_unix")
|
||||
private long lastConversionDateUnix;
|
||||
|
||||
@JsonProperty("can_be_downloaded")
|
||||
private boolean canBeDownloaded;
|
||||
|
||||
@JsonProperty("state")
|
||||
private String state;
|
||||
|
||||
@JsonProperty("chapters")
|
||||
private List<Chapter> chapters;
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public String getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getUnixCreateDate() {
|
||||
return unixCreateDate;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDefaultTitleVoiceId() {
|
||||
return defaultTitleVoiceId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDefaultParagraphVoiceId() {
|
||||
return defaultParagraphVoiceId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDefaultModelId() {
|
||||
return defaultModelId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getLastConversionDateUnix() {
|
||||
return lastConversionDateUnix;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isCanBeDownloaded() {
|
||||
return canBeDownloaded;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public List<Chapter> getChapters() {
|
||||
return chapters;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "Project{" +
|
||||
"projectId='" + projectId + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", unixCreateDate=" + unixCreateDate +
|
||||
", defaultTitleVoiceId='" + defaultTitleVoiceId + '\'' +
|
||||
", defaultParagraphVoiceId='" + defaultParagraphVoiceId + '\'' +
|
||||
", defaultModelId='" + defaultModelId + '\'' +
|
||||
", lastConversionDateUnix=" + lastConversionDateUnix +
|
||||
", canBeDownloaded=" + canBeDownloaded +
|
||||
", state='" + state + '\'' +
|
||||
", chapters=" + chapters +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package net.andrewcpu.elevenlabs.model.projects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ProjectSnapshot extends Snapshot {
|
||||
|
||||
@Override
|
||||
public InputStream getAudioStream() {
|
||||
return ElevenLabs.getProjectsAPI().getProjectSnapshotAudioStream(projectId, projectSnapshotId);
|
||||
}
|
||||
|
||||
public ProjectSnapshot() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ProjectSnapshot(String projectSnapshotId, String projectId, long createdAtUnix, String name) {
|
||||
super(projectId, createdAtUnix, name);
|
||||
this.projectSnapshotId = projectSnapshotId;
|
||||
}
|
||||
|
||||
@JsonProperty("project_snapshot_id")
|
||||
private String projectSnapshotId;
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public String getProjectSnapshotId() {
|
||||
return projectSnapshotId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProjectSnapshot{" +
|
||||
"projectSnapshotId='" + projectSnapshotId + '\'' +
|
||||
", projectId='" + projectId + '\'' +
|
||||
", createdAtUnix=" + createdAtUnix +
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package net.andrewcpu.elevenlabs.model.projects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public abstract class Snapshot extends ElevenModel {
|
||||
@JsonProperty("project_id")
|
||||
protected String projectId;
|
||||
|
||||
@JsonProperty("created_at_unix")
|
||||
protected long createdAtUnix;
|
||||
|
||||
@JsonProperty("name")
|
||||
protected String name;
|
||||
|
||||
public Snapshot(String projectId, long createdAtUnix, String name) {
|
||||
this.projectId = projectId;
|
||||
this.createdAtUnix = createdAtUnix;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Snapshot() {
|
||||
}
|
||||
|
||||
public abstract InputStream getAudioStream();
|
||||
|
||||
@JsonIgnore
|
||||
public String getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public long getCreatedAtUnix() {
|
||||
return createdAtUnix;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "Snapshot{" +
|
||||
"projectId='" + projectId + '\'' +
|
||||
", createdAtUnix=" + createdAtUnix +
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.andrewcpu.elevenlabs.model.projects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
|
||||
public class Statistics extends ElevenModel {
|
||||
@JsonProperty("characters_unconverted")
|
||||
private int charactersUnconverted;
|
||||
|
||||
@JsonProperty("characters_converted")
|
||||
private int charactersConverted;
|
||||
|
||||
@JsonProperty("paragraphs_converted")
|
||||
private int paragraphsConverted;
|
||||
|
||||
@JsonProperty("paragraphs_unconverted")
|
||||
private int paragraphsUnconverted;
|
||||
|
||||
|
||||
public Statistics(int charactersUnconverted, int charactersConverted, int paragraphsConverted, int paragraphsUnconverted) {
|
||||
this.charactersUnconverted = charactersUnconverted;
|
||||
this.charactersConverted = charactersConverted;
|
||||
this.paragraphsConverted = paragraphsConverted;
|
||||
this.paragraphsUnconverted = paragraphsUnconverted;
|
||||
}
|
||||
|
||||
public Statistics() {
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public int getCharactersUnconverted() {
|
||||
return charactersUnconverted;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public int getCharactersConverted() {
|
||||
return charactersConverted;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public int getParagraphsConverted() {
|
||||
return paragraphsConverted;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public int getParagraphsUnconverted() {
|
||||
return paragraphsUnconverted;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "Statistics{" +
|
||||
"charactersUnconverted=" + charactersUnconverted +
|
||||
", charactersConverted=" + charactersConverted +
|
||||
", paragraphsConverted=" + paragraphsConverted +
|
||||
", paragraphsUnconverted=" + paragraphsUnconverted +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package net.andrewcpu.elevenlabs.model.request;
|
||||
|
||||
import net.andrewcpu.elevenlabs.enums.ProjectOutputQuality;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class AddProjectRequest {
|
||||
private String name;
|
||||
private String fromUrl;
|
||||
private File fromDocument;
|
||||
private String defaultTitleVoiceId;
|
||||
private String defaultParagraphVoiceId;
|
||||
private String defaultModelId;
|
||||
private ProjectOutputQuality projectOutputQuality;
|
||||
private String title;
|
||||
private String author;
|
||||
private String isbnNumber;
|
||||
private boolean acxVolumeNormalization;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public AddProjectRequest setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFromUrl() {
|
||||
return fromUrl;
|
||||
}
|
||||
|
||||
public AddProjectRequest setFromUrl(String fromUrl) {
|
||||
this.fromUrl = fromUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public File getFromDocument() {
|
||||
return fromDocument;
|
||||
}
|
||||
|
||||
public AddProjectRequest setFromDocument(File fromDocument) {
|
||||
this.fromDocument = fromDocument;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDefaultTitleVoiceId() {
|
||||
return defaultTitleVoiceId;
|
||||
}
|
||||
|
||||
public AddProjectRequest setDefaultTitleVoiceId(String defaultTitleVoiceId) {
|
||||
this.defaultTitleVoiceId = defaultTitleVoiceId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDefaultParagraphVoiceId() {
|
||||
return defaultParagraphVoiceId;
|
||||
}
|
||||
|
||||
public AddProjectRequest setDefaultParagraphVoiceId(String defaultParagraphVoiceId) {
|
||||
this.defaultParagraphVoiceId = defaultParagraphVoiceId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDefaultModelId() {
|
||||
return defaultModelId;
|
||||
}
|
||||
|
||||
public AddProjectRequest setDefaultModelId(String defaultModelId) {
|
||||
this.defaultModelId = defaultModelId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectOutputQuality getProjectOutputQuality() {
|
||||
return projectOutputQuality;
|
||||
}
|
||||
|
||||
public AddProjectRequest setProjectOutputQuality(ProjectOutputQuality projectOutputQuality) {
|
||||
this.projectOutputQuality = projectOutputQuality;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public AddProjectRequest setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public AddProjectRequest setAuthor(String author) {
|
||||
this.author = author;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getIsbnNumber() {
|
||||
return isbnNumber;
|
||||
}
|
||||
|
||||
public AddProjectRequest setIsbnNumber(String isbnNumber) {
|
||||
this.isbnNumber = isbnNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAcxVolumeNormalization() {
|
||||
return acxVolumeNormalization;
|
||||
}
|
||||
|
||||
public AddProjectRequest setAcxVolumeNormalization(boolean acxVolumeNormalization) {
|
||||
this.acxVolumeNormalization = acxVolumeNormalization;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package net.andrewcpu.elevenlabs.model.request;
|
||||
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CreateAudioNativeProjectRequest extends ElevenModel {
|
||||
private String name;
|
||||
private String image;
|
||||
private String author;
|
||||
private boolean small;
|
||||
private String textColor;
|
||||
private String backgroundColor;
|
||||
private Integer sessionization;
|
||||
private String voiceId;
|
||||
private String modelId;
|
||||
private File file;
|
||||
private boolean autoConvert;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public CreateAudioNativeProjectRequest setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public CreateAudioNativeProjectRequest setImage(String image) {
|
||||
this.image = image;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public CreateAudioNativeProjectRequest setAuthor(String author) {
|
||||
this.author = author;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSmall() {
|
||||
return small;
|
||||
}
|
||||
|
||||
public CreateAudioNativeProjectRequest setSmall(boolean small) {
|
||||
this.small = small;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTextColor() {
|
||||
return textColor;
|
||||
}
|
||||
|
||||
public CreateAudioNativeProjectRequest setTextColor(String textColor) {
|
||||
this.textColor = textColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public CreateAudioNativeProjectRequest setBackgroundColor(String backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getSessionization() {
|
||||
return sessionization;
|
||||
}
|
||||
|
||||
public CreateAudioNativeProjectRequest setSessionization(Integer sessionization) {
|
||||
this.sessionization = sessionization;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getVoiceId() {
|
||||
return voiceId;
|
||||
}
|
||||
|
||||
public CreateAudioNativeProjectRequest setVoiceId(String voiceId) {
|
||||
this.voiceId = voiceId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getModelId() {
|
||||
return modelId;
|
||||
}
|
||||
|
||||
public CreateAudioNativeProjectRequest setModelId(String modelId) {
|
||||
this.modelId = modelId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public CreateAudioNativeProjectRequest setFile(File file) {
|
||||
this.file = file;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAutoConvert() {
|
||||
return autoConvert;
|
||||
}
|
||||
|
||||
public CreateAudioNativeProjectRequest setAutoConvert(boolean autoConvert) {
|
||||
this.autoConvert = autoConvert;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.andrewcpu.elevenlabs.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
import net.andrewcpu.elevenlabs.model.projects.ChapterSnapshot;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ChapterSnapshotsModelResponse extends ElevenModel {
|
||||
|
||||
public ChapterSnapshotsModelResponse(List<ChapterSnapshot> snapshots) {
|
||||
this.snapshots = snapshots;
|
||||
}
|
||||
|
||||
public ChapterSnapshotsModelResponse() {
|
||||
}
|
||||
|
||||
@JsonProperty("snapshots")
|
||||
private List<ChapterSnapshot> snapshots;
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public List<ChapterSnapshot> getSnapshots() {
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "ChapterSnapshotsModelResponse{" +
|
||||
"snapshots=" + snapshots +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.andrewcpu.elevenlabs.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
import net.andrewcpu.elevenlabs.model.projects.Chapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ChaptersModelResponse extends ElevenModel {
|
||||
@JsonProperty("chapters")
|
||||
private List<Chapter> chapters;
|
||||
|
||||
public ChaptersModelResponse(List<Chapter> chapters) {
|
||||
this.chapters = chapters;
|
||||
}
|
||||
|
||||
public ChaptersModelResponse() {
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public List<Chapter> getChapters() {
|
||||
return chapters;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "ChaptersModelResponse{" +
|
||||
"chapters=" + chapters +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.andrewcpu.elevenlabs.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
|
||||
public class CreateAudioEnabledProjectModelResponse extends ElevenModel {
|
||||
@JsonProperty("project_id")
|
||||
private String projectId;
|
||||
|
||||
@JsonProperty("converting")
|
||||
private boolean converting;
|
||||
|
||||
@JsonProperty("html_snippet")
|
||||
private String htmlSnippet;
|
||||
|
||||
public CreateAudioEnabledProjectModelResponse(String projectId, boolean converting, String htmlSnippet) {
|
||||
this.projectId = projectId;
|
||||
this.converting = converting;
|
||||
this.htmlSnippet = htmlSnippet;
|
||||
}
|
||||
|
||||
public CreateAudioEnabledProjectModelResponse() {
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isConverting() {
|
||||
return converting;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getHtmlSnippet() {
|
||||
return htmlSnippet;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "CreateAudioEnabledProjectModelResponse{" +
|
||||
"projectId='" + projectId + '\'' +
|
||||
", converting=" + converting +
|
||||
", htmlSnippet='" + htmlSnippet + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.andrewcpu.elevenlabs.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
import net.andrewcpu.elevenlabs.model.Language;
|
||||
@@ -24,23 +23,46 @@ public class GenerationTypeModel extends ElevenModel {
|
||||
@JsonProperty("can_do_voice_conversion")
|
||||
private boolean canDoVoiceConversion;
|
||||
|
||||
@JsonProperty("can_use_style")
|
||||
private boolean canUseStyle;
|
||||
|
||||
@JsonProperty("can_use_speaker_boost")
|
||||
private boolean canUseSpeakerBoost;
|
||||
|
||||
@JsonProperty("serves_pro_voices")
|
||||
private boolean servesProVoices;
|
||||
|
||||
@JsonProperty("token_cost_factor")
|
||||
private int tokenCostFactor;
|
||||
|
||||
@JsonProperty("description")
|
||||
private String description;
|
||||
|
||||
@JsonProperty("requires_alpha_access")
|
||||
private boolean requiresAlphaAccess;
|
||||
|
||||
@JsonProperty("max_characters_request_free_user")
|
||||
private int maxCharactersRequestFreeUser;
|
||||
@JsonProperty("max_characters_request_subscribed_user")
|
||||
private int maxCharactersRequestSubscribedUser;
|
||||
|
||||
@JsonProperty("languages")
|
||||
private List<Language> languages;
|
||||
|
||||
public GenerationTypeModel(String modelId, String name, boolean canBeFinetuned, boolean canDoTextToSpeech, boolean canDoVoiceConversion, int tokenCostFactor, String description, List<Language> languages) {
|
||||
public GenerationTypeModel(String modelId, String name, boolean canBeFinetuned, boolean canDoTextToSpeech, boolean canDoVoiceConversion, boolean canUseStyle, boolean canUseSpeakerBoost, boolean servesProVoices, int tokenCostFactor, String description, boolean requiresAlphaAccess, int maxCharactersRequestFreeUser, int maxCharactersRequestSubscribedUser, List<Language> languages) {
|
||||
this.modelId = modelId;
|
||||
this.name = name;
|
||||
this.canBeFinetuned = canBeFinetuned;
|
||||
this.canDoTextToSpeech = canDoTextToSpeech;
|
||||
this.canDoVoiceConversion = canDoVoiceConversion;
|
||||
this.canUseStyle = canUseStyle;
|
||||
this.canUseSpeakerBoost = canUseSpeakerBoost;
|
||||
this.servesProVoices = servesProVoices;
|
||||
this.tokenCostFactor = tokenCostFactor;
|
||||
this.description = description;
|
||||
this.requiresAlphaAccess = requiresAlphaAccess;
|
||||
this.maxCharactersRequestFreeUser = maxCharactersRequestFreeUser;
|
||||
this.maxCharactersRequestSubscribedUser = maxCharactersRequestSubscribedUser;
|
||||
this.languages = languages;
|
||||
}
|
||||
|
||||
@@ -87,17 +109,54 @@ public class GenerationTypeModel extends ElevenModel {
|
||||
return languages;
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isCanUseStyle() {
|
||||
return canUseStyle;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isCanUseSpeakerBoost() {
|
||||
return canUseSpeakerBoost;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isServesProVoices() {
|
||||
return servesProVoices;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isRequiresAlphaAccess() {
|
||||
return requiresAlphaAccess;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public int getMaxCharactersRequestFreeUser() {
|
||||
return maxCharactersRequestFreeUser;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public int getMaxCharactersRequestSubscribedUser() {
|
||||
return maxCharactersRequestSubscribedUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "ModelResponse{" +
|
||||
return "GenerationTypeModel{" +
|
||||
"modelId='" + modelId + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", canBeFinetuned=" + canBeFinetuned +
|
||||
", canDoTextToSpeech=" + canDoTextToSpeech +
|
||||
", canDoVoiceConversion=" + canDoVoiceConversion +
|
||||
", canUseStyle=" + canUseStyle +
|
||||
", canUseSpeakerBoost=" + canUseSpeakerBoost +
|
||||
", servesProVoices=" + servesProVoices +
|
||||
", tokenCostFactor=" + tokenCostFactor +
|
||||
", description='" + description + '\'' +
|
||||
", requiresAlphaAccess=" + requiresAlphaAccess +
|
||||
", maxCharactersRequestFreeUser=" + maxCharactersRequestFreeUser +
|
||||
", maxCharactersRequestSubscribedUser=" + maxCharactersRequestSubscribedUser +
|
||||
", languages=" + languages +
|
||||
'}';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.andrewcpu.elevenlabs.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
import net.andrewcpu.elevenlabs.model.projects.Project;
|
||||
|
||||
public class ProjectModelResponse extends ElevenModel {
|
||||
@JsonProperty("project")
|
||||
private Project project;
|
||||
|
||||
public ProjectModelResponse(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public ProjectModelResponse() {
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "ProjectModelResponse{" +
|
||||
"project=" + project +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.andrewcpu.elevenlabs.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
import net.andrewcpu.elevenlabs.model.projects.ProjectSnapshot;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectSnapshotsModelResponse extends ElevenModel {
|
||||
@JsonProperty("snapshots")
|
||||
private List<ProjectSnapshot> projectSnapshots;
|
||||
|
||||
|
||||
public ProjectSnapshotsModelResponse(List<ProjectSnapshot> projectSnapshots) {
|
||||
this.projectSnapshots = projectSnapshots;
|
||||
}
|
||||
|
||||
public ProjectSnapshotsModelResponse() {
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public List<ProjectSnapshot> getSnapshots() {
|
||||
return projectSnapshots;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "ProjectSnapshotsModelResponse{" +
|
||||
"snapshots=" + projectSnapshots +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.andrewcpu.elevenlabs.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
import net.andrewcpu.elevenlabs.model.projects.Project;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectsModelResponse extends ElevenModel {
|
||||
@JsonProperty("projects")
|
||||
private List<Project> projects;
|
||||
|
||||
public ProjectsModelResponse(List<Project> projects) {
|
||||
this.projects = projects;
|
||||
}
|
||||
|
||||
public ProjectsModelResponse() {
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public List<Project> getProjects() {
|
||||
return projects;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "ProjectsModelResponse{" +
|
||||
"projects=" + projects +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.andrewcpu.elevenlabs.model.tuning;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
public class Subscription extends ElevenModel {
|
||||
@JsonIgnore
|
||||
public static Subscription get() {
|
||||
return ElevenLabs.getSubscription();
|
||||
return ElevenLabs.getUserAPI().getSubscription();
|
||||
}
|
||||
|
||||
@JsonProperty("tier")
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
public class User extends ElevenModel {
|
||||
|
||||
public static User get() {
|
||||
return ElevenLabs.getUser();
|
||||
return ElevenLabs.getUserAPI().getUser();
|
||||
}
|
||||
|
||||
@JsonProperty("subscription")
|
||||
|
||||
@@ -63,14 +63,14 @@ public class Sample extends ElevenModel {
|
||||
}
|
||||
|
||||
public File downloadAudio() {
|
||||
return ElevenLabs.getAudioSample(voice.getVoiceId(), sampleId);
|
||||
return ElevenLabs.getSampleAPI().getAudioSample(voice.getVoiceId(), sampleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning! This will delete the sample.
|
||||
*/
|
||||
public String delete() {
|
||||
return ElevenLabs.deleteSample(voice.getVoiceId(), sampleId);
|
||||
return ElevenLabs.getSampleAPI().deleteSample(voice.getVoiceId(), sampleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,8 @@ package net.andrewcpu.elevenlabs.model.voice;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.enums.GeneratedAudioOutputFormat;
|
||||
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
import net.andrewcpu.elevenlabs.model.tuning.FineTuning;
|
||||
|
||||
@@ -14,15 +16,15 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Voice extends ElevenModel {
|
||||
public static List<Voice> getVoices() {
|
||||
return ElevenLabs.getVoices();
|
||||
return ElevenLabs.getVoiceAPI().getVoices();
|
||||
}
|
||||
|
||||
public static Voice getVoice(String voiceId) {
|
||||
return ElevenLabs.getVoice(voiceId);
|
||||
return ElevenLabs.getVoiceAPI().getVoice(voiceId);
|
||||
}
|
||||
|
||||
public static Voice getVoice(String voiceId, boolean withSettings) {
|
||||
return ElevenLabs.getVoice(voiceId, withSettings);
|
||||
return ElevenLabs.getVoiceAPI().getVoice(voiceId, withSettings);
|
||||
}
|
||||
|
||||
@JsonProperty("voice_id")
|
||||
@@ -58,6 +60,9 @@ public class Voice extends ElevenModel {
|
||||
@JsonProperty("sharing")
|
||||
private Sharing sharing;
|
||||
|
||||
@JsonProperty("high_quality_base_model_ids")
|
||||
private List<String> highQualityBaseModelIds;
|
||||
|
||||
@JsonIgnore
|
||||
public String getVoiceId() {
|
||||
return voiceId;
|
||||
@@ -117,15 +122,15 @@ public class Voice extends ElevenModel {
|
||||
* Warning! This will delete the voice.
|
||||
*/
|
||||
public String delete() {
|
||||
return ElevenLabs.deleteVoice(voiceId);
|
||||
return ElevenLabs.getVoiceAPI().deleteVoice(voiceId);
|
||||
}
|
||||
public VoiceSettings fetchSettings() {
|
||||
this.settings = ElevenLabs.getVoiceSettings(voiceId);
|
||||
this.settings = ElevenLabs.getVoiceAPI().getVoiceSettings(voiceId);
|
||||
return settings;
|
||||
}
|
||||
|
||||
public VoiceSettings updateVoiceSettings(VoiceSettings voiceSettings) {
|
||||
ElevenLabs.editVoiceSettings(voiceId, voiceSettings);
|
||||
ElevenLabs.getVoiceAPI().editVoiceSettings(voiceId, voiceSettings);
|
||||
this.settings = voiceSettings;
|
||||
return settings;
|
||||
}
|
||||
@@ -143,44 +148,125 @@ public class Voice extends ElevenModel {
|
||||
this.sharing = refreshedData.sharing;
|
||||
this.previewUrl = refreshedData.previewUrl;
|
||||
this.category = refreshedData.category;
|
||||
this.highQualityBaseModelIds = refreshedData.highQualityBaseModelIds;
|
||||
return this;
|
||||
}
|
||||
|
||||
public File generate(String text, String model) {
|
||||
return ElevenLabs.generateTextToSpeech(voiceId, text, model, settings);
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, model, settings);
|
||||
}
|
||||
|
||||
public File generate(String text, String model, VoiceSettings settings) {
|
||||
return ElevenLabs.generateTextToSpeech(voiceId, text, model, settings);
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, model, settings);
|
||||
}
|
||||
|
||||
public File generate(String text, String model, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId,text, model, outputFormat,streamLatencyOptimization, settings);
|
||||
}
|
||||
public File generate(String text, String model, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId,text, model, outputFormat,StreamLatencyOptimization.getDefault(), settings);
|
||||
}
|
||||
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), outputFormat,StreamLatencyOptimization.getDefault(), settings);
|
||||
}
|
||||
public File generate(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), GeneratedAudioOutputFormat.getDefault(),streamLatencyOptimization, settings);
|
||||
}
|
||||
|
||||
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), outputFormat,streamLatencyOptimization, settings);
|
||||
}
|
||||
public File generate(String text, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), outputFormat,streamLatencyOptimization, settings);
|
||||
}
|
||||
public File generate(String text, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||
}
|
||||
|
||||
public File generate(String text, VoiceSettings settings) {
|
||||
return ElevenLabs.generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", settings);
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), settings);
|
||||
}
|
||||
|
||||
public File generate(String text) {
|
||||
return ElevenLabs.generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", settings);
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, ElevenLabs.getDefaultModel(), settings);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public InputStream generateStream(String text, String model) {
|
||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, model, settings);
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, model, settings);
|
||||
}
|
||||
|
||||
public InputStream generateStream(String text, String model, VoiceSettings settings) {
|
||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, model, settings);
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, model, settings);
|
||||
}
|
||||
|
||||
public InputStream generateStream(String text, VoiceSettings settings) {
|
||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", settings);
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), settings);
|
||||
}
|
||||
|
||||
public InputStream generateStream(String text) {
|
||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", settings);
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), settings);
|
||||
}
|
||||
|
||||
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, model, generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
||||
}
|
||||
|
||||
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings settings) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, model, generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
||||
}
|
||||
|
||||
public InputStream generateStream(String text, VoiceSettings settings, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
||||
}
|
||||
|
||||
public InputStream generateStream(String text, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
||||
}
|
||||
|
||||
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, model, GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||
}
|
||||
|
||||
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings settings) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, model, GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||
}
|
||||
|
||||
public InputStream generateStream(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||
}
|
||||
|
||||
public InputStream generateStream(String text, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, ElevenLabs.getDefaultModel(), GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||
}
|
||||
|
||||
public File speechToSpeech(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId, VoiceSettings voiceSettings) {
|
||||
return ElevenLabs.getSpeechToSpeechAPI().generateSpeechToSpeech(voiceId, voiceSettings, modelId, audioFile, latencyOptimization);
|
||||
}
|
||||
|
||||
public File speechToSpeech(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId) {
|
||||
return speechToSpeech(audioFile, latencyOptimization, modelId, settings);
|
||||
}
|
||||
|
||||
public File speechToSpeech(File audioFile, String modelId) {
|
||||
return speechToSpeech(audioFile, StreamLatencyOptimization.getDefault(), modelId,settings);
|
||||
}
|
||||
|
||||
public InputStream speechToSpeechStream(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId, VoiceSettings voiceSettings) {
|
||||
return ElevenLabs.getSpeechToSpeechAPI().generateSpeechToSpeechStream(voiceId, voiceSettings,modelId,audioFile,latencyOptimization);
|
||||
}
|
||||
|
||||
public InputStream speechToSpeechStream(File audioFile, StreamLatencyOptimization latencyOptimization, String modelId) {
|
||||
return speechToSpeechStream(audioFile,latencyOptimization,modelId,settings);
|
||||
}
|
||||
|
||||
public InputStream speechToSpeechStream(File audioFile, String modelId) {
|
||||
return speechToSpeechStream(audioFile, StreamLatencyOptimization.getDefault(),modelId);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "Voice{" +
|
||||
"voiceId='" + voiceId + '\'' +
|
||||
@@ -194,6 +280,7 @@ public class Voice extends ElevenModel {
|
||||
", availableForTiers=" + availableForTiers +
|
||||
", settings=" + settings +
|
||||
", sharing=" + sharing +
|
||||
", highQualityBaseModelIds=" + highQualityBaseModelIds +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ public class VoiceBuilder {
|
||||
}
|
||||
|
||||
public Voice create() {
|
||||
CreateVoiceResponse createVoiceResponse = ElevenLabs.createVoice(name, files.toArray(File[]::new), description, labels);
|
||||
CreateVoiceResponse createVoiceResponse = ElevenLabs.getVoiceAPI().createVoice(name, files.toArray(File[]::new), description, labels);
|
||||
return Voice.getVoice(createVoiceResponse.getVoiceId(), true);
|
||||
}
|
||||
|
||||
public Voice edit() {
|
||||
ElevenLabs.editVoice(voice.getVoiceId(), name, files.toArray(File[]::new), description, labels);
|
||||
ElevenLabs.getVoiceAPI().editVoice(voice.getVoiceId(), name, files.toArray(File[]::new), description, labels);
|
||||
voice = voice.refresh();
|
||||
return voice;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||
|
||||
public class VoiceSettings extends ElevenModel {
|
||||
public static VoiceSettings getDefaultVoiceSettings() {
|
||||
return ElevenLabs.getDefaultVoiceSettings();
|
||||
return ElevenLabs.getVoiceAPI().getDefaultVoiceSettings();
|
||||
}
|
||||
@JsonProperty("stability")
|
||||
private double stability;
|
||||
@@ -15,9 +15,24 @@ public class VoiceSettings extends ElevenModel {
|
||||
@JsonProperty("similarity_boost")
|
||||
private double similarityBoost;
|
||||
|
||||
@JsonProperty("style")
|
||||
private double style;
|
||||
|
||||
@JsonProperty("use_speaker_boost")
|
||||
private boolean useSpeakerBoost;
|
||||
|
||||
public VoiceSettings(double stability, double similarityBoost, double style, boolean useSpeakerBoost) {
|
||||
this.stability = stability;
|
||||
this.similarityBoost = similarityBoost;
|
||||
this.style = style;
|
||||
this.useSpeakerBoost = useSpeakerBoost;
|
||||
}
|
||||
|
||||
public VoiceSettings(double stability, double similarityBoost) {
|
||||
this.stability = stability;
|
||||
this.similarityBoost = similarityBoost;
|
||||
this.style = 0;
|
||||
this.useSpeakerBoost = true;
|
||||
}
|
||||
|
||||
public VoiceSettings() {
|
||||
@@ -34,11 +49,23 @@ public class VoiceSettings extends ElevenModel {
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public double getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isUseSpeakerBoost() {
|
||||
return useSpeakerBoost;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public String toString() {
|
||||
return "VoiceSettings{" +
|
||||
"stability=" + stability +
|
||||
", similarityBoost=" + similarityBoost +
|
||||
", style=" + style +
|
||||
", useSpeakerBoost=" + useSpeakerBoost +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,9 @@ public abstract class DeleteRequest<T> extends ElevenLabsRequest<T> {
|
||||
public DeleteRequest(String endpoint, Class<T> clazz) {
|
||||
super(HttpRequestType.DELETE, endpoint, clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,15 @@ package net.andrewcpu.elevenlabs.requests;
|
||||
|
||||
import net.andrewcpu.elevenlabs.enums.HttpRequestType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.andrewcpu.elevenlabs.util.ElevenNetworkUtil.buildQueryParameters;
|
||||
|
||||
public abstract class ElevenLabsRequest<T> {
|
||||
private HttpRequestType type;
|
||||
private String endpoint;
|
||||
private Class<T> responseClass;
|
||||
private final HttpRequestType type;
|
||||
private final String endpoint;
|
||||
private final Class<T> responseClass;
|
||||
|
||||
public ElevenLabsRequest(HttpRequestType type, String endpoint, Class<T> clazz) {
|
||||
this.type = type;
|
||||
@@ -18,7 +23,13 @@ public abstract class ElevenLabsRequest<T> {
|
||||
}
|
||||
|
||||
public String getEndpoint() {
|
||||
return endpoint;
|
||||
Map<String, String> params = getQueryParameters();
|
||||
if(params.isEmpty()) return endpoint;
|
||||
return endpoint + "?" + buildQueryParameters(getQueryParameters());
|
||||
}
|
||||
|
||||
public Map<String, String> getQueryParameters() {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
public Class<T> getResponseClass() {
|
||||
@@ -26,6 +37,4 @@ public abstract class ElevenLabsRequest<T> {
|
||||
}
|
||||
|
||||
public abstract Object getPayload();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,4 +6,9 @@ public abstract class GetRequest<T> extends ElevenLabsRequest<T> {
|
||||
public GetRequest(String endpoint, Class<T> clazz) {
|
||||
super(HttpRequestType.GET, endpoint, clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.andrewcpu.elevenlabs.requests;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class PostMultipartRequest<T> extends PostRequest<T> {
|
||||
public PostMultipartRequest(String endpoint, Class<T> clazz) {
|
||||
super(endpoint, clazz);
|
||||
}
|
||||
|
||||
|
||||
public abstract Map<String, Object> getMultipartParts(Map<String, Object> map);
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return getMultipartParts(new HashMap<>());
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,9 @@ public abstract class PostRequest<T> extends ElevenLabsRequest<T> {
|
||||
public PostRequest(String endpoint, Class<T> clazz) {
|
||||
super(HttpRequestType.POST, endpoint, clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.andrewcpu.elevenlabs.requests.audionative;
|
||||
|
||||
import net.andrewcpu.elevenlabs.model.request.CreateAudioNativeProjectRequest;
|
||||
import net.andrewcpu.elevenlabs.model.response.CreateAudioEnabledProjectModelResponse;
|
||||
import net.andrewcpu.elevenlabs.requests.PostMultipartRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PostCreateAudioNativeProjectRequest extends PostMultipartRequest<CreateAudioEnabledProjectModelResponse> {
|
||||
private final CreateAudioNativeProjectRequest request;
|
||||
public PostCreateAudioNativeProjectRequest(CreateAudioNativeProjectRequest request) {
|
||||
super("v1/audio-native", CreateAudioEnabledProjectModelResponse.class);
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getMultipartParts(Map<String, Object> payload) {
|
||||
payload.put("name", request.getName());
|
||||
payload.put("image", request.getImage());
|
||||
payload.put("author", request.getAuthor());
|
||||
payload.put("small", request.isSmall());
|
||||
payload.put("text_color", request.getTextColor());
|
||||
payload.put("background_color", request.getBackgroundColor());
|
||||
payload.put("sessionization", request.getSessionization());
|
||||
payload.put("voice_id", request.getVoiceId());
|
||||
payload.put("model_id", request.getModelId());
|
||||
payload.put("file", request.getFile());
|
||||
payload.put("auto_convert", request.isAutoConvert());
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,4 @@ public class DeleteHistoryItemRequest extends DeleteRequest<String> {
|
||||
public DeleteHistoryItemRequest(String historyItemId) {
|
||||
super("v1/history/" + historyItemId, String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,4 @@ public class GetHistoryItemAudioRequest extends GetRequest<File> {
|
||||
public GetHistoryItemAudioRequest(String historyItemId) {
|
||||
super("v1/history/" + historyItemId + "/audio", File.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,4 @@ public class GetHistoryItemByIdRequest extends GetRequest<HistoryItem> {
|
||||
public GetHistoryItemByIdRequest(String historyId) {
|
||||
super("v1/history/" + historyId, HistoryItem.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,36 @@ package net.andrewcpu.elevenlabs.requests.history;
|
||||
import net.andrewcpu.elevenlabs.model.history.History;
|
||||
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.andrewcpu.elevenlabs.model.history.History.DEFAULT_HISTORY_PAGE_SIZE;
|
||||
|
||||
public class GetHistoryRequest extends GetRequest<History> {
|
||||
private final int pageSize;
|
||||
private final String startAfterHistoryId;
|
||||
|
||||
public GetHistoryRequest() {
|
||||
this(DEFAULT_HISTORY_PAGE_SIZE, null);
|
||||
}
|
||||
|
||||
public GetHistoryRequest(String startAfterHistoryId) {
|
||||
this(DEFAULT_HISTORY_PAGE_SIZE, startAfterHistoryId);
|
||||
}
|
||||
|
||||
public GetHistoryRequest(int pageSize, String startAfterHistoryId) {
|
||||
super("v1/history", History.class);
|
||||
this.pageSize = pageSize;
|
||||
this.startAfterHistoryId = startAfterHistoryId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
public Map<String, String> getQueryParameters() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("page_size", String.valueOf(pageSize));
|
||||
if(startAfterHistoryId != null) {
|
||||
params.put("start_after_history_item_id", startAfterHistoryId);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PostDownloadHistoryItemsRequest extends PostRequest<File> {
|
||||
private String[] historyItemIds;
|
||||
private final String[] historyItemIds;
|
||||
public PostDownloadHistoryItemsRequest(String... historyItemIds) {
|
||||
super("v1/history/download", File.class);
|
||||
this.historyItemIds = historyItemIds;
|
||||
|
||||
@@ -7,9 +7,4 @@ public class GetModelsRequest extends GetRequest<GenerationTypeModel[]> {
|
||||
public GetModelsRequest() {
|
||||
super("v1/models", GenerationTypeModel[].class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.requests.DeleteRequest;
|
||||
|
||||
public class DeleteChapterByIdRequest extends DeleteRequest<String> {
|
||||
public DeleteChapterByIdRequest(String projectId, String chapterId) {
|
||||
super("v1/projects/" + projectId + "/chapters/" + chapterId, String.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.requests.DeleteRequest;
|
||||
|
||||
public class DeleteProjectByIdRequest extends DeleteRequest<String> {
|
||||
public DeleteProjectByIdRequest(String projectId) {
|
||||
super("v1/projects/" + projectId, String.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.model.projects.Chapter;
|
||||
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
||||
|
||||
public class GetChapterByIdRequest extends GetRequest<Chapter> {
|
||||
public GetChapterByIdRequest(String projectId, String chapterId) {
|
||||
super("v1/projects/" + projectId + "/chapters/" + chapterId, Chapter.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.model.response.ChapterSnapshotsModelResponse;
|
||||
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
||||
|
||||
public class GetChapterSnapshotsRequest extends GetRequest<ChapterSnapshotsModelResponse> {
|
||||
public GetChapterSnapshotsRequest(String projectId, String chapterId) {
|
||||
super("v1/projects/" + projectId + "/chapters/" + chapterId + "/snapshots", ChapterSnapshotsModelResponse.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.model.projects.Project;
|
||||
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
||||
|
||||
public class GetProjectByIdRequest extends GetRequest<Project> {
|
||||
public GetProjectByIdRequest(String projectId) {
|
||||
super("v1/projects/" + projectId, Project.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.model.response.ChaptersModelResponse;
|
||||
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
||||
|
||||
public class GetProjectChaptersRequest extends GetRequest<ChaptersModelResponse> {
|
||||
public GetProjectChaptersRequest(String projectId) {
|
||||
super("v1/projects/" + projectId + "/chapters", ChaptersModelResponse.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.model.response.ProjectSnapshotsModelResponse;
|
||||
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
||||
|
||||
public class GetProjectSnapshotsRequest extends GetRequest<ProjectSnapshotsModelResponse> {
|
||||
public GetProjectSnapshotsRequest(String projectId) {
|
||||
super("v1/projects/" + projectId + "/snapshots", ProjectSnapshotsModelResponse.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.model.response.ProjectsModelResponse;
|
||||
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
||||
|
||||
public class GetProjectsRequest extends GetRequest<ProjectsModelResponse> {
|
||||
public GetProjectsRequest() {
|
||||
super("v1/projects", ProjectsModelResponse.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.model.request.AddProjectRequest;
|
||||
import net.andrewcpu.elevenlabs.model.response.ProjectModelResponse;
|
||||
import net.andrewcpu.elevenlabs.requests.PostMultipartRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PostAddProjectRequest extends PostMultipartRequest<ProjectModelResponse> {
|
||||
private final AddProjectRequest request;
|
||||
public PostAddProjectRequest(AddProjectRequest request) {
|
||||
super("v1/projects/add", ProjectModelResponse.class);
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getMultipartParts(Map<String, Object> payload) {
|
||||
payload.put("name",request.getName());
|
||||
payload.put("from_url", request.getFromUrl());
|
||||
payload.put("from_document", request.getFromDocument());
|
||||
payload.put("default_title_voice_id", request.getDefaultTitleVoiceId());
|
||||
payload.put("default_paragraph_voice_id", request.getDefaultParagraphVoiceId());
|
||||
payload.put("default_model_id", request.getDefaultModelId());
|
||||
payload.put("quality_preset", request.getProjectOutputQuality().name().toLowerCase());
|
||||
payload.put("title", request.getTitle());
|
||||
payload.put("author", request.getAuthor());
|
||||
payload.put("isbn_number", request.getIsbnNumber());
|
||||
payload.put("acx_volume_normalization", request.isAcxVolumeNormalization());
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
public class PostConvertChapterRequest extends PostRequest<String> {
|
||||
public PostConvertChapterRequest(String projectId, String chapterId) {
|
||||
super("v1/projects/" + projectId + "/chapters/" + chapterId + "/convert", String.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
public class PostConvertProjectRequest extends PostRequest<String> {
|
||||
public PostConvertProjectRequest(String projectId) {
|
||||
super("v1/projects/" + projectId + "/convert", String.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class PostStreamChapterSnapshotAudioRequest extends PostRequest<InputStream> {
|
||||
public PostStreamChapterSnapshotAudioRequest(String projectId, String chapterId, String chapterSnapshotId) {
|
||||
super("v1/projects/" + projectId + "/chapters/" + chapterId + "/snapshots/" + chapterSnapshotId + "/stream", InputStream.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.andrewcpu.elevenlabs.requests.projects;
|
||||
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class PostStreamProjectSnapshotAudioRequest extends PostRequest<InputStream> {
|
||||
public PostStreamProjectSnapshotAudioRequest(String projectId, String snapshotId) {
|
||||
super("v1/projects/" + projectId + "/snapshots/" + snapshotId + "/stream", InputStream.class);
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,4 @@ public class DeleteSampleRequest extends DeleteRequest<String> {
|
||||
public DeleteSampleRequest(String voiceId, String sampleId) {
|
||||
super("v1/voices/" + voiceId + "/samples/" + sampleId, String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,4 @@ public class GetSampleRequest extends GetRequest<File> {
|
||||
public GetSampleRequest(String voiceId, String sampleId) {
|
||||
super("v1/voices/" + voiceId + "/samples/" + sampleId + "/audio", File.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.andrewcpu.elevenlabs.requests.sts;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
||||
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PostSpeechToSpeechRequest extends PostRequest<File> {
|
||||
private final StreamLatencyOptimization latencyOptimization;
|
||||
private final String modelId;
|
||||
private final VoiceSettings voiceSettings;
|
||||
private final File audio;
|
||||
public PostSpeechToSpeechRequest(String voiceId, VoiceSettings voiceSettings, File audio, String modelId, StreamLatencyOptimization latencyOptimization) {
|
||||
super("v1/speech-to-speech/" + voiceId, File.class);
|
||||
this.latencyOptimization = latencyOptimization;
|
||||
this.voiceSettings = voiceSettings;
|
||||
this.audio = audio;
|
||||
this.modelId = modelId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getQueryParameters() {
|
||||
Map<String, String> opts = new HashMap<>();
|
||||
opts.put("optimize_streaming_latency",String.valueOf(latencyOptimization.getValue()));
|
||||
return opts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
String voiceSettingsString;
|
||||
try {
|
||||
voiceSettingsString = new ObjectMapper().writeValueAsString(voiceSettings);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
body.put("audio", audio);
|
||||
body.put("model_id", modelId);
|
||||
body.put("voice_settings", voiceSettingsString);
|
||||
return body;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.andrewcpu.elevenlabs.requests.sts;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
||||
import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PostSpeechToSpeechStreamedRequest extends PostRequest<InputStream> {
|
||||
private final StreamLatencyOptimization latencyOptimization;
|
||||
private final String modelId;
|
||||
private final VoiceSettings voiceSettings;
|
||||
private final File audio;
|
||||
public PostSpeechToSpeechStreamedRequest(String voiceId, VoiceSettings voiceSettings, File audio, String modelId, StreamLatencyOptimization latencyOptimization) {
|
||||
super("v1/speech-to-speech/" + voiceId + "/stream", InputStream.class);
|
||||
this.latencyOptimization = latencyOptimization;
|
||||
this.voiceSettings = voiceSettings;
|
||||
this.audio = audio;
|
||||
this.modelId = modelId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getQueryParameters() {
|
||||
Map<String, String> opts = new HashMap<>();
|
||||
opts.put("optimize_streaming_latency",String.valueOf(latencyOptimization.getValue()));
|
||||
return opts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
String voiceSettingsString;
|
||||
try {
|
||||
voiceSettingsString = new ObjectMapper().writeValueAsString(voiceSettings);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
body.put("audio", audio);
|
||||
body.put("model_id", modelId);
|
||||
body.put("voice_settings", voiceSettingsString);
|
||||
return body;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,58 @@
|
||||
package net.andrewcpu.elevenlabs.requests.tts;
|
||||
|
||||
import net.andrewcpu.elevenlabs.enums.GeneratedAudioOutputFormat;
|
||||
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
||||
import net.andrewcpu.elevenlabs.model.request.TextToSpeechRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PostTextToSpeechRequest extends PostRequest<File> {
|
||||
private TextToSpeechRequest request;
|
||||
private final TextToSpeechRequest request;
|
||||
private final StreamLatencyOptimization streamLatencyOptimization;
|
||||
private final GeneratedAudioOutputFormat outputFormat;
|
||||
|
||||
public PostTextToSpeechRequest(String voiceId, TextToSpeechRequest request) {
|
||||
super("v1/text-to-speech/" + voiceId, File.class);
|
||||
this.request = request;
|
||||
this.streamLatencyOptimization = StreamLatencyOptimization.getDefault();
|
||||
this.outputFormat = GeneratedAudioOutputFormat.getDefault();
|
||||
}
|
||||
|
||||
public PostTextToSpeechRequest(String voiceId, TextToSpeechRequest request, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
super("v1/text-to-speech/" + voiceId, File.class);
|
||||
this.request = request;
|
||||
this.streamLatencyOptimization = streamLatencyOptimization;
|
||||
this.outputFormat = GeneratedAudioOutputFormat.getDefault();
|
||||
}
|
||||
|
||||
public PostTextToSpeechRequest(String voiceId, TextToSpeechRequest request, StreamLatencyOptimization streamLatencyOptimization, GeneratedAudioOutputFormat generatedAudioOutputFormat) {
|
||||
super("v1/text-to-speech/" + voiceId, File.class);
|
||||
this.request = request;
|
||||
this.streamLatencyOptimization = streamLatencyOptimization;
|
||||
this.outputFormat = generatedAudioOutputFormat;
|
||||
}
|
||||
|
||||
public PostTextToSpeechRequest(String voiceId, TextToSpeechRequest request, GeneratedAudioOutputFormat generatedAudioOutputFormat) {
|
||||
super("v1/text-to-speech/" + voiceId, File.class);
|
||||
this.request = request;
|
||||
this.streamLatencyOptimization = StreamLatencyOptimization.getDefault();
|
||||
this.outputFormat = generatedAudioOutputFormat;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getQueryParameters() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("optimize_streaming_latency", String.valueOf(streamLatencyOptimization.getValue()));
|
||||
map.put("output_format", outputFormat.name().toLowerCase());
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,53 @@
|
||||
package net.andrewcpu.elevenlabs.requests.tts;
|
||||
|
||||
import net.andrewcpu.elevenlabs.enums.GeneratedAudioOutputFormat;
|
||||
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
||||
import net.andrewcpu.elevenlabs.model.request.TextToSpeechRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PostTextToSpeechStreamedRequest extends PostRequest<InputStream> {
|
||||
private TextToSpeechRequest request;
|
||||
private final TextToSpeechRequest request;
|
||||
private final StreamLatencyOptimization streamLatencyOptimization;
|
||||
private final GeneratedAudioOutputFormat outputFormat;
|
||||
|
||||
public PostTextToSpeechStreamedRequest(String voiceId, TextToSpeechRequest request) {
|
||||
super("v1/text-to-speech/" + voiceId, InputStream.class);
|
||||
this.request = request;
|
||||
this.streamLatencyOptimization = StreamLatencyOptimization.getDefault();
|
||||
this.outputFormat = GeneratedAudioOutputFormat.getDefault();
|
||||
}
|
||||
|
||||
public PostTextToSpeechStreamedRequest(String voiceId, TextToSpeechRequest request, StreamLatencyOptimization streamLatencyOptimization) {
|
||||
super("v1/text-to-speech/" + voiceId, InputStream.class);
|
||||
this.request = request;
|
||||
this.streamLatencyOptimization = streamLatencyOptimization;
|
||||
this.outputFormat = GeneratedAudioOutputFormat.getDefault();
|
||||
}
|
||||
|
||||
public PostTextToSpeechStreamedRequest(String voiceId, TextToSpeechRequest request, StreamLatencyOptimization streamLatencyOptimization, GeneratedAudioOutputFormat generatedAudioOutputFormat) {
|
||||
super("v1/text-to-speech/" + voiceId, InputStream.class);
|
||||
this.request = request;
|
||||
this.streamLatencyOptimization = streamLatencyOptimization;
|
||||
this.outputFormat = generatedAudioOutputFormat;
|
||||
}
|
||||
|
||||
public PostTextToSpeechStreamedRequest(String voiceId, TextToSpeechRequest request, GeneratedAudioOutputFormat generatedAudioOutputFormat) {
|
||||
super("v1/text-to-speech/" + voiceId, InputStream.class);
|
||||
this.request = request;
|
||||
this.streamLatencyOptimization = StreamLatencyOptimization.getDefault();
|
||||
this.outputFormat = generatedAudioOutputFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getQueryParameters() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("optimize_streaming_latency", String.valueOf(streamLatencyOptimization.getValue()));
|
||||
map.put("output_format", outputFormat.name().toLowerCase());
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,13 +4,7 @@ import net.andrewcpu.elevenlabs.model.user.Subscription;
|
||||
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
||||
|
||||
public class GetSubscriptionRequest extends GetRequest<Subscription> {
|
||||
|
||||
public GetSubscriptionRequest() {
|
||||
super("v1/user/subscription", Subscription.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,4 @@ public class GetUserRequest extends GetRequest<User> {
|
||||
public GetUserRequest() {
|
||||
super("v1/user", User.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,4 @@ public class DeleteVoiceRequest extends DeleteRequest<String> {
|
||||
public DeleteVoiceRequest(String voiceId) {
|
||||
super("v1/voices/" + voiceId, String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,4 @@ public class GetDefaultVoiceSettingsRequest extends GetRequest<VoiceSettings> {
|
||||
public GetDefaultVoiceSettingsRequest() {
|
||||
super("v1/voices/settings/default", VoiceSettings.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,20 +7,22 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GetVoiceRequest extends GetRequest<Voice> {
|
||||
private boolean withSettings;
|
||||
private final boolean withSettings;
|
||||
public GetVoiceRequest(String voiceId) {
|
||||
this(voiceId, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public GetVoiceRequest(String voiceId, boolean withSettings) {
|
||||
super( "v1/voices/" + voiceId, Voice.class);
|
||||
this.withSettings = withSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
Map<String, Object> payload = new HashMap<>();
|
||||
payload.put("with_settings", withSettings);
|
||||
public Map<String, String> getQueryParameters() {
|
||||
Map<String, String> payload = new HashMap<>();
|
||||
payload.put("with_settings", String.valueOf(withSettings));
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,4 @@ public class GetVoiceSettingsRequest extends GetRequest<VoiceSettings> {
|
||||
public GetVoiceSettingsRequest(String voiceId) {
|
||||
super("v1/voices/" + voiceId + "/settings", VoiceSettings.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,4 @@ public class GetVoicesRequest extends GetRequest<VoiceModelResponse> {
|
||||
public GetVoicesRequest() {
|
||||
super("v1/voices", VoiceModelResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package net.andrewcpu.elevenlabs.requests.voices;
|
||||
|
||||
import net.andrewcpu.elevenlabs.model.response.CreateVoiceResponse;
|
||||
import net.andrewcpu.elevenlabs.requests.PostMultipartRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PostAddVoiceRequest extends PostRequest<CreateVoiceResponse> {
|
||||
private String name;
|
||||
private File[] samples;
|
||||
private String description;
|
||||
private Map<String, String> labels;
|
||||
public class PostAddVoiceRequest extends PostMultipartRequest<CreateVoiceResponse> {
|
||||
private final String name;
|
||||
private final File[] samples;
|
||||
private final String description;
|
||||
private final Map<String, String> labels;
|
||||
public PostAddVoiceRequest(String name, File[] samples, String description, Map<String, String> labels) {
|
||||
super("v1/voices/add", CreateVoiceResponse.class);
|
||||
this.name = name;
|
||||
@@ -37,8 +38,7 @@ public class PostAddVoiceRequest extends PostRequest<CreateVoiceResponse> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
public Map<String, Object> getMultipartParts(Map<String, Object> map) {
|
||||
map.put("name", this.name);
|
||||
map.put("files", this.samples);
|
||||
map.put("description", this.description);
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package net.andrewcpu.elevenlabs.requests.voices;
|
||||
|
||||
import net.andrewcpu.elevenlabs.requests.PostMultipartRequest;
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PostEditVoiceRequest extends PostRequest<String> {
|
||||
private String name;
|
||||
private File[] samples;
|
||||
private String description;
|
||||
private Map<String, String> labels;
|
||||
public class PostEditVoiceRequest extends PostMultipartRequest<String> {
|
||||
private final String name;
|
||||
private final File[] samples;
|
||||
private final String description;
|
||||
private final Map<String, String> labels;
|
||||
public PostEditVoiceRequest(String voiceId, String name, File[] samples, String description, Map<String, String> labels) {
|
||||
super("v1/voices/" + voiceId + "/edit", String.class);
|
||||
this.name = name;
|
||||
@@ -36,8 +37,7 @@ public class PostEditVoiceRequest extends PostRequest<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPayload() {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
public Map<String, Object> getMultipartParts(Map<String, Object> map) {
|
||||
map.put("name", this.name);
|
||||
map.put("files", this.samples);
|
||||
map.put("description", this.description);
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||
|
||||
public class PostEditVoiceSettingsRequest extends PostRequest<String> {
|
||||
private VoiceSettings voiceSettings;
|
||||
private final VoiceSettings voiceSettings;
|
||||
public PostEditVoiceSettingsRequest(String voiceId, VoiceSettings voiceSettings) {
|
||||
super("v1/voices/" + voiceId + "/settings/edit", String.class);
|
||||
this.voiceSettings = voiceSettings;
|
||||
|
||||
@@ -12,18 +12,23 @@ import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
||||
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||
import org.apache.hc.core5.http.*;
|
||||
import org.apache.hc.core5.http.ContentType;
|
||||
import org.apache.hc.core5.http.HttpEntity;
|
||||
import org.apache.hc.core5.http.HttpRequest;
|
||||
import org.apache.hc.core5.http.NameValuePair;
|
||||
import org.apache.hc.core5.http.io.entity.EntityUtils;
|
||||
import org.apache.hc.core5.http.io.entity.StringEntity;
|
||||
import org.apache.hc.core5.http.message.BasicNameValuePair;
|
||||
import org.apache.hc.core5.net.URIBuilder;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class ElevenNetworkUtil {
|
||||
private static final String BASE_URL = "https://api.elevenlabs.io/";
|
||||
@@ -34,6 +39,19 @@ public class ElevenNetworkUtil {
|
||||
request.setHeader("xi-api-key", ElevenLabs.getApiKey());
|
||||
}
|
||||
|
||||
public static String buildQueryParameters(Map<String, String> parameters) {
|
||||
StringJoiner queryParameters = new StringJoiner("&");
|
||||
for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||
String encodedKey = encodeValue(entry.getKey());
|
||||
String encodedValue = encodeValue(entry.getValue());
|
||||
queryParameters.add(encodedKey + "=" + encodedValue);
|
||||
}
|
||||
return queryParameters.toString();
|
||||
}
|
||||
|
||||
private static String encodeValue(String value) {
|
||||
return URLEncoder.encode(value, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static HttpUriRequestBase getRequest(HttpRequestType type, String path) {
|
||||
switch (type) {
|
||||
@@ -48,22 +66,10 @@ public class ElevenNetworkUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<NameValuePair> getParameters(Object payload) {
|
||||
List<NameValuePair> parameters = new ArrayList<>();
|
||||
if (payload instanceof Map<?, ?>) {
|
||||
Map<?, ?> payloadMap = (Map<?, ?>) payload;
|
||||
for (Map.Entry<?, ?> entry : payloadMap.entrySet()) {
|
||||
parameters.add(new BasicNameValuePair(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())));
|
||||
}
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
private static HttpUriRequestBase handleNonBodyRequest(HttpRequestType requestType, Object payload, String path) {
|
||||
List<NameValuePair> parameters = getParameters(payload);
|
||||
private static HttpUriRequestBase handleNonBodyRequest(HttpRequestType requestType, String path) {
|
||||
HttpUriRequestBase request = getRequest(requestType, path);
|
||||
try {
|
||||
request.setUri(new URIBuilder(path).addParameters(parameters).build());
|
||||
request.setUri(new URIBuilder(path).build());
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -123,7 +129,7 @@ public class ElevenNetworkUtil {
|
||||
public static HttpUriRequestBase getRequest(HttpRequestType method, String path, Object payload) throws JsonProcessingException {
|
||||
HttpUriRequestBase request;
|
||||
if (method == HttpRequestType.GET || method == HttpRequestType.DELETE) {
|
||||
request = handleNonBodyRequest(method, payload, path);
|
||||
request = handleNonBodyRequest(method, path);
|
||||
} else {
|
||||
request = handleBodyRequest(method, payload, path);
|
||||
}
|
||||
@@ -131,12 +137,17 @@ public class ElevenNetworkUtil {
|
||||
return request;
|
||||
}
|
||||
|
||||
public static String getHistoryItemUrl(String historyItemId) {
|
||||
return BASE_URL + "v1/history/" + historyItemId + "/audio";
|
||||
}
|
||||
|
||||
public static <T> T sendRequest(HttpRequestType method, String path, Object payload, Class<T> responseType) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
path = BASE_URL + path;
|
||||
try {
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
HttpUriRequestBase request = getRequest(method, path, payload);
|
||||
|
||||
return getRequestResult(responseType, objectMapper, httpclient, request);
|
||||
} catch (IOException | ValidationException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package net.andrewcpu.elevenlabs;
|
||||
|
||||
|
||||
import net.andrewcpu.elevenlabs.builders.SpeechGenerationBuilder;
|
||||
import net.andrewcpu.elevenlabs.builders.abstracts.AbstractSpeechGenerationBuilder;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ElevenLabsTest {
|
||||
public static final String ELEVEN_LABS_API_KEY = "";
|
||||
public static final String ELEVEN_LABS_API_KEY = System.getenv("ELEVENLABS_API_KEY");
|
||||
public static final String TEST_VOICE = "ZjJOFdM86g4E9U6OhzUo";
|
||||
static {
|
||||
ElevenLabs.setApiKey(ELEVEN_LABS_API_KEY);
|
||||
|
||||
@@ -8,7 +8,9 @@ import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.andrewcpu.elevenlabs.model.history.History.DEFAULT_HISTORY_PAGE_SIZE;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class HistoryTest extends ElevenLabsTest {
|
||||
@@ -16,33 +18,35 @@ public class HistoryTest extends ElevenLabsTest {
|
||||
@Test
|
||||
public void testGetHistory() {
|
||||
assertFalse("Failed to get history.", doesThrow(() -> {
|
||||
ElevenLabs.getHistory();
|
||||
ElevenLabs.getHistoryAPI().getHistory();
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHistoryItem() {
|
||||
History history = ElevenLabs.getHistory();
|
||||
History history = ElevenLabs.getHistoryAPI().getHistory();
|
||||
assertNotNull(history);
|
||||
List<HistoryItem> items = history.getHistoryItems();
|
||||
assertNotNull(items);
|
||||
assertTrue(items.size() != 0);
|
||||
HistoryItem item = history.getHistoryItems().get(0);
|
||||
assertFalse("Failed to get history item", doesThrow(() -> {
|
||||
ElevenLabs.getHistoryItem(item.getHistoryItemId());
|
||||
ElevenLabs.getHistoryAPI().getHistoryItem(item.getHistoryItemId());
|
||||
}));
|
||||
assertFalse("Failed to download audio history.", doesThrow(() -> {
|
||||
File output = ElevenLabs.getHistoryItemAudio(item.getHistoryItemId());
|
||||
File output = ElevenLabs.getHistoryAPI().getHistoryItemAudio(item.getHistoryItemId());
|
||||
output.delete();
|
||||
}));
|
||||
assertTrue(items.size() >= 2);
|
||||
HistoryItem item2 = history.getHistoryItems().get(1);
|
||||
|
||||
assertFalse("Failed to download audio history (grouped).", doesThrow(() -> {
|
||||
File output = ElevenLabs.getHistoryItemAudio(item.getHistoryItemId(), item2.getHistoryItemId());
|
||||
File output = ElevenLabs.getHistoryAPI().getHistoryItemAudio(item.getHistoryItemId(), item2.getHistoryItemId());
|
||||
System.out.println(output.getName());
|
||||
output.delete();
|
||||
}));
|
||||
|
||||
Optional<History> nextHistory = history.next(DEFAULT_HISTORY_PAGE_SIZE);
|
||||
assertTrue(nextHistory.isPresent());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ public class AvailableModelsTest extends ElevenLabsTest {
|
||||
public void testGetModels() {
|
||||
GenerationTypeModel[] models = null;
|
||||
try{
|
||||
models = ElevenLabs.getAvailableModels();
|
||||
System.out.println(Arrays.stream(models).map(Object::toString).collect(Collectors.toList()));
|
||||
models = ElevenLabs.getModelsAPI().getAvailableModels();
|
||||
Arrays.stream(models).map(o -> o.getModelId() + "," + o.getName()).forEach(System.out::println);
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail("Failed to get voice type models: " + e.getMessage());
|
||||
|
||||
@@ -16,18 +16,18 @@ public class AudioSampleTest extends ElevenLabsTest {
|
||||
public void testGetAudioSamples() {
|
||||
assertFalse("Couldn't load audio samples.", doesThrow(() -> {
|
||||
List<Sample> samples = null;
|
||||
samples = ElevenLabs.getVoice(TEST_VOICE, true).getSamples();
|
||||
samples = ElevenLabs.getVoiceAPI().getVoice(TEST_VOICE, true).getSamples();
|
||||
assertNotNull(samples);
|
||||
}));
|
||||
}
|
||||
@Test
|
||||
public void testGetAudioSample() {
|
||||
assertFalse("Couldn't load audio sample.", doesThrow(() -> {
|
||||
Voice voice = ElevenLabs.getVoice(TEST_VOICE, true);
|
||||
Voice voice = ElevenLabs.getVoiceAPI().getVoice(TEST_VOICE, true);
|
||||
assertNotNull("Voice is null!", voice);
|
||||
assertNotNull("Voice samples are null!", voice.getSamples());
|
||||
assertTrue("No samples to test!", voice.getSamples().size() != 0);
|
||||
File file = ElevenLabs.getAudioSample(TEST_VOICE, voice.getSamples().get(0).getSampleId());
|
||||
File file = ElevenLabs.getSampleAPI().getAudioSample(TEST_VOICE, voice.getSamples().get(0).getSampleId());
|
||||
assertNotNull(file);
|
||||
file.delete();
|
||||
}));
|
||||
|
||||
@@ -14,7 +14,7 @@ public class TextToSpeechTest extends ElevenLabsTest {
|
||||
@Test
|
||||
public void testDownloadResponse() {
|
||||
assertFalse("Cannot download tts!", doesThrow(() -> {
|
||||
File file = ElevenLabs.generateTextToSpeech(TEST_VOICE, "This is a test", "eleven_monolingual_v1", new VoiceSettings(0.7, 0.7));
|
||||
File file = ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(TEST_VOICE, "This is a test", "eleven_monolingual_v1", new VoiceSettings(0.7, 0.7, 0, true));
|
||||
file.delete();
|
||||
}));
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class TextToSpeechTest extends ElevenLabsTest {
|
||||
@Test
|
||||
public void testStreamedResponse() {
|
||||
assertFalse("Cannot strem tts!", doesThrow(() -> {
|
||||
InputStream inputStream = ElevenLabs.generateTextToSpeechStreamed(TEST_VOICE, "This is a test", "eleven_monolingual_v1", new VoiceSettings(0.7, 0.7));
|
||||
InputStream inputStream = ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(TEST_VOICE, "This is a test", "eleven_monolingual_v1", new VoiceSettings(0.7, 0.7, 0, true));
|
||||
File tmp;
|
||||
try {
|
||||
tmp = File.createTempFile("test", "audio");
|
||||
|
||||
@@ -4,27 +4,26 @@ import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||
import net.andrewcpu.elevenlabs.ElevenLabsTest;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class UserTest extends ElevenLabsTest {
|
||||
@Test
|
||||
public void testGetUser() {
|
||||
try{
|
||||
ElevenLabs.getUser();
|
||||
ElevenLabs.getUserAPI().getUser();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
assertTrue("Failed to get user: " + e.getMessage(), false);
|
||||
fail("Failed to get user: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSubscription() {
|
||||
try{
|
||||
ElevenLabs.getSubscription();
|
||||
ElevenLabs.getUserAPI().getSubscription();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
assertFalse("Failed to get subscription: " + e.getMessage(), true);
|
||||
fail("Failed to get subscription: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class VoiceTest extends ElevenLabsTest {
|
||||
@@ -22,34 +21,34 @@ public class VoiceTest extends ElevenLabsTest {
|
||||
public void testGetVoiceWithSettings() {
|
||||
Voice voice = null;
|
||||
try{
|
||||
voice = ElevenLabs.getVoice(ElevenLabsTest.TEST_VOICE, true);
|
||||
voice = ElevenLabs.getVoiceAPI().getVoice(ElevenLabsTest.TEST_VOICE, true);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
assertTrue("Failed to get voice: " + e.getMessage(), voice != null);
|
||||
assertNotNull("Failed to get voice: " + e.getMessage(), voice);
|
||||
}
|
||||
assertTrue(voice.getSettings() != null);
|
||||
assertNotNull(voice.getSettings());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVoiceWithoutSettings() {
|
||||
Voice voice = null;
|
||||
try{
|
||||
voice = ElevenLabs.getVoice(ElevenLabsTest.TEST_VOICE, false);
|
||||
voice = ElevenLabs.getVoiceAPI().getVoice(ElevenLabsTest.TEST_VOICE, false);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
assertTrue("Failed to get voice: " + e.getMessage(), voice != null);
|
||||
assertNotNull("Failed to get voice: " + e.getMessage(), voice);
|
||||
}
|
||||
assertTrue(voice.getSettings() == null);
|
||||
assertNull(voice.getSettings());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVoiceSettings() {
|
||||
VoiceSettings settings = null;
|
||||
try{
|
||||
settings = ElevenLabs.getVoiceSettings(ElevenLabsTest.TEST_VOICE);
|
||||
settings = ElevenLabs.getVoiceAPI().getVoiceSettings(ElevenLabsTest.TEST_VOICE);
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
assertTrue("Failed to get voice settings: " + e.getMessage(), false);
|
||||
fail("Failed to get voice settings: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,10 +56,10 @@ public class VoiceTest extends ElevenLabsTest {
|
||||
public void getDefaultVoiceSettings() {
|
||||
VoiceSettings defaultVoiceSettings = null;
|
||||
try {
|
||||
defaultVoiceSettings = ElevenLabs.getDefaultVoiceSettings();
|
||||
defaultVoiceSettings = ElevenLabs.getVoiceAPI().getDefaultVoiceSettings();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
assertTrue("Failed to get default voice settings: " + e.getMessage(), false);
|
||||
fail("Failed to get default voice settings: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,10 +67,10 @@ public class VoiceTest extends ElevenLabsTest {
|
||||
public void getVoices() {
|
||||
List<Voice> voices = null;
|
||||
try{
|
||||
voices = ElevenLabs.getVoices();
|
||||
voices = ElevenLabs.getVoiceAPI().getVoices();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();;
|
||||
assertTrue("Failed to get voices: " + e.getMessage(), false);
|
||||
e.printStackTrace();
|
||||
fail("Failed to get voices: " + e.getMessage());
|
||||
}
|
||||
assertTrue(voices != null && voices.size() > 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user