Skip to content

Commit

Permalink
Merge pull request #46 from tryolabs/development
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
Bruno Berisso committed May 18, 2018
2 parents 3ce7254 + 321f352 commit e2fafa5
Show file tree
Hide file tree
Showing 63 changed files with 3,227 additions and 1,620 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -12,12 +12,14 @@ build/
*.perspectivev3
!default.perspectivev3
xcuserdata
xcshareddata
*.xccheckout
profile
*.moved-aside
DerivedData
*.hmap
*.ipa
.LSOverride

# Bundler
.bundle
Expand Down
30 changes: 30 additions & 0 deletions Sphinx/LICENSE
@@ -0,0 +1,30 @@
Copyright (c) 1999-2016 Carnegie Mellon University. All rights
reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.

This work was supported in part by funding from the Defense Advanced
Research Projects Agency and the National Science Foundation of the
United States of America, and the CMU Sphinx Speech Consortium.

THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91 changes: 91 additions & 0 deletions Sphinx/builder/README.md
@@ -0,0 +1,91 @@

# CMU SphinxBase and PocketSphinx Builder

> **DISCLAIMER**: TLSphinx comes with pre-bundled sphinxbase and pocketsphinx
> libraries and headers, you're **strongly** encouraged to use those instead of
> building them on your own.
These are the CMU sphinxbase and pocketsphinx building instructions for TLSphinx, follow the guide below to build the required libraries for TLSphinx to build.

In order to build sphinxbase and pocketsphinx both packages need to be downloaded, see: [CMUSphinx Downloads](https://cmusphinx.github.io/wiki/download/).

From there you need to download:

* [sphinxbase-5prealpha](http://sourceforge.net/projects/cmusphinx/files/sphinxbase/5prealpha)
* [pocketsphinx-5prealpha](http://sourceforge.net/projects/cmusphinx/files/pocketsphinx/5prealpha)

After downloading both files copy them to `Sphinx/builder/cmusphinx`

## Automatic Compilation
After copying the files to the appropiate directory (*see above*) just run the install.sh script and with some luck you're done.

```
cd Sphinx/builder/
./install.sh
```


---
## Manual Compilation
If possible please try automatic compilation when possible, manual compilation is not for the feint of heart yet it might help in scenarios where you want to build CMU Sphinx Base and Pocket Sphinx from their respective master branches.

Below are sample instructions on how to manually build the **5prealpha** release, to build against the lastest source just modify each command accordingly.
### Sphinxbase
---
#### To prepare build environment:
```
#From TLSphinx root directory
cd Sphinx/builder/cmusphinx
tar zxvf sphinxbase-5prealpha.tar.gz
cp ../ios-build-sphinxbase.sh sphinxbase-5prealpha/
```
#### To build:
```
SPHINX_VERSION_REQ=5prealpha
cd sphinxbase-5prealpha
./ios-build-sphinxbase.sh
```
#### Install Libraries:
```
cp bin/arm64/lib/libsphinx*.a ../../../lib/sphinxbase/arm64/
cp bin/armv7/lib/libsphinx*.a ../../../lib/sphinxbase/armv7/
cp bin/armv7s/lib/libsphinx*.a ../../../lib/sphinxbase/armv7s/
cp bin/i386/lib/libsphinx*.a ../../../lib/sphinxbase/i386/
cp bin/x86_64/lib/libsphinx*.a ../../../lib/sphinxbase/x86_64/
cp bin/libsphinxad.a ../../../lib/sphinxbase/
cp bin/libsphinxbase.a ../../../lib/sphinxbase/
```
#### Install Headers
```
cp include/sphinxbase/ ../../../include/sphinxbase/
cp include/sphinx_config.h ../../../include/sphinxbase/
```

### PocketSphinx
---
#### To prepare build environment:
```
#From TLSphinx root directory
cd Sphinx/builder/cmusphinx
tar zxvf pocketsphinx-5prealpha.tar.gz
cp ../ios-build-pocketsphinx.sh pocketsphinx-5prealpha/
```
#### To build:
```
SPHINX_VERSION_REQ=5prealpha
cd pocketsphinx-5prealpha
./ios-build-pocketsphinx.sh
```
#### Install Libraries:
```
cp bin/arm64/lib/libpocketsphinx.a ../../../lib/pocketsphinx/arm64/
cp bin/armv7/lib/libpocketsphinx.a ../../../lib/pocketsphinx/armv7/
cp bin/armv7s/lib/libpocketsphinx.a ../../../lib/pocketsphinx/armv7s/
cp bin/i386/lib/libpocketsphinx.a ../../../lib/pocketsphinx/i386/
cp bin/x86_64/lib/libpocketsphinx.a ../../../lib/pocketsphinx/x86_64/
cp bin/libpocketsphinx.a ../../../lib/pocketsphinx/
```
#### Install Headers
```
cp -vf include/*.h ../../../include/pocketsphinx/
```
2 changes: 2 additions & 0 deletions Sphinx/builder/cmusphinx/.gitignore
@@ -0,0 +1,2 @@
*.tar.gz
*sphinx*/
4 changes: 4 additions & 0 deletions Sphinx/builder/cmusphinx/README.md
@@ -0,0 +1,4 @@
Yes this is the directory where you should put

* pocketsphinx-5prealpha.tar.gz
* sphinxbase-5prealpha.tar.Igz
81 changes: 81 additions & 0 deletions Sphinx/builder/install.sh
@@ -0,0 +1,81 @@
#!/bin/sh
SPHINX_VERSION_REQ=5prealpha
SPHINXBASE_RELEASE=sphinxbase-${SPHINX_VERSION_REQ}
POCKETSPHINX_RELEASE=pocketsphinx-${SPHINX_VERSION_REQ}
export SPHINX_VERSION_REQ

SPHINXBASE_PKG=${SPHINXBASE_RELEASE}.tar.gz
POCKETSPHINX_PKG=${POCKETSPHINX}.tar.gz

#Check Sphinx libraries are in place
if [ ! -f `pwd`/cmusphinx/${SPHINXBASE_RELEASE}.tar.gz ]; then
echo "Please follow the readme instrunctions on how to download ${SPHINXBASE_PKG}"
exit 1
fi

if [ ! -f `pwd`/cmusphinx/${POCKETSPHINX_RELEASE}.tar.gz ]; then
echo "Please follow the readme instrunctions on how to download ${POCKETSPHINX_PKG}"
exit 1
fi

cd cmusphinx
rm -f build.log > /dev/null 2>&1

for SPHINX_PROJECT in ${SPHINXBASE_RELEASE} ${POCKETSPHINX_RELEASE}
do
#Delete previous build directory if found
if [ -d ${SPHINX_PROJECT} ]; then
rm -rf ${SPHINX_PROJECT}
fi
tarfile=${SPHINX_PROJECT}.tar.gz
echo "Decompressing ${tarfile}..."
tar zxf $tarfile || exit 1
done

#Copy build scripts
cp -f ../ios-build-sphinxbase.sh ${SPHINXBASE_RELEASE}/
cp -f ../ios-build-pocketsphinx.sh ${POCKETSPHINX_RELEASE}/

#Compile SphinxBase
cd $SPHINXBASE_RELEASE
./ios-build-sphinxbase.sh || exit 1
cd ..
#Compile PocketSphinx
cd $POCKETSPHINX_RELEASE
./ios-build-pocketsphinx.sh || exit 1
cd ..

#rm -rf ../../../lib/*sphinx*
#rm -rf ../../../include/*sphinx*

cd $SPHINXBASE_RELEASE
echo
echo "Installing SphinxBase libraries..."
cp -f bin/arm64/lib/libsphinx*.a ../../../lib/sphinxbase/arm64/ &&
cp -f bin/armv7/lib/libsphinx*.a ../../../lib/sphinxbase/armv7/ &&
cp -f bin/armv7s/lib/libsphinx*.a ../../../lib/sphinxbase/armv7s/ &&
cp -f bin/i386/lib/libsphinx*.a ../../../lib/sphinxbase/i386/ &&
cp -f bin/x86_64/lib/libsphinx*.a ../../../lib/sphinxbase/x86_64/ &&
cp -f bin/libsphinxad.a ../../../lib/sphinxbase/ &&
cp -f bin/libsphinxbase.a ../../../lib/sphinxbase/ || exit 1
echo
echo "Installing SphinxBase header..."
cp -f include/sphinxbase/*.h ../../../include/sphinxbase/ &&
cp -f include/sphinx_config.h ../../../include/sphinxbase/ || exit 1
cd ..

cd $POCKETSPHINX_RELEASE
echo
echo "Installing PocketSphinx libraries..."
cp -f bin/arm64/lib/libpocketsphinx.a ../../../lib/pocketsphinx/arm64/ &&
cp -f bin/armv7/lib/libpocketsphinx.a ../../../lib/pocketsphinx/armv7/ &&
cp -f bin/armv7s/lib/libpocketsphinx.a ../../../lib/pocketsphinx/armv7s/ &&
cp -f bin/i386/lib/libpocketsphinx.a ../../../lib/pocketsphinx/i386/ &&
cp -f bin/x86_64/lib/libpocketsphinx.a ../../../lib/pocketsphinx/x86_64/ &&
cp -f bin/libpocketsphinx.a ../../../lib/pocketsphinx/ || exit 1
echo
echo "Installing PocketSphinx headers..."
cp -vf include/*.h ../../../include/pocketsphinx/ || exit 1

cd ..
echo Done
79 changes: 79 additions & 0 deletions Sphinx/builder/ios-build-pocketsphinx.sh
@@ -0,0 +1,79 @@
#!/bin/sh

SCRATCH="scratch"
DEST=`pwd`/"bin"

ARCHS="arm64 armv7 armv7s x86_64 i386"

if [ "$*" ]
then
ARCHS="$*"
fi

if [ "${SPHINX_VERSION_REQ}" != "" ]; then
SPHINX_VERSION_SUFFIX="-${SPHINX_VERSION_REQ}"
fi

CWD=`pwd`

for ARCH in $ARCHS
do
SPHINXBASE_DIR=`pwd`/../sphinxbase${SPHINX_VERSION_SUFFIX}/bin/$ARCH
echo "building $ARCH..."
mkdir -p "$SCRATCH/$ARCH"
cd "$SCRATCH/$ARCH"

MIN_IOS_VERSION="8.0"
if [[ "${ARCH}" == "arm64" || "${ARCH}" == "x86_64" ]]; then
MIN_IOS_VERSION="7.0" # 7.0 as this is the minimum for these architectures
fi

if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
IOS_CFLAGS="-arch $ARCH -mios-simulator-version-min=$MIN_IOS_VERSION"
else
PLATFORM="iPhoneOS"
IOS_CFLAGS="-arch $ARCH -mios-version-min=$MIN_IOS_VERSION -fembed-bitcode"
fi

HOST_TYPE="${ARCH}-apple-darwin"
if [ "${ARCH}" == "arm64" ]; then
# Fix unknown type for arm64 cpu (which is aarch64)
HOST_TYPE="aarch64-apple-darwin"
fi

export DEVELOPER=`xcode-select --print-path`
export DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export SDKROOT="${DEVROOT}/SDKs/${PLATFORM}${IPHONE_SDK}.sdk"
export CC=`xcrun -find clang`
export LD=`xcrun -find ld`
export CFLAGS="-O3 ${IOS_CFLAGS} -isysroot ${SDKROOT}"
export LDFLAGS="${IOS_CFLAGS} -isysroot ${SDKROOT}"
export CPPFLAGS="${CFLAGS}"

$CWD/configure \
--host="${HOST_TYPE}" \
--prefix="$DEST/$ARCH" \
--without-lapack \
--without-python \
--with-sphinxbase="$SPHINXBASE_DIR" \
|| exit 1

make -j3 install || exit 1
cd $CWD
done

PROJECT=pocketsphinx

if [ ! "$*" ]
then
LIPO_ARGS="-output $DEST/lib$PROJECT.a"
for ARCH in $ARCHS
do
LIPO_ARGS="$LIPO_ARGS $DEST/$ARCH/lib/lib$PROJECT.a"
done
lipo -create $LIPO_ARGS || exit 1
fi

echo Done
89 changes: 89 additions & 0 deletions Sphinx/builder/ios-build-sphinxbase.sh
@@ -0,0 +1,89 @@
#!/bin/sh

SCRATCH="scratch"
DEST=`pwd`/"bin"

ARCHS="arm64 armv7 armv7s x86_64 i386"

if [ "$*" ]
then
ARCHS="$*"
fi

if [ "${SPHINX_VERSION_REQ}" != "" ]; then
SPHINX_PKG_SUFFIX="-${SPHINX_VERSION_REQ}"
fi

CWD=`pwd`

for ARCH in $ARCHS
do
SPHINXBASE_DIR=`pwd`/../sphinxbase${SPHINX_VERSION_SUFFIX}/bin/$ARCH
echo "building $ARCH..."
mkdir -p "$SCRATCH/$ARCH"
cd "$SCRATCH/$ARCH"

MIN_IOS_VERSION="8.0"
if [[ "${ARCH}" == "arm64" || "${ARCH}" == "x86_64" ]]; then
MIN_IOS_VERSION="7.0" # 7.0 as this is the minimum for these architectures
fi

if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
IOS_CFLAGS="-arch $ARCH -mios-simulator-version-min=$MIN_IOS_VERSION"
else
PLATFORM="iPhoneOS"
IOS_CFLAGS="-arch $ARCH -mios-version-min=$MIN_IOS_VERSION -fembed-bitcode"
fi

HOST_TYPE="${ARCH}-apple-darwin"
if [ "${ARCH}" == "arm64" ]; then
# Fix unknown type for arm64 cpu (which is aarch64)
HOST_TYPE="aarch64-apple-darwin"
fi

export DEVELOPER=`xcode-select --print-path`
export DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export SDKROOT="${DEVROOT}/SDKs/${PLATFORM}${IPHONE_SDK}.sdk"
export CC=`xcrun -find clang`
export LD=`xcrun -find ld`
export CFLAGS="-O3 ${IOS_CFLAGS} -isysroot ${SDKROOT}"
export LDFLAGS="${IOS_CFLAGS} -isysroot ${SDKROOT}"
export CPPFLAGS="${CFLAGS}"

$CWD/configure \
--host="${HOST_TYPE}" \
--prefix="$DEST/$ARCH" \
--without-lapack \
--without-python \
--with-sphinxbase="$SPHINXBASE_DIR" \
|| exit 1

make -j3 install || exit 1
cd $CWD
done

PROJECT=sphinxbase

if [ ! "$*" ]
then
LIPO_ARGS="-output $DEST/lib$PROJECT.a"
for ARCH in $ARCHS
do
LIPO_ARGS="$LIPO_ARGS $DEST/$ARCH/lib/lib$PROJECT.a"
done
lipo -create $LIPO_ARGS || exit 1
fi
# libsphinxad
if [ ! "$*" ]
then
LIPO_ARGS="-output $DEST/libsphinxad.a"
for ARCH in $ARCHS
do
LIPO_ARGS="$LIPO_ARGS $DEST/$ARCH/lib/libsphinxad.a"
done
lipo -create $LIPO_ARGS || exit 1
fi

echo Done

0 comments on commit e2fafa5

Please sign in to comment.