diff --git a/Makefile.am b/Makefile.am
index 71bdfb33..89bc9675 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -99,6 +99,7 @@ src_libespeak_ng_la_SOURCES = \
src/libespeak-ng/compiledict.c \
src/libespeak-ng/compilembrola.c \
src/libespeak-ng/dictionary.c \
+ src/libespeak-ng/espeak_api.c \
src/libespeak-ng/ieee80.c \
src/libespeak-ng/intonation.c \
src/libespeak-ng/numbers.c \
diff --git a/src/libespeak-ng/espeak_api.c b/src/libespeak-ng/espeak_api.c
new file mode 100644
index 00000000..db7f48e7
--- /dev/null
+++ b/src/libespeak-ng/espeak_api.c
@@ -0,0 +1,65 @@
+/* An implementation of the eSpeak API using the espeak-ng API.
+ *
+ * Copyright (C) 2016 Reece H. Dunn
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see: .
+ */
+
+#include "config.h"
+
+#include "speak_lib.h"
+#include "espeak_ng.h"
+
+#include
+
+extern int option_phoneme_events; // from translate.h
+
+#pragma GCC visibility push(default)
+
+ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length, const char *path, int options)
+{
+ espeak_ng_InitializePath(path);
+ espeak_ng_STATUS result = espeak_ng_Initialize();
+ if (result != ENS_OK) {
+ if (result == ENS_VERSION_MISMATCH)
+ fprintf(stderr, "Wrong version of espeak-data\n");
+ else {
+ fprintf(stderr, "Failed to load espeak-data\n");
+ if ((options & espeakINITIALIZE_DONT_EXIT) == 0)
+ exit(1);
+ }
+ }
+
+ switch (output_type)
+ {
+ case AUDIO_OUTPUT_PLAYBACK:
+ espeak_ng_InitializeOutput(ENOUTPUT_MODE_SPEAK_AUDIO, buf_length, NULL);
+ break;
+ case AUDIO_OUTPUT_RETRIEVAL:
+ espeak_ng_InitializeOutput(0, buf_length, NULL);
+ break;
+ case AUDIO_OUTPUT_SYNCHRONOUS:
+ espeak_ng_InitializeOutput(ENOUTPUT_MODE_SYNCHRONOUS, buf_length, NULL);
+ break;
+ case AUDIO_OUTPUT_SYNCH_PLAYBACK:
+ espeak_ng_InitializeOutput(ENOUTPUT_MODE_SYNCHRONOUS | ENOUTPUT_MODE_SPEAK_AUDIO, buf_length, NULL);
+ break;
+ }
+
+ option_phoneme_events = (options & (espeakINITIALIZE_PHONEME_EVENTS | espeakINITIALIZE_PHONEME_IPA));
+
+ return espeak_ng_GetSampleRate();
+}
+
+#pragma GCC visibility pop
diff --git a/src/libespeak-ng/speech.c b/src/libespeak-ng/speech.c
index a85b52c9..ac22c468 100644
--- a/src/libespeak-ng/speech.c
+++ b/src/libespeak-ng/speech.c
@@ -639,43 +639,6 @@ ESPEAK_API void espeak_SetPhonemeCallback(int (*PhonemeCallback)(const char *))
phoneme_callback = PhonemeCallback;
}
-ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length, const char *path, int options)
-{
- int param;
-
- espeak_ng_InitializePath(path);
- espeak_ng_STATUS result = espeak_ng_Initialize();
- if (result != ENS_OK) {
- if (result == ENS_VERSION_MISMATCH)
- fprintf(stderr, "Wrong version of espeak-data (expected 0x%x) at %s\n", version_phdata, path_home);
- else {
- fprintf(stderr, "Failed to load espeak-data\n");
- if ((options & espeakINITIALIZE_DONT_EXIT) == 0)
- exit(1);
- }
- }
-
- switch (output_type)
- {
- case AUDIO_OUTPUT_PLAYBACK:
- espeak_ng_InitializeOutput(ENOUTPUT_MODE_SPEAK_AUDIO, buf_length, NULL);
- break;
- case AUDIO_OUTPUT_RETRIEVAL:
- espeak_ng_InitializeOutput(0, buf_length, NULL);
- break;
- case AUDIO_OUTPUT_SYNCHRONOUS:
- espeak_ng_InitializeOutput(ENOUTPUT_MODE_SYNCHRONOUS, buf_length, NULL);
- break;
- case AUDIO_OUTPUT_SYNCH_PLAYBACK:
- espeak_ng_InitializeOutput(ENOUTPUT_MODE_SYNCHRONOUS | ENOUTPUT_MODE_SPEAK_AUDIO, buf_length, NULL);
- break;
- }
-
- option_phoneme_events = (options & (espeakINITIALIZE_PHONEME_EVENTS | espeakINITIALIZE_PHONEME_IPA));
-
- return samplerate;
-}
-
ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size,
unsigned int position,
espeak_POSITION_TYPE position_type,