mirror of
https://github.com/Andrewcpu/elevenlabs-api.git
synced 2026-05-06 03:00:23 -04:00
32 lines
1.8 KiB
Java
32 lines
1.8 KiB
Java
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)));
|
|
}
|
|
|
|
}
|