67 lines
1.8 KiB
Java
67 lines
1.8 KiB
Java
package com.emotion.service;
|
|
|
|
public interface TtsEngineClient {
|
|
|
|
TtsEngineResult synthesize(String text, String voice, String outputPath, SynthesisOptions options);
|
|
|
|
class SynthesisOptions {
|
|
private final Double speechRate;
|
|
private final Double pitch;
|
|
private final String emotion;
|
|
|
|
public SynthesisOptions(Double speechRate, Double pitch, String emotion) {
|
|
this.speechRate = speechRate;
|
|
this.pitch = pitch;
|
|
this.emotion = emotion;
|
|
}
|
|
|
|
public Double getSpeechRate() {
|
|
return speechRate;
|
|
}
|
|
|
|
public Double getPitch() {
|
|
return pitch;
|
|
}
|
|
|
|
public String getEmotion() {
|
|
return emotion;
|
|
}
|
|
|
|
public String cacheKey() {
|
|
return "rate=" + (speechRate == null ? "" : speechRate)
|
|
+ ";pitch=" + (pitch == null ? "" : pitch)
|
|
+ ";emotion=" + (emotion == null ? "" : emotion);
|
|
}
|
|
}
|
|
|
|
class TtsEngineResult {
|
|
private final boolean success;
|
|
private final String audioPath;
|
|
private final Long durationMs;
|
|
private final String errorMessage;
|
|
|
|
public TtsEngineResult(boolean success, String audioPath, Long durationMs, String errorMessage) {
|
|
this.success = success;
|
|
this.audioPath = audioPath;
|
|
this.durationMs = durationMs;
|
|
this.errorMessage = errorMessage;
|
|
}
|
|
|
|
public boolean isSuccess() {
|
|
return success;
|
|
}
|
|
|
|
public String getAudioPath() {
|
|
return audioPath;
|
|
}
|
|
|
|
public Long getDurationMs() {
|
|
return durationMs;
|
|
}
|
|
|
|
public String getErrorMessage() {
|
|
return errorMessage;
|
|
}
|
|
}
|
|
}
|