Browse Source

Implement SpeechSynthesis.getChannelCount in Java.

master
Reece H. Dunn 9 years ago
parent
commit
c62a91fc0f

+ 0
- 16
android/jni/jni/eSpeakService.cpp View File

#define LOG_TAG "eSpeakService" #define LOG_TAG "eSpeakService"
#define DEBUG true #define DEBUG true


enum audio_channel_count {
CHANNEL_COUNT_MONO = 1,
CHANNEL_COUNT_STEREO = 2
};

enum audio_encoding { enum audio_encoding {
ENCODING_INVALID = 0x00, ENCODING_INVALID = 0x00,
ENCODING_DEFAULT = 0x01, ENCODING_DEFAULT = 0x01,
SYNTH_ABORT = 1 SYNTH_ABORT = 1
}; };


const int DEFAULT_CHANNEL_COUNT = CHANNEL_COUNT_MONO;
const int DEFAULT_AUDIO_FORMAT = ENCODING_PCM_16BIT; const int DEFAULT_AUDIO_FORMAT = ENCODING_PCM_16BIT;
const int DEFAULT_BUFFER_SIZE = 1000; const int DEFAULT_BUFFER_SIZE = 1000;


JNIEnv *env; JNIEnv *env;
jobject object; jobject object;
int sampleRate; int sampleRate;
int channelCount;
int audioFormat; int audioFormat;
int bufferSizeInMillis; int bufferSizeInMillis;


env = NULL; env = NULL;
object = NULL; object = NULL;
sampleRate = 0; sampleRate = 0;
channelCount = DEFAULT_CHANNEL_COUNT;
audioFormat = DEFAULT_AUDIO_FORMAT; audioFormat = DEFAULT_AUDIO_FORMAT;
bufferSizeInMillis = DEFAULT_BUFFER_SIZE; bufferSizeInMillis = DEFAULT_BUFFER_SIZE;
} }
return (jint)(nat ? nat->sampleRate : 0); return (jint)(nat ? nat->sampleRate : 0);
} }


JNIEXPORT jint
JNICALL Java_com_reecedunn_espeak_SpeechSynthesis_nativeGetChannelCount(
JNIEnv *env, jobject object) {
if (DEBUG) LOGV("%s", __FUNCTION__);
const native_data_t *nat = getNativeData(env, object);
return (jint) nat->channelCount;
}

JNIEXPORT jint JNIEXPORT jint
JNICALL Java_com_reecedunn_espeak_SpeechSynthesis_nativeGetAudioFormat( JNICALL Java_com_reecedunn_espeak_SpeechSynthesis_nativeGetAudioFormat(
JNIEnv *env, jobject object) { JNIEnv *env, jobject object) {

+ 3
- 3
android/src/com/reecedunn/espeak/SpeechSynthesis.java View File

public static final int AGE_YOUNG = 12; public static final int AGE_YOUNG = 12;
public static final int AGE_OLD = 60; public static final int AGE_OLD = 60;


public static final int CHANNEL_COUNT_MONO = 1;

static { static {
System.loadLibrary("ttsespeak"); System.loadLibrary("ttsespeak");


} }


public int getChannelCount() { public int getChannelCount() {
return nativeGetChannelCount(); return CHANNEL_COUNT_MONO;
} }


public int getAudioFormat() { public int getAudioFormat() {


private native final int nativeGetSampleRate(); private native final int nativeGetSampleRate();


private native final int nativeGetChannelCount();

private native final int nativeGetAudioFormat(); private native final int nativeGetAudioFormat();


private native final int nativeGetBufferSizeInMillis(); private native final int nativeGetBufferSizeInMillis();

Loading…
Cancel
Save