mirror of
https://github.com/Andrewcpu/elevenlabs-api.git
synced 2026-05-06 03:00:23 -04:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
334a903c83 | ||
|
|
d7a710e197 | ||
|
|
15db53e81e | ||
|
|
bc6ee1306f | ||
|
|
8199e766ef |
2
pom.xml
2
pom.xml
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
<groupId>net.andrewcpu</groupId>
|
<groupId>net.andrewcpu</groupId>
|
||||||
<artifactId>elevenlabs-api</artifactId>
|
<artifactId>elevenlabs-api</artifactId>
|
||||||
<version>2.2</version>
|
<version>2.6-SNAPSHOT</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
|
|||||||
@@ -1,38 +1,18 @@
|
|||||||
package net.andrewcpu.elevenlabs;
|
package net.andrewcpu.elevenlabs;
|
||||||
|
|
||||||
import net.andrewcpu.elevenlabs.enums.GeneratedAudioOutputFormat;
|
import net.andrewcpu.elevenlabs.api.impl.*;
|
||||||
import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
|
||||||
import net.andrewcpu.elevenlabs.model.history.History;
|
|
||||||
import net.andrewcpu.elevenlabs.model.history.HistoryItem;
|
|
||||||
import net.andrewcpu.elevenlabs.model.projects.Project;
|
|
||||||
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.response.ProjectsModelResponse;
|
|
||||||
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.projects.GetProjectsRequest;
|
|
||||||
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;
|
|
||||||
|
|
||||||
public class ElevenLabs {
|
public class ElevenLabs {
|
||||||
private static String API_KEY = null;
|
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() {
|
public static String getApiKey() {
|
||||||
return API_KEY;
|
return API_KEY;
|
||||||
@@ -40,103 +20,54 @@ public class ElevenLabs {
|
|||||||
|
|
||||||
public static void setApiKey(String apiKey) {
|
public static void setApiKey(String apiKey) {
|
||||||
API_KEY = apiKey;
|
API_KEY = apiKey;
|
||||||
|
initializeSubclasses();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T sendRequest(ElevenLabsRequest<T> request) {
|
private static void initializeSubclasses() {
|
||||||
return ElevenNetworkUtil.sendRequest(request.getType(),request.getEndpoint(), request.getPayload(),request.getResponseClass());
|
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() {
|
public static AudioNativeAPI getAudioNativeAPI() {
|
||||||
return sendRequest(new GetHistoryRequest());
|
return audioNativeAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static User getUser() {
|
public static HistoryAPI getHistoryAPI() {
|
||||||
return sendRequest(new GetUserRequest());
|
return historyAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Subscription getSubscription() {
|
public static ModelsAPI getModelsAPI() {
|
||||||
return sendRequest(new GetSubscriptionRequest());
|
return modelsAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HistoryItem getHistoryItem(String historyItemId) {
|
public static ProjectsAPI getProjectsAPI() {
|
||||||
return sendRequest(new GetHistoryItemByIdRequest(historyItemId));
|
return projectsAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String deleteHistoryItem(String historyItemId) {
|
public static SampleAPI getSampleAPI() {
|
||||||
return sendRequest(new DeleteHistoryItemRequest(historyItemId));
|
return sampleAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getHistoryItemAudio(String historyItemId) {
|
public static SpeechToSpeechAPI getSpeechToSpeechAPI() {
|
||||||
return sendRequest(new GetHistoryItemAudioRequest(historyItemId));
|
return speechToSpeechAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getHistoryItemAudio(String... historyItemIds) {
|
public static TextToSpeechAPI getTextToSpeechAPI() {
|
||||||
return sendRequest(new PostDownloadHistoryItemsRequest(historyItemIds));
|
return textToSpeechAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String deleteSample(String voiceId, String sampleId) {
|
public static UserAPI getUserAPI() {
|
||||||
return sendRequest(new DeleteSampleRequest(voiceId, sampleId));
|
return userAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getAudioSample(String voiceId, String sampleId) {
|
public static VoiceAPI getVoiceAPI() {
|
||||||
return sendRequest(new GetSampleRequest(voiceId, sampleId));
|
return voiceAPI;
|
||||||
}
|
|
||||||
|
|
||||||
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 ProjectsModelResponse getProjects() {
|
|
||||||
return sendRequest(new GetProjectsRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
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 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 static 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 static InputStream generateTextToSpeechStreamed(String voiceId, String text, String modelId, VoiceSettings voiceSettings) {
|
|
||||||
return sendRequest(new PostTextToSpeechStreamedRequest(voiceId, new TextToSpeechRequest(text, modelId, voiceSettings)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,31 @@
|
|||||||
|
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 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,28 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.api.impl;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.api.ElevenLabsAPI;
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package net.andrewcpu.elevenlabs.enums;
|
package net.andrewcpu.elevenlabs.enums;
|
||||||
|
|
||||||
public enum HttpRequestType {
|
public enum HttpRequestType {
|
||||||
POST, GET, PUT, DELETE;
|
POST, GET, PUT, DELETE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
public class History extends ElevenModel {
|
public class History extends ElevenModel {
|
||||||
|
|
||||||
public static History get() {
|
public static History get() {
|
||||||
return ElevenLabs.getHistory();
|
return ElevenLabs.getHistoryAPI().getHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty("history")
|
@JsonProperty("history")
|
||||||
@@ -57,11 +57,11 @@ public class History extends ElevenModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public File downloadHistory(String... historyIds) {
|
public File downloadHistory(String... historyIds) {
|
||||||
return ElevenLabs.getHistoryItemAudio(historyIds);
|
return ElevenLabs.getHistoryAPI().getHistoryItemAudio(historyIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File downloadHistory(HistoryItem... items) {
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@@ -124,11 +124,11 @@ public class HistoryItem extends ElevenModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String delete() {
|
public String delete() {
|
||||||
return ElevenLabs.deleteHistoryItem(historyItemId);
|
return ElevenLabs.getHistoryAPI().deleteHistoryItem(historyItemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File downloadAudio() {
|
public File downloadAudio() {
|
||||||
return ElevenLabs.getHistoryItemAudio(historyItemId);
|
return ElevenLabs.getHistoryAPI().getHistoryItemAudio(historyItemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@@ -1,9 +1,27 @@
|
|||||||
package net.andrewcpu.elevenlabs.model.projects;
|
package net.andrewcpu.elevenlabs.model.projects;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Chapter extends ElevenModel {
|
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")
|
@JsonProperty("chapter_id")
|
||||||
private String chapterId;
|
private String chapterId;
|
||||||
|
|
||||||
@@ -24,4 +42,66 @@ public class Chapter extends ElevenModel {
|
|||||||
|
|
||||||
@JsonProperty("statistics")
|
@JsonProperty("statistics")
|
||||||
private Statistics 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 +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,17 @@ package net.andrewcpu.elevenlabs.model.projects;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
public class ChapterSnapshot extends ElevenModel {
|
public class ChapterSnapshot extends ElevenModel {
|
||||||
|
|
||||||
|
public InputStream getAudioStream() {
|
||||||
|
return ElevenLabs.getProjectsAPI().getChapterSnapshotAudioStream(projectId, chapterId, chapterSnapshotId);
|
||||||
|
}
|
||||||
|
|
||||||
public ChapterSnapshot() {
|
public ChapterSnapshot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,59 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import net.andrewcpu.elevenlabs.ElevenLabs;
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
import net.andrewcpu.elevenlabs.model.request.AddProjectRequest;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Project extends ElevenModel {
|
public class Project extends ElevenModel {
|
||||||
|
|
||||||
public static List<Project> getProjects() {
|
public static List<Project> getProjects() {
|
||||||
return ElevenLabs.getProjects().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 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")
|
@JsonProperty("project_id")
|
||||||
|
|||||||
@@ -2,9 +2,17 @@ package net.andrewcpu.elevenlabs.model.projects;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import net.andrewcpu.elevenlabs.ElevenLabs;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
public class ProjectSnapshot extends ElevenModel {
|
public class ProjectSnapshot extends ElevenModel {
|
||||||
|
|
||||||
|
public InputStream getAudioStream() {
|
||||||
|
return ElevenLabs.getProjectsAPI().getProjectSnapshotAudioStream(projectId, projectSnapshotId);
|
||||||
|
}
|
||||||
|
|
||||||
public ProjectSnapshot() {
|
public ProjectSnapshot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package net.andrewcpu.elevenlabs.model.request;
|
|||||||
import net.andrewcpu.elevenlabs.enums.ProjectOutputQuality;
|
import net.andrewcpu.elevenlabs.enums.ProjectOutputQuality;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.invoke.StringConcatFactory;
|
|
||||||
|
|
||||||
public class AddProjectRequest {
|
public class AddProjectRequest {
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.andrewcpu.elevenlabs.model.request;
|
|||||||
|
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
import javax.management.loading.PrivateClassLoader;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class CreateAudioNativeProjectRequest extends ElevenModel {
|
public class CreateAudioNativeProjectRequest extends ElevenModel {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.andrewcpu.elevenlabs.model.response;
|
package net.andrewcpu.elevenlabs.model.response;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
import net.andrewcpu.elevenlabs.model.Language;
|
import net.andrewcpu.elevenlabs.model.Language;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.andrewcpu.elevenlabs.model.tuning;
|
package net.andrewcpu.elevenlabs.model.tuning;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
import net.andrewcpu.elevenlabs.model.ElevenModel;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import net.andrewcpu.elevenlabs.model.ElevenModel;
|
|||||||
public class Subscription extends ElevenModel {
|
public class Subscription extends ElevenModel {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public static Subscription get() {
|
public static Subscription get() {
|
||||||
return ElevenLabs.getSubscription();
|
return ElevenLabs.getUserAPI().getSubscription();
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty("tier")
|
@JsonProperty("tier")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import net.andrewcpu.elevenlabs.model.ElevenModel;
|
|||||||
public class User extends ElevenModel {
|
public class User extends ElevenModel {
|
||||||
|
|
||||||
public static User get() {
|
public static User get() {
|
||||||
return ElevenLabs.getUser();
|
return ElevenLabs.getUserAPI().getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty("subscription")
|
@JsonProperty("subscription")
|
||||||
|
|||||||
@@ -63,14 +63,14 @@ public class Sample extends ElevenModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public File downloadAudio() {
|
public File downloadAudio() {
|
||||||
return ElevenLabs.getAudioSample(voice.getVoiceId(), sampleId);
|
return ElevenLabs.getSampleAPI().getAudioSample(voice.getVoiceId(), sampleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warning! This will delete the sample.
|
* Warning! This will delete the sample.
|
||||||
*/
|
*/
|
||||||
public String delete() {
|
public String delete() {
|
||||||
return ElevenLabs.deleteSample(voice.getVoiceId(), sampleId);
|
return ElevenLabs.getSampleAPI().deleteSample(voice.getVoiceId(), sampleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,15 +16,15 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class Voice extends ElevenModel {
|
public class Voice extends ElevenModel {
|
||||||
public static List<Voice> getVoices() {
|
public static List<Voice> getVoices() {
|
||||||
return ElevenLabs.getVoices();
|
return ElevenLabs.getVoiceAPI().getVoices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Voice getVoice(String voiceId) {
|
public static Voice getVoice(String voiceId) {
|
||||||
return ElevenLabs.getVoice(voiceId);
|
return ElevenLabs.getVoiceAPI().getVoice(voiceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Voice getVoice(String voiceId, boolean withSettings) {
|
public static Voice getVoice(String voiceId, boolean withSettings) {
|
||||||
return ElevenLabs.getVoice(voiceId, withSettings);
|
return ElevenLabs.getVoiceAPI().getVoice(voiceId, withSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonProperty("voice_id")
|
@JsonProperty("voice_id")
|
||||||
@@ -122,15 +122,15 @@ public class Voice extends ElevenModel {
|
|||||||
* Warning! This will delete the voice.
|
* Warning! This will delete the voice.
|
||||||
*/
|
*/
|
||||||
public String delete() {
|
public String delete() {
|
||||||
return ElevenLabs.deleteVoice(voiceId);
|
return ElevenLabs.getVoiceAPI().deleteVoice(voiceId);
|
||||||
}
|
}
|
||||||
public VoiceSettings fetchSettings() {
|
public VoiceSettings fetchSettings() {
|
||||||
this.settings = ElevenLabs.getVoiceSettings(voiceId);
|
this.settings = ElevenLabs.getVoiceAPI().getVoiceSettings(voiceId);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VoiceSettings updateVoiceSettings(VoiceSettings voiceSettings) {
|
public VoiceSettings updateVoiceSettings(VoiceSettings voiceSettings) {
|
||||||
ElevenLabs.editVoiceSettings(voiceId, voiceSettings);
|
ElevenLabs.getVoiceAPI().editVoiceSettings(voiceId, voiceSettings);
|
||||||
this.settings = voiceSettings;
|
this.settings = voiceSettings;
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
@@ -153,98 +153,117 @@ public class Voice extends ElevenModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public File generate(String text, String model) {
|
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) {
|
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) {
|
public File generate(String text, String model, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.generateTextToSpeech(voiceId,text, model, outputFormat,streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId,text, model, outputFormat,streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
public File generate(String text, String model, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat) {
|
public File generate(String text, String model, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat) {
|
||||||
return ElevenLabs.generateTextToSpeech(voiceId,text, model, outputFormat,StreamLatencyOptimization.getDefault(), settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId,text, model, outputFormat,StreamLatencyOptimization.getDefault(), settings);
|
||||||
}
|
}
|
||||||
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat) {
|
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat) {
|
||||||
return ElevenLabs.generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", outputFormat,StreamLatencyOptimization.getDefault(), settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", outputFormat,StreamLatencyOptimization.getDefault(), settings);
|
||||||
}
|
}
|
||||||
public File generate(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization) {
|
public File generate(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", GeneratedAudioOutputFormat.getDefault(),streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", GeneratedAudioOutputFormat.getDefault(),streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
public File generate(String text, VoiceSettings settings, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", outputFormat,streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", outputFormat,streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
public File generate(String text, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
public File generate(String text, GeneratedAudioOutputFormat outputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", outputFormat,streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", outputFormat,streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
public File generate(String text, StreamLatencyOptimization streamLatencyOptimization) {
|
public File generate(String text, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File generate(String text, VoiceSettings settings) {
|
public File generate(String text, VoiceSettings settings) {
|
||||||
return ElevenLabs.generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File generate(String text) {
|
public File generate(String text) {
|
||||||
return ElevenLabs.generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(voiceId, text, "eleven_monolingual_v1", settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public InputStream generateStream(String text, String model) {
|
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) {
|
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) {
|
public InputStream generateStream(String text, VoiceSettings settings) {
|
||||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text) {
|
public InputStream generateStream(String text) {
|
||||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, model, generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, model, generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings settings) {
|
public InputStream generateStream(String text, String model, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings settings) {
|
||||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, model, generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, model, generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, VoiceSettings settings, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, VoiceSettings settings, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, GeneratedAudioOutputFormat generatedAudioOutputFormat, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", generatedAudioOutputFormat, streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, model, GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, model, GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings settings) {
|
public InputStream generateStream(String text, String model, StreamLatencyOptimization streamLatencyOptimization, VoiceSettings settings) {
|
||||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, model, GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, model, GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, VoiceSettings settings, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream generateStream(String text, StreamLatencyOptimization streamLatencyOptimization) {
|
public InputStream generateStream(String text, StreamLatencyOptimization streamLatencyOptimization) {
|
||||||
return ElevenLabs.generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", GeneratedAudioOutputFormat.getDefault(), streamLatencyOptimization, settings);
|
return ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(voiceId, text, "eleven_monolingual_v1", 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);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
@@ -81,12 +81,12 @@ public class VoiceBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Voice create() {
|
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);
|
return Voice.getVoice(createVoiceResponse.getVoiceId(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Voice edit() {
|
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();
|
voice = voice.refresh();
|
||||||
return voice;
|
return voice;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import net.andrewcpu.elevenlabs.model.ElevenModel;
|
|||||||
|
|
||||||
public class VoiceSettings extends ElevenModel {
|
public class VoiceSettings extends ElevenModel {
|
||||||
public static VoiceSettings getDefaultVoiceSettings() {
|
public static VoiceSettings getDefaultVoiceSettings() {
|
||||||
return ElevenLabs.getDefaultVoiceSettings();
|
return ElevenLabs.getVoiceAPI().getDefaultVoiceSettings();
|
||||||
}
|
}
|
||||||
@JsonProperty("stability")
|
@JsonProperty("stability")
|
||||||
private double stability;
|
private double stability;
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import java.util.Map;
|
|||||||
import static net.andrewcpu.elevenlabs.util.ElevenNetworkUtil.buildQueryParameters;
|
import static net.andrewcpu.elevenlabs.util.ElevenNetworkUtil.buildQueryParameters;
|
||||||
|
|
||||||
public abstract class ElevenLabsRequest<T> {
|
public abstract class ElevenLabsRequest<T> {
|
||||||
private HttpRequestType type;
|
private final HttpRequestType type;
|
||||||
private String endpoint;
|
private final String endpoint;
|
||||||
private Class<T> responseClass;
|
private final Class<T> responseClass;
|
||||||
|
|
||||||
public ElevenLabsRequest(HttpRequestType type, String endpoint, Class<T> clazz) {
|
public ElevenLabsRequest(HttpRequestType type, String endpoint, Class<T> clazz) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PostCreateAudioNativeProjectRequest extends PostRequest<CreateAudioEnabledProjectModelResponse> {
|
public class PostCreateAudioNativeProjectRequest extends PostRequest<CreateAudioEnabledProjectModelResponse> {
|
||||||
private CreateAudioNativeProjectRequest request;
|
private final CreateAudioNativeProjectRequest request;
|
||||||
public PostCreateAudioNativeProjectRequest(CreateAudioNativeProjectRequest request) {
|
public PostCreateAudioNativeProjectRequest(CreateAudioNativeProjectRequest request) {
|
||||||
super("v1/audio-native", CreateAudioEnabledProjectModelResponse.class);
|
super("v1/audio-native", CreateAudioEnabledProjectModelResponse.class);
|
||||||
this.request = request;
|
this.request = request;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.Arrays;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PostDownloadHistoryItemsRequest extends PostRequest<File> {
|
public class PostDownloadHistoryItemsRequest extends PostRequest<File> {
|
||||||
private String[] historyItemIds;
|
private final String[] historyItemIds;
|
||||||
public PostDownloadHistoryItemsRequest(String... historyItemIds) {
|
public PostDownloadHistoryItemsRequest(String... historyItemIds) {
|
||||||
super("v1/history/download", File.class);
|
super("v1/history/download", File.class);
|
||||||
this.historyItemIds = historyItemIds;
|
this.historyItemIds = historyItemIds;
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package net.andrewcpu.elevenlabs.requests.projects;
|
package net.andrewcpu.elevenlabs.requests.projects;
|
||||||
|
|
||||||
|
import net.andrewcpu.elevenlabs.model.response.ChapterSnapshotsModelResponse;
|
||||||
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
||||||
|
|
||||||
public class GetChapterSnapshotsRequest extends GetRequest<GetChapterSnapshotsRequest> {
|
public class GetChapterSnapshotsRequest extends GetRequest<ChapterSnapshotsModelResponse> {
|
||||||
public GetChapterSnapshotsRequest(String projectId, String chapterId) {
|
public GetChapterSnapshotsRequest(String projectId, String chapterId) {
|
||||||
super("v1/projects/" + projectId + "/chapters/" + chapterId + "/snapshots", GetChapterSnapshotsRequest.class);
|
super("v1/projects/" + projectId + "/chapters/" + chapterId + "/snapshots", ChapterSnapshotsModelResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package net.andrewcpu.elevenlabs.requests.projects;
|
|||||||
import net.andrewcpu.elevenlabs.model.response.ProjectsModelResponse;
|
import net.andrewcpu.elevenlabs.model.response.ProjectsModelResponse;
|
||||||
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
import net.andrewcpu.elevenlabs.requests.GetRequest;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class GetProjectsRequest extends GetRequest<ProjectsModelResponse> {
|
public class GetProjectsRequest extends GetRequest<ProjectsModelResponse> {
|
||||||
public GetProjectsRequest() {
|
public GetProjectsRequest() {
|
||||||
super("v1/projects", ProjectsModelResponse.class);
|
super("v1/projects", ProjectsModelResponse.class);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PostAddProjectRequest extends PostRequest<ProjectModelResponse> {
|
public class PostAddProjectRequest extends PostRequest<ProjectModelResponse> {
|
||||||
private AddProjectRequest request;
|
private final AddProjectRequest request;
|
||||||
public PostAddProjectRequest(AddProjectRequest request) {
|
public PostAddProjectRequest(AddProjectRequest request) {
|
||||||
super("v1/projects/add", ProjectModelResponse.class);
|
super("v1/projects/add", ProjectModelResponse.class);
|
||||||
this.request = request;
|
this.request = request;
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.requests.sts;
|
||||||
|
|
||||||
|
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<>();
|
||||||
|
body.put("audio", audio);
|
||||||
|
body.put("model_id", modelId);
|
||||||
|
body.put("voice_settings", voiceSettings);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package net.andrewcpu.elevenlabs.requests.sts;
|
||||||
|
|
||||||
|
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<>();
|
||||||
|
body.put("audio", audio);
|
||||||
|
body.put("model_id", modelId);
|
||||||
|
body.put("voice_settings", voiceSettings);
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,9 +10,9 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PostTextToSpeechRequest extends PostRequest<File> {
|
public class PostTextToSpeechRequest extends PostRequest<File> {
|
||||||
private TextToSpeechRequest request;
|
private final TextToSpeechRequest request;
|
||||||
private StreamLatencyOptimization streamLatencyOptimization;
|
private final StreamLatencyOptimization streamLatencyOptimization;
|
||||||
private GeneratedAudioOutputFormat outputFormat;
|
private final GeneratedAudioOutputFormat outputFormat;
|
||||||
|
|
||||||
public PostTextToSpeechRequest(String voiceId, TextToSpeechRequest request) {
|
public PostTextToSpeechRequest(String voiceId, TextToSpeechRequest request) {
|
||||||
super("v1/text-to-speech/" + voiceId, File.class);
|
super("v1/text-to-speech/" + voiceId, File.class);
|
||||||
|
|||||||
@@ -5,15 +5,14 @@ import net.andrewcpu.elevenlabs.enums.StreamLatencyOptimization;
|
|||||||
import net.andrewcpu.elevenlabs.model.request.TextToSpeechRequest;
|
import net.andrewcpu.elevenlabs.model.request.TextToSpeechRequest;
|
||||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PostTextToSpeechStreamedRequest extends PostRequest<InputStream> {
|
public class PostTextToSpeechStreamedRequest extends PostRequest<InputStream> {
|
||||||
private TextToSpeechRequest request;
|
private final TextToSpeechRequest request;
|
||||||
private StreamLatencyOptimization streamLatencyOptimization;
|
private final StreamLatencyOptimization streamLatencyOptimization;
|
||||||
private GeneratedAudioOutputFormat outputFormat;
|
private final GeneratedAudioOutputFormat outputFormat;
|
||||||
|
|
||||||
public PostTextToSpeechStreamedRequest(String voiceId, TextToSpeechRequest request) {
|
public PostTextToSpeechStreamedRequest(String voiceId, TextToSpeechRequest request) {
|
||||||
super("v1/text-to-speech/" + voiceId, InputStream.class);
|
super("v1/text-to-speech/" + voiceId, InputStream.class);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class GetVoiceRequest extends GetRequest<Voice> {
|
public class GetVoiceRequest extends GetRequest<Voice> {
|
||||||
private boolean withSettings;
|
private final boolean withSettings;
|
||||||
public GetVoiceRequest(String voiceId) {
|
public GetVoiceRequest(String voiceId) {
|
||||||
this(voiceId, true);
|
this(voiceId, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PostAddVoiceRequest extends PostRequest<CreateVoiceResponse> {
|
public class PostAddVoiceRequest extends PostRequest<CreateVoiceResponse> {
|
||||||
private String name;
|
private final String name;
|
||||||
private File[] samples;
|
private final File[] samples;
|
||||||
private String description;
|
private final String description;
|
||||||
private Map<String, String> labels;
|
private final Map<String, String> labels;
|
||||||
public PostAddVoiceRequest(String name, File[] samples, String description, Map<String, String> labels) {
|
public PostAddVoiceRequest(String name, File[] samples, String description, Map<String, String> labels) {
|
||||||
super("v1/voices/add", CreateVoiceResponse.class);
|
super("v1/voices/add", CreateVoiceResponse.class);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PostEditVoiceRequest extends PostRequest<String> {
|
public class PostEditVoiceRequest extends PostRequest<String> {
|
||||||
private String name;
|
private final String name;
|
||||||
private File[] samples;
|
private final File[] samples;
|
||||||
private String description;
|
private final String description;
|
||||||
private Map<String, String> labels;
|
private final Map<String, String> labels;
|
||||||
public PostEditVoiceRequest(String voiceId, String name, File[] samples, String description, 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);
|
super("v1/voices/" + voiceId + "/edit", String.class);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.andrewcpu.elevenlabs.model.voice.VoiceSettings;
|
|||||||
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
import net.andrewcpu.elevenlabs.requests.PostRequest;
|
||||||
|
|
||||||
public class PostEditVoiceSettingsRequest extends PostRequest<String> {
|
public class PostEditVoiceSettingsRequest extends PostRequest<String> {
|
||||||
private VoiceSettings voiceSettings;
|
private final VoiceSettings voiceSettings;
|
||||||
public PostEditVoiceSettingsRequest(String voiceId, VoiceSettings voiceSettings) {
|
public PostEditVoiceSettingsRequest(String voiceId, VoiceSettings voiceSettings) {
|
||||||
super("v1/voices/" + voiceId + "/settings/edit", String.class);
|
super("v1/voices/" + voiceId + "/settings/edit", String.class);
|
||||||
this.voiceSettings = voiceSettings;
|
this.voiceSettings = voiceSettings;
|
||||||
|
|||||||
@@ -12,16 +12,19 @@ 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.CloseableHttpClient;
|
||||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
||||||
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
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.EntityUtils;
|
||||||
import org.apache.hc.core5.http.io.entity.StringEntity;
|
import org.apache.hc.core5.http.io.entity.StringEntity;
|
||||||
import org.apache.hc.core5.http.message.BasicNameValuePair;
|
import org.apache.hc.core5.http.message.BasicNameValuePair;
|
||||||
import org.apache.hc.core5.net.URIBuilder;
|
import org.apache.hc.core5.net.URIBuilder;
|
||||||
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -47,11 +50,7 @@ public class ElevenNetworkUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String encodeValue(String value) {
|
private static String encodeValue(String value) {
|
||||||
try {
|
return URLEncoder.encode(value, StandardCharsets.UTF_8);
|
||||||
return URLEncoder.encode(value, "UTF-8");
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
throw new RuntimeException("Encoding not supported", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpUriRequestBase getRequest(HttpRequestType type, String path) {
|
public static HttpUriRequestBase getRequest(HttpRequestType type, String path) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package net.andrewcpu.elevenlabs;
|
|||||||
|
|
||||||
|
|
||||||
public class ElevenLabsTest {
|
public class ElevenLabsTest {
|
||||||
public static final String ELEVEN_LABS_API_KEY = System.getenv("ELEVEN_LABS_API_KEY");
|
public static final String ELEVEN_LABS_API_KEY = System.getenv("ELEVENLABS_API_KEY");
|
||||||
public static final String TEST_VOICE = "ZjJOFdM86g4E9U6OhzUo";
|
public static final String TEST_VOICE = "ZjJOFdM86g4E9U6OhzUo";
|
||||||
static {
|
static {
|
||||||
ElevenLabs.setApiKey(ELEVEN_LABS_API_KEY);
|
ElevenLabs.setApiKey(ELEVEN_LABS_API_KEY);
|
||||||
|
|||||||
@@ -16,30 +16,30 @@ public class HistoryTest extends ElevenLabsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetHistory() {
|
public void testGetHistory() {
|
||||||
assertFalse("Failed to get history.", doesThrow(() -> {
|
assertFalse("Failed to get history.", doesThrow(() -> {
|
||||||
ElevenLabs.getHistory();
|
ElevenLabs.getHistoryAPI().getHistory();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetHistoryItem() {
|
public void testGetHistoryItem() {
|
||||||
History history = ElevenLabs.getHistory();
|
History history = ElevenLabs.getHistoryAPI().getHistory();
|
||||||
assertNotNull(history);
|
assertNotNull(history);
|
||||||
List<HistoryItem> items = history.getHistoryItems();
|
List<HistoryItem> items = history.getHistoryItems();
|
||||||
assertNotNull(items);
|
assertNotNull(items);
|
||||||
assertTrue(items.size() != 0);
|
assertTrue(items.size() != 0);
|
||||||
HistoryItem item = history.getHistoryItems().get(0);
|
HistoryItem item = history.getHistoryItems().get(0);
|
||||||
assertFalse("Failed to get history item", doesThrow(() -> {
|
assertFalse("Failed to get history item", doesThrow(() -> {
|
||||||
ElevenLabs.getHistoryItem(item.getHistoryItemId());
|
ElevenLabs.getHistoryAPI().getHistoryItem(item.getHistoryItemId());
|
||||||
}));
|
}));
|
||||||
assertFalse("Failed to download audio history.", doesThrow(() -> {
|
assertFalse("Failed to download audio history.", doesThrow(() -> {
|
||||||
File output = ElevenLabs.getHistoryItemAudio(item.getHistoryItemId());
|
File output = ElevenLabs.getHistoryAPI().getHistoryItemAudio(item.getHistoryItemId());
|
||||||
output.delete();
|
output.delete();
|
||||||
}));
|
}));
|
||||||
assertTrue(items.size() >= 2);
|
assertTrue(items.size() >= 2);
|
||||||
HistoryItem item2 = history.getHistoryItems().get(1);
|
HistoryItem item2 = history.getHistoryItems().get(1);
|
||||||
|
|
||||||
assertFalse("Failed to download audio history (grouped).", doesThrow(() -> {
|
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());
|
System.out.println(output.getName());
|
||||||
output.delete();
|
output.delete();
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class AvailableModelsTest extends ElevenLabsTest {
|
|||||||
public void testGetModels() {
|
public void testGetModels() {
|
||||||
GenerationTypeModel[] models = null;
|
GenerationTypeModel[] models = null;
|
||||||
try{
|
try{
|
||||||
models = ElevenLabs.getAvailableModels();
|
models = ElevenLabs.getModelsAPI().getAvailableModels();
|
||||||
System.out.println(Arrays.stream(models).map(Object::toString).collect(Collectors.toList()));
|
System.out.println(Arrays.stream(models).map(Object::toString).collect(Collectors.toList()));
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -16,18 +16,18 @@ public class AudioSampleTest extends ElevenLabsTest {
|
|||||||
public void testGetAudioSamples() {
|
public void testGetAudioSamples() {
|
||||||
assertFalse("Couldn't load audio samples.", doesThrow(() -> {
|
assertFalse("Couldn't load audio samples.", doesThrow(() -> {
|
||||||
List<Sample> samples = null;
|
List<Sample> samples = null;
|
||||||
samples = ElevenLabs.getVoice(TEST_VOICE, true).getSamples();
|
samples = ElevenLabs.getVoiceAPI().getVoice(TEST_VOICE, true).getSamples();
|
||||||
assertNotNull(samples);
|
assertNotNull(samples);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testGetAudioSample() {
|
public void testGetAudioSample() {
|
||||||
assertFalse("Couldn't load audio sample.", doesThrow(() -> {
|
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 is null!", voice);
|
||||||
assertNotNull("Voice samples are null!", voice.getSamples());
|
assertNotNull("Voice samples are null!", voice.getSamples());
|
||||||
assertTrue("No samples to test!", voice.getSamples().size() != 0);
|
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);
|
assertNotNull(file);
|
||||||
file.delete();
|
file.delete();
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class TextToSpeechTest extends ElevenLabsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testDownloadResponse() {
|
public void testDownloadResponse() {
|
||||||
assertFalse("Cannot download tts!", doesThrow(() -> {
|
assertFalse("Cannot download tts!", doesThrow(() -> {
|
||||||
File file = ElevenLabs.generateTextToSpeech(TEST_VOICE, "This is a test", "eleven_monolingual_v1", new VoiceSettings(0.7, 0.7, 0, true));
|
File file = ElevenLabs.getTextToSpeechAPI().generateTextToSpeech(TEST_VOICE, "This is a test", "eleven_monolingual_v1", new VoiceSettings(0.7, 0.7, 0, true));
|
||||||
file.delete();
|
file.delete();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ public class TextToSpeechTest extends ElevenLabsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testStreamedResponse() {
|
public void testStreamedResponse() {
|
||||||
assertFalse("Cannot strem tts!", doesThrow(() -> {
|
assertFalse("Cannot strem tts!", doesThrow(() -> {
|
||||||
InputStream inputStream = ElevenLabs.generateTextToSpeechStreamed(TEST_VOICE, "This is a test", "eleven_monolingual_v1", new VoiceSettings(0.7, 0.7, 0, true));
|
InputStream inputStream = ElevenLabs.getTextToSpeechAPI().generateTextToSpeechStreamed(TEST_VOICE, "This is a test", "eleven_monolingual_v1", new VoiceSettings(0.7, 0.7, 0, true));
|
||||||
File tmp;
|
File tmp;
|
||||||
try {
|
try {
|
||||||
tmp = File.createTempFile("test", "audio");
|
tmp = File.createTempFile("test", "audio");
|
||||||
|
|||||||
@@ -4,27 +4,26 @@ import net.andrewcpu.elevenlabs.ElevenLabs;
|
|||||||
import net.andrewcpu.elevenlabs.ElevenLabsTest;
|
import net.andrewcpu.elevenlabs.ElevenLabsTest;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class UserTest extends ElevenLabsTest {
|
public class UserTest extends ElevenLabsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetUser() {
|
public void testGetUser() {
|
||||||
try{
|
try{
|
||||||
ElevenLabs.getUser();
|
ElevenLabs.getUserAPI().getUser();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
assertTrue("Failed to get user: " + e.getMessage(), false);
|
fail("Failed to get user: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetSubscription() {
|
public void testGetSubscription() {
|
||||||
try{
|
try{
|
||||||
ElevenLabs.getSubscription();
|
ElevenLabs.getUserAPI().getSubscription();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();
|
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.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
|
|
||||||
public class VoiceTest extends ElevenLabsTest {
|
public class VoiceTest extends ElevenLabsTest {
|
||||||
@@ -22,34 +21,34 @@ public class VoiceTest extends ElevenLabsTest {
|
|||||||
public void testGetVoiceWithSettings() {
|
public void testGetVoiceWithSettings() {
|
||||||
Voice voice = null;
|
Voice voice = null;
|
||||||
try{
|
try{
|
||||||
voice = ElevenLabs.getVoice(ElevenLabsTest.TEST_VOICE, true);
|
voice = ElevenLabs.getVoiceAPI().getVoice(ElevenLabsTest.TEST_VOICE, true);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
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
|
@Test
|
||||||
public void testGetVoiceWithoutSettings() {
|
public void testGetVoiceWithoutSettings() {
|
||||||
Voice voice = null;
|
Voice voice = null;
|
||||||
try{
|
try{
|
||||||
voice = ElevenLabs.getVoice(ElevenLabsTest.TEST_VOICE, false);
|
voice = ElevenLabs.getVoiceAPI().getVoice(ElevenLabsTest.TEST_VOICE, false);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
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
|
@Test
|
||||||
public void testGetVoiceSettings() {
|
public void testGetVoiceSettings() {
|
||||||
VoiceSettings settings = null;
|
VoiceSettings settings = null;
|
||||||
try{
|
try{
|
||||||
settings = ElevenLabs.getVoiceSettings(ElevenLabsTest.TEST_VOICE);
|
settings = ElevenLabs.getVoiceAPI().getVoiceSettings(ElevenLabsTest.TEST_VOICE);
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();
|
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() {
|
public void getDefaultVoiceSettings() {
|
||||||
VoiceSettings defaultVoiceSettings = null;
|
VoiceSettings defaultVoiceSettings = null;
|
||||||
try {
|
try {
|
||||||
defaultVoiceSettings = ElevenLabs.getDefaultVoiceSettings();
|
defaultVoiceSettings = ElevenLabs.getVoiceAPI().getDefaultVoiceSettings();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();
|
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() {
|
public void getVoices() {
|
||||||
List<Voice> voices = null;
|
List<Voice> voices = null;
|
||||||
try{
|
try{
|
||||||
voices = ElevenLabs.getVoices();
|
voices = ElevenLabs.getVoiceAPI().getVoices();
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
e.printStackTrace();;
|
e.printStackTrace();
|
||||||
assertTrue("Failed to get voices: " + e.getMessage(), false);
|
fail("Failed to get voices: " + e.getMessage());
|
||||||
}
|
}
|
||||||
assertTrue(voices != null && voices.size() > 0);
|
assertTrue(voices != null && voices.size() > 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user