- bring in 2 patches from pkgsrc to actually make espeak work live (and

not only be able to save text to speech in wav file)
- rework the src Makefile
- use system portaudio.h instead of the bundled one
This commit is contained in:
ajacoutot 2009-04-16 16:39:17 +00:00
parent 6213d1c830
commit 992a95f9bf
5 changed files with 99 additions and 29 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.3 2009/03/23 12:02:27 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.4 2009/04/16 16:39:17 ajacoutot Exp $
COMMENT= compact speech synthesizer
DISTNAME= espeak-1.40.02-source
PKGNAME= ${DISTNAME:S/-source//}
PKGNAME= ${DISTNAME:S/-source//}p0
SHARED_LIBS= espeak 0.0
CATEGORIES= audio devel
@ -39,7 +39,7 @@ MAKE_FLAGS += EXTRA_FLAGS="-fPIC"
SUBST_VARS= PREFIX LIBespeak_VERSION
post-extract:
@cp ${WRKSRC}/portaudio19.h ${WRKSRC}/portaudio.h
@cp ${LOCALBASE}/include/portaudio.h ${WRKSRC}/portaudio.h
pre-configure:
${SUBST_CMD} ${WRKSRC}/speech.h ${WRKSRC}/Makefile

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-src_Makefile,v 1.4 2009/03/23 12:02:28 ajacoutot Exp $
--- src/Makefile.orig Mon Mar 23 12:36:15 2009
+++ src/Makefile Mon Mar 23 12:39:29 2009
$OpenBSD: patch-src_Makefile,v 1.5 2009/04/16 16:39:17 ajacoutot Exp $
--- src/Makefile.orig Mon Dec 22 23:37:41 2008
+++ src/Makefile Thu Apr 16 18:33:32 2009
@@ -1,6 +1,5 @@
# remove -fno-exceptions if it causes problems with stdio library on some platforms (ARM)
@ -22,22 +22,31 @@ $OpenBSD: patch-src_Makefile,v 1.4 2009/03/23 12:02:28 ajacoutot Exp $
# Use SONAME_OPT=-Wl,h, on Solaris
SONAME_OPT=-Wl,-soname,
@@ -35,7 +36,7 @@ USE_AUDIO=-DUSE_PULSEAUDIO
else
ifeq ($(AUDIO),portaudio)
WAVE=wave.cpp
-LIB_AUDIO=-lportaudio
+LIB_AUDIO=-L$(LOCALBASE)/lib -lportaudio
USE_AUDIO=-DUSE_PORTAUDIO
else
ifeq ($(AUDIO),sada)
@@ -60,27 +61,25 @@ libespeak_SOURCES = speak_lib.cpp compiledict.cpp dict
SRCS1=$(speak_SOURCES)
OBJS1=$(patsubst %.cpp,%.o,$(SRCS1))
-LIBS1=-lstdc++ $(LIB_AUDIO) -lpthread $(EXTRA_LIBS)
+LIBS1=-lstdc++ $(LPATH) -lportaudio -pthread
+LIBS1=-lstdc++ $(LIB_AUDIO) -pthread $(EXTRA_LIBS)
SRCS2=$(libespeak_SOURCES)
OBJS2=$(patsubst %.cpp,x_%.o,$(SRCS2))
-LIBS2=-lstdc++ $(LIB_AUDIO) -lpthread
+LIBS2=-lstdc++ $(LPATH) -lportaudio -pthread
+LIBS2=-lstdc++ $(LPATH) $(LIB_AUDIO) -pthread
SRCS3 = espeak.cpp
OBJS3=$(patsubst %.cpp,%.o,$(SRCS3))
-LIBS3=-lstdc++ -L . -lespeak
+LIBS3=-lstdc++ -L . -lespeak $(LPATH) -lportaudio -pthread
+LIBS3=-lstdc++ -L . -lespeak $(LPATH) -pthread
-CXXFLAGS=-O2
@ -47,7 +56,7 @@ $OpenBSD: patch-src_Makefile,v 1.4 2009/03/23 12:02:28 ajacoutot Exp $
.cpp.o:
- $(CXX) $(CXXFLAGS) $(USE_AUDIO) -D PATH_ESPEAK_DATA=\"$(DATADIR)\" -Wall -pedantic -I. -c -fno-exceptions $<
+ $(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) $(USE_AUDIO) -D PATH_ESPEAK_DATA=\"$(DATADIR)\" -Wall -pedantic -I. -c -fno-exceptions $<
+ $(CXX) $(CXXFLAGS) -pthread $(USE_AUDIO) -D PATH_ESPEAK_DATA=\"$(DATADIR)\" -Wall -pedantic -I. -c -fno-exceptions $<
$(BIN_NAME): $(OBJS1)
- $(CXX) -o $@ $(OBJS1) $(LIBS1)
@ -61,7 +70,7 @@ $OpenBSD: patch-src_Makefile,v 1.4 2009/03/23 12:02:28 ajacoutot Exp $
x_%.o: %.cpp
- $(CXX) $(CXXFLAGS) $(USE_AUDIO) -Wall -fpic -fvisibility=hidden -pedantic \
- -I. -D LIBRARY -c -fno-exceptions $< -o x_$*.o
+ $(CXX) $(CXXFLAGS) $(USE_AUDIO) -Wall -fPIC -DPIC -pedantic \
+ $(CXX) $(CXXFLAGS) -pthread $(USE_AUDIO) -Wall -fpic -pedantic \
+ -I. -DLIBRARY -DPATH_ESPEAK_DATA=\"$(DATADIR)\" -c -fno-exceptions $< -o x_$*.o
$(LIB_NAME): $(OBJS2)
@ -70,3 +79,10 @@ $OpenBSD: patch-src_Makefile,v 1.4 2009/03/23 12:02:28 ajacoutot Exp $
$(STATIC_LIB_NAME): $(OBJS2)
$(AR) cqs $(STATIC_LIB_NAME) $(OBJS2)
@@ -123,5 +122,5 @@ install: all
# Install development headers
$(INSTALL) -pm 644 speak_lib.h $(DESTDIR)$(INCDIR)
# Install data files
- cp -prf ../espeak-data/* $(DESTDIR)$(DATADIR)
+ cp -pRf ../espeak-data/* $(DESTDIR)$(DATADIR)

View File

@ -0,0 +1,34 @@
$OpenBSD: patch-src_event_cpp,v 1.1 2009/04/16 16:39:17 ajacoutot Exp $
--- src/event.cpp.orig Mon Dec 22 23:36:40 2008
+++ src/event.cpp Thu Apr 16 18:20:56 2009
@@ -40,6 +40,12 @@
//>
//<decls and function prototypes
+#ifndef timespeccmp
+#define timespeccmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#endif
// my_mutex: protects my_thread_is_talking,
static pthread_mutex_t my_mutex;
@@ -400,10 +406,14 @@ ENTER("sleep_until_timeout_or_stop_request");
to.tv_sec, to.tv_nsec,
ts.tv_sec, ts.tv_nsec);
- while ((err = sem_timedwait(&my_sem_stop_is_required, &ts)) == -1
- && errno == EINTR)
+ while ((err = sem_trywait(&my_sem_stop_is_required)) == -1
+ && (errno == EINTR || errno == EAGAIN))
{
- continue; // Restart when interrupted by handler
+ struct timespec help;
+ clock_gettime2(&help);
+ if (timespeccmp(&help, &ts, >=))
+ break;
+ sched_yield();
}
assert (gettimeofday(&tv, NULL) != -1);

View File

@ -0,0 +1,34 @@
$OpenBSD: patch-src_fifo_cpp,v 1.1 2009/04/16 16:39:17 ajacoutot Exp $
--- src/fifo.cpp.orig Mon Dec 22 23:36:40 2008
+++ src/fifo.cpp Thu Apr 16 18:20:58 2009
@@ -39,6 +39,12 @@
#include "wave.h"
#include "debug.h"
+#ifndef timespeccmp
+#define timespeccmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#endif
//>
//<decls and function prototypes
@@ -306,10 +312,14 @@ static int sleep_until_start_request_or_inactivity()
to.tv_sec, to.tv_nsec,
ts.tv_sec, ts.tv_nsec);
- while ((err = sem_timedwait(&my_sem_start_is_required, &ts)) == -1
- && errno == EINTR)
+ while ((err = sem_trywait(&my_sem_start_is_required)) == -1
+ && (errno == EINTR || errno == EAGAIN))
{
- continue;
+ struct timespec help;
+ clock_gettime2(&help);
+ if (timespeccmp(&help, &ts, >=))
+ break;
+ sched_yield();
}
assert (gettimeofday(&tv, NULL) != -1);

View File

@ -1,24 +1,10 @@
$OpenBSD: patch-src_speech_h,v 1.2 2009/03/23 12:02:28 ajacoutot Exp $
$OpenBSD: patch-src_speech_h,v 1.3 2009/04/16 16:39:17 ajacoutot Exp $
- Don't define USE_ASYNC, this required sem_timedwait() to be present.
--- src/speech.h.orig Mon Dec 22 23:36:40 2008
+++ src/speech.h Mon Mar 23 12:39:44 2009
@@ -37,19 +37,19 @@
#define ESPEAK_API extern "C"
#ifdef LIBRARY
-#define USE_ASYNC
+//#define USE_ASYNC
//#define USE_MBROLA_LIB
#endif
#ifdef _ESPEAKEDIT
#define USE_PORTAUDIO
-#define USE_ASYNC
+//#define USE_ASYNC
#define LOG_FRAMES // write keyframe info to log-espeakedit
#endif
--- src/speech.h.orig Thu Apr 16 18:19:43 2009
+++ src/speech.h Thu Apr 16 18:20:03 2009
@@ -49,7 +49,7 @@
// will look for espeak_data directory here, and also in user's home directory
#ifndef PATH_ESPEAK_DATA