Implement SpeechSynthesis.getBufferSizeInMillis in Java.

This commit is contained in:
Reece H. Dunn
2015-10-07 20:57:51 +01:00
parent 92ac250ddd
commit 46c5f88c6f
2 changed files with 6 additions and 19 deletions
@@ -51,6 +51,7 @@ public class SpeechSynthesis {
public static final int CHANNEL_COUNT_MONO = 1;
public static final int FORMAT_PCM_S16 = 2;
public static final int BUFFER_SIZE_IN_MILLIS = 1000;
static {
System.loadLibrary("ttsespeak");
@@ -107,7 +108,7 @@ public class SpeechSynthesis {
}
public int getBufferSizeInBytes() {
final int bufferSizeInMillis = nativeGetBufferSizeInMillis();
final int bufferSizeInMillis = BUFFER_SIZE_IN_MILLIS;
final int sampleRate = nativeGetSampleRate();
return (bufferSizeInMillis * sampleRate) / 1000;
}
@@ -310,7 +311,7 @@ public class SpeechSynthesis {
return;
}
if (!nativeCreate(mDatapath)) {
if (!nativeCreate(mDatapath, BUFFER_SIZE_IN_MILLIS)) {
Log.e(TAG, "Failed to initialize speech synthesis library");
return;
}
@@ -336,7 +337,7 @@ public class SpeechSynthesis {
private static native final boolean nativeClassInit();
private native final boolean nativeCreate(String path);
private native final boolean nativeCreate(String path, int bufferSizeInMillis);
private native final boolean nativeDestroy();
@@ -344,8 +345,6 @@ public class SpeechSynthesis {
private native final int nativeGetSampleRate();
private native final int nativeGetBufferSizeInMillis();
private native final String[] nativeGetAvailableVoices();
private native final boolean nativeSetVoiceByName(String name);