mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-10-31 05:35:35 +00:00
Replace SpeechSynthesis.getBufferSizeInBytes with a constant in the C++ source, specified in the correct units (milliseconds).
This commit is contained in:
@@ -163,7 +163,6 @@ public class SpeechSynthesisTest extends TextToSpeechTestCase
|
||||
assertThat(synth.getSampleRate(), is(22050));
|
||||
assertThat(synth.getChannelCount(), is(1));
|
||||
assertThat(synth.getAudioFormat(), is(AudioFormat.ENCODING_PCM_16BIT));
|
||||
assertThat(synth.getBufferSizeInBytes(), is(22050));
|
||||
}
|
||||
|
||||
public void testJavaToIanaLanguageCode()
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <speak_lib.h>
|
||||
#include <Log.h>
|
||||
|
||||
#define BUFFER_SIZE_IN_MILLISECONDS 1000
|
||||
|
||||
/** @name Java to Wide String Helpers
|
||||
* @brief These are helpers for converting a jstring to wchar_t*.
|
||||
*
|
||||
@@ -163,13 +165,13 @@ JNICALL Java_com_reecedunn_espeak_SpeechSynthesis_nativeClassInit(
|
||||
|
||||
JNIEXPORT jint
|
||||
JNICALL Java_com_reecedunn_espeak_SpeechSynthesis_nativeCreate(
|
||||
JNIEnv *env, jobject object, jstring path, jint bufferSizeInMillis) {
|
||||
JNIEnv *env, jobject object, jstring path) {
|
||||
if (DEBUG) LOGV("%s [env=%p, object=%p]", __FUNCTION__, env, object);
|
||||
|
||||
const char *c_path = path ? env->GetStringUTFChars(path, NULL) : NULL;
|
||||
|
||||
if (DEBUG) LOGV("Initializing with path %s", c_path);
|
||||
int sampleRate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS, bufferSizeInMillis, c_path, 0);
|
||||
int sampleRate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS, BUFFER_SIZE_IN_MILLISECONDS, c_path, 0);
|
||||
|
||||
if (c_path) env->ReleaseStringUTFChars(path, c_path);
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ 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");
|
||||
@@ -103,10 +102,6 @@ public class SpeechSynthesis {
|
||||
return FORMAT_PCM_S16;
|
||||
}
|
||||
|
||||
public int getBufferSizeInBytes() {
|
||||
return (BUFFER_SIZE_IN_MILLIS * mSampleRate) / 1000;
|
||||
}
|
||||
|
||||
private Locale getLocaleFromLanguageName(String name) {
|
||||
if (mLocaleFixes.containsKey(name)) {
|
||||
return mLocaleFixes.get(name);
|
||||
@@ -287,7 +282,7 @@ public class SpeechSynthesis {
|
||||
return;
|
||||
}
|
||||
|
||||
mSampleRate = nativeCreate(mDatapath, BUFFER_SIZE_IN_MILLIS);
|
||||
mSampleRate = nativeCreate(mDatapath);
|
||||
if (mSampleRate == 0) {
|
||||
Log.e(TAG, "Failed to initialize speech synthesis library");
|
||||
return;
|
||||
@@ -312,7 +307,7 @@ public class SpeechSynthesis {
|
||||
|
||||
private static native final boolean nativeClassInit();
|
||||
|
||||
private native final int nativeCreate(String path, int bufferSizeInMillis);
|
||||
private native final int nativeCreate(String path);
|
||||
|
||||
private native final static String nativeGetVersion();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user