@@ -427,70 +427,59 @@ AS_IF([test $with_kali != no], [output_modules="${output_modules} kali"])
427427
428428# check for piper support
429429AC_ARG_WITH ( [ piper] ,
430- [ AS_HELP_STRING ( [ --with-piper= /path] , [ include Piper support] ) ] ,
430+ [ AS_HELP_STRING ( [ --with-piper[ [ =yes|no|check| /path] ] ] , [ include Piper TTS support] ) ] ,
431431 [ ] ,
432- [ with_piper=no] )
433- AS_IF ( [ test $with_espeak = yes -a $with_piper != no] , [
434- # We currently need various headers of piper
435- PIPER_SRC_DIR="$with_piper/src/cpp"
432+ [ with_piper=check] )
433+
434+ AS_IF ( [ test "$with_piper" != "no"] , [
435+ PIPER_CFLAGS=""
436+ PIPER_LIBS=""
437+ AS_IF ( [ test "$with_piper" != "yes" -a "$with_piper" != "check"] , [
438+ PIPER_CFLAGS="-I$with_piper/include"
439+ PIPER_LIBS="-L$with_piper/lib -lpiper"
440+ ] )
436441 OLDCXXFLAGS="$CXXFLAGS"
437442 OLDLDFLAGS="$LDFLAGS"
438- CXXFLAGS="$CXXFLAGS -I$PIPER_SRC_DIR"
439-
440- AS_IF ( [ test $with_piper != no] ,
441- [ PKG_CHECK_MODULES([ ONNXRUNTIME] , [ libonnxruntime] , [
442- CXXFLAGS="$CXXFLAGS $ONNXRUNTIME_CFLAGS"
443- LDFLAGS="$LDFLAGS $ONNXRUNTIME_LIBS"
444- ] , [ AC_CHECK_LIB ( [ onnxruntime] , [ OrtGetApiBase] ,
445- [ ONNXRUNTIME_LIBS="-lonnxruntime"] ,
446- [ with_piper=no] )
447- ] )] )
448-
449- AS_IF ( [ test $with_piper != no] ,
450- [ PKG_CHECK_MODULES([ RUBBERBAND] , [ rubberband] , [
451- CXXFLAGS="$CXXFLAGS $RUBBERBAND_CFLAGS"
452- LDFLAGS="$LDFLAGS $RUBBERBAND_LIBS"
453- ] , [ with_piper=no] )] )
443+ OLDLIBS="$LIBS"
444+ CXXFLAGS="$CXXFLAGS $PIPER_CFLAGS"
445+ LDFLAGS="$LDFLAGS $PIPER_LIBS"
454446
455447 AC_LANG_PUSH ( C++ )
456- AS_IF ( [ test $with_piper != no] ,
457- [ AC_CHECK_LIB ( [ piper_phonemize] , [ _ZN5piper19DEFAULT_PHONEME_MAPB5cxx11E] ,
458- [ :] ,
459- [ with_piper=no] ) ] )
460-
461- AS_IF ( [ test $with_piper != no] ,
462- [ AC_CHECK_HEADER ( [ json.hpp] ,
463- [ ] ,
464- [ with_piper=no] ) ] )
465- AS_IF ( [ test $with_piper != no] ,
466- [ AC_CHECK_HEADER ( [ piper.hpp] ,
467- [ ] ,
468- [ with_piper=no] ) ] )
469- AS_IF ( [ test $with_piper != no] ,
470- [ AC_CHECK_HEADER ( [ utf8.h] ,
471- [ ] ,
472- [ with_piper=no] ) ] )
473- AS_IF ( [ test $with_piper != no] ,
474- [ AC_CHECK_HEADER ( [ wavfile.hpp] ,
475- [ ] ,
476- [ with_piper=no] ) ] )
477-
478- AS_IF ( [ test $with_piper != no] ,
479- # We need espeak with https://github.com/espeak-ng/espeak-ng/pull/2127 applied
480- [ AC_CHECK_LIB ( [ espeak-ng] , [ espeak_TextToPhonemesWithTerminator] ,
481- [ :] ,
482- [ with_piper=no] ,
483- [ $ESPEAK_NG_LIBS] ) ] )
484-
448+ # Check for piper.h header
449+ AC_CHECK_HEADER ( [ piper.h] , [ have_piper_h=yes] , [ have_piper_h=no] )
450+ # Check for libpiper library
451+ AC_CHECK_LIB ( [ piper] , [ piper_create] , [ have_libpiper=yes] , [ have_libpiper=no] )
452+ # Check for nlohmann json
453+ AC_CHECK_HEADER ( [ nlohmann/json.hpp] , [ have_json_h=yes] , [
454+ AC_CHECK_HEADER ( [ json.hpp] , [ have_json_h=yes] , [ have_json_h=no] )
455+ ] )
485456 AC_LANG_POP ( C++ )
457+
486458 CXXFLAGS="$OLDCXXFLAGS"
487459 LDFLAGS="$OLDLDFLAGS"
460+ LIBS="$OLDLIBS"
461+
462+ AS_IF ( [ test "$have_piper_h" = "yes" -a "$have_libpiper" = "yes" -a "$have_json_h" = "yes"] , [
463+ PKG_CHECK_MODULES([ RUBBERBAND] , [ rubberband] , [
464+ AS_IF ( [ test -z "$PIPER_LIBS"] , [ PIPER_LIBS="-lpiper"] )
465+ with_piper=yes
466+ ] , [
467+ AS_IF ( [ test "$with_piper" = "yes"] , [
468+ AC_MSG_FAILURE ( [ rubberband is required for piper] )
469+ ] )
470+ with_piper=no
471+ ] )
472+ ] , [
473+ AS_IF ( [ test "$with_piper" = "yes"] , [
474+ AC_MSG_FAILURE ( [ libpiper (piper.h, libpiper, and json.hpp) is not available] )
475+ ] )
476+ with_piper=no
477+ ] )
488478] )
489- AM_CONDITIONAL([ piper_support] , [ test $with_piper != no] )
490- AS_IF ( [ test $with_piper != no] , [ output_modules="${output_modules} cxxpiper"] )
491- AC_SUBST ( [ PIPER_SRC_DIR] )
492- AC_SUBST ( [ ONNXRUNTIME_CFLAGS] )
493- AC_SUBST ( [ ONNXRUNTIME_LIBS] )
479+ AM_CONDITIONAL([ piper_support] , [ test "$with_piper" = "yes"] )
480+ AS_IF ( [ test "$with_piper" = "yes"] , [ output_modules="${output_modules} piper"] )
481+ AC_SUBST ( [ PIPER_CFLAGS] )
482+ AC_SUBST ( [ PIPER_LIBS] )
494483AC_SUBST ( [ RUBBERBAND_CFLAGS] )
495484AC_SUBST ( [ RUBBERBAND_LIBS] )
496485
0 commit comments