mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-12-05 08:00:36 +00:00
Implement SpeechSynthesis.getAudioFormat in Java.
This commit is contained in:
@@ -104,33 +104,23 @@ unicode_string::~unicode_string()
|
|||||||
#define LOG_TAG "eSpeakService"
|
#define LOG_TAG "eSpeakService"
|
||||||
#define DEBUG true
|
#define DEBUG true
|
||||||
|
|
||||||
enum audio_encoding {
|
|
||||||
ENCODING_INVALID = 0x00,
|
|
||||||
ENCODING_DEFAULT = 0x01,
|
|
||||||
ENCODING_PCM_16BIT = 0x02,
|
|
||||||
ENCODING_PCM_8BIT = 0x03
|
|
||||||
};
|
|
||||||
|
|
||||||
enum synthesis_result {
|
enum synthesis_result {
|
||||||
SYNTH_CONTINUE = 0,
|
SYNTH_CONTINUE = 0,
|
||||||
SYNTH_ABORT = 1
|
SYNTH_ABORT = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
const int DEFAULT_AUDIO_FORMAT = ENCODING_PCM_16BIT;
|
|
||||||
const int DEFAULT_BUFFER_SIZE = 1000;
|
const int DEFAULT_BUFFER_SIZE = 1000;
|
||||||
|
|
||||||
struct native_data_t {
|
struct native_data_t {
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
jobject object;
|
jobject object;
|
||||||
int sampleRate;
|
int sampleRate;
|
||||||
int audioFormat;
|
|
||||||
int bufferSizeInMillis;
|
int bufferSizeInMillis;
|
||||||
|
|
||||||
native_data_t() {
|
native_data_t() {
|
||||||
env = NULL;
|
env = NULL;
|
||||||
object = NULL;
|
object = NULL;
|
||||||
sampleRate = 0;
|
sampleRate = 0;
|
||||||
audioFormat = DEFAULT_AUDIO_FORMAT;
|
|
||||||
bufferSizeInMillis = DEFAULT_BUFFER_SIZE;
|
bufferSizeInMillis = DEFAULT_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -239,14 +229,6 @@ JNICALL Java_com_reecedunn_espeak_SpeechSynthesis_nativeGetSampleRate(
|
|||||||
return (jint)(nat ? nat->sampleRate : 0);
|
return (jint)(nat ? nat->sampleRate : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint
|
|
||||||
JNICALL Java_com_reecedunn_espeak_SpeechSynthesis_nativeGetAudioFormat(
|
|
||||||
JNIEnv *env, jobject object) {
|
|
||||||
if (DEBUG) LOGV("%s", __FUNCTION__);
|
|
||||||
const native_data_t *nat = getNativeData(env, object);
|
|
||||||
return (jint) nat->audioFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jint
|
JNIEXPORT jint
|
||||||
JNICALL Java_com_reecedunn_espeak_SpeechSynthesis_nativeGetBufferSizeInMillis(
|
JNICALL Java_com_reecedunn_espeak_SpeechSynthesis_nativeGetBufferSizeInMillis(
|
||||||
JNIEnv *env, jobject object) {
|
JNIEnv *env, jobject object) {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class SpeechSynthesis {
|
|||||||
public static final int AGE_OLD = 60;
|
public static final int AGE_OLD = 60;
|
||||||
|
|
||||||
public static final int CHANNEL_COUNT_MONO = 1;
|
public static final int CHANNEL_COUNT_MONO = 1;
|
||||||
|
public static final int FORMAT_PCM_S16 = 2;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("ttsespeak");
|
System.loadLibrary("ttsespeak");
|
||||||
@@ -102,7 +103,7 @@ public class SpeechSynthesis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getAudioFormat() {
|
public int getAudioFormat() {
|
||||||
return nativeGetAudioFormat();
|
return FORMAT_PCM_S16;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBufferSizeInBytes() {
|
public int getBufferSizeInBytes() {
|
||||||
@@ -343,8 +344,6 @@ public class SpeechSynthesis {
|
|||||||
|
|
||||||
private native final int nativeGetSampleRate();
|
private native final int nativeGetSampleRate();
|
||||||
|
|
||||||
private native final int nativeGetAudioFormat();
|
|
||||||
|
|
||||||
private native final int nativeGetBufferSizeInMillis();
|
private native final int nativeGetBufferSizeInMillis();
|
||||||
|
|
||||||
private native final String[] nativeGetAvailableVoices();
|
private native final String[] nativeGetAvailableVoices();
|
||||||
|
|||||||
Reference in New Issue
Block a user