Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don’t work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Vscode
.vscode/

# Binaries
tic.out
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Works with 3.11 and tested through 3.15
cmake_minimum_required(VERSION 3.11...3.16)

# Project name and a few useful settings. Other commands can pick up the results
project(featex
VERSION 0.1
DESCRIPTION "featex"
LANGUAGES C)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Only do these if this is the main project, and not if it is included through add_subdirectory
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)

# Nicely support folders in IDE's
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

endif()

add_subdirectory(src)
151 changes: 106 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,109 @@
# featex
PocketSphinx phonetic feature extraction for intelligibility prediction and remediation

To compile and run, you need to install CMU PocketSphinx, e.g., on redhat/centos/fedora:

sudo yum install svn autoconf libtool automake bison python-devel swig

or, on debian/ubuntu/mint:

sudo apt-get install subversion autoconf libtool automake bison python-dev swig

then:

cd
mkdir src
cd src
mkdir ps
cd ps
svn checkout svn://svn.code.sf.net/p/cmusphinx/code/trunk/sphinxbase
cd sphinxbase
./autogen.sh
make
sudo make install
cd ..
svn checkout svn://svn.code.sf.net/p/cmusphinx/code/trunk/pocketsphinx
cd pocketsphinx
./autogen.sh
make
sudo make install

cd test/regression
./test-lm.sh

This should say, "All sub-tests passed"

cd ~/src/ps
git clone https://github.com/jsalsman/featex
cd featex

gcc -I /usr/local/include/pocketsphinx -I /usr/local/include/sphinxbase \
-I ~/src/ps/pocketsphinx/src/libpocketsphinx \
-o featex featex.c -lpocketsphinx -lsphinxbase -lm

LD_LIBRARY_PATH=/usr/local/lib ./featex we drank tea in the afternoon and watched tv

Make sure those `-I` include paths and the `#define MODELDIR` directive near the top of featex.c correctly identify where the include files, libraries, and en-us model files were actually installed. The numeric feature stream goes to standard output, and verbose debugging output goes to stderr, so in production you might likely run it with `2>/dev/null`. If you don't want to prepend the LD_LIBRARY_PATH, which is necessary on redhat but not debian variants, see e.g. https://serverfault.com/a/372998

The file `Spoken-English-Intelligibility-Remediation.pdf` -- also at http://arxiv.org/abs/1709.01713 -- has more information.
### Dependencies

#### Packages

To compile and run, you need to install CMU PocketSphinx
On Redhat/CentOS/Fedora:

sudo yum install svn autoconf libtool automake bison python-devel swig gcc make

or on Debian based systems:

sudo apt-get install subversion autoconf libtool automake bison python-dev swig gcc make

#### Sphinxbase and Pocketsphinx

Install both sphinxbase and pocketsphinx. Go to any temp directory and execute the following.

Sphinxbase:

$ svn checkout svn://svn.code.sf.net/p/cmusphinx/code/trunk/sphinxbase
$ cd sphinxbase
$ ./autogen.sh
$ make
$ sudo make install

Pocketsphinx:

$ svn checkout svn://svn.code.sf.net/p/cmusphinx/code/trunk/pocketsphinx
$ cd pocketsphinx
$ ./autogen.sh
$ make
$ sudo make install

Run the builtin test:

$ cd test/regression
$ ./test-lm.sh

This should say, "All sub-tests passed"

### Compiling

Clone the repository:

$ git clone https://github.com/jarulsamy/featex

Create a build directory and `cd` into it:

$ cd featex
$ mkdir build
$ cd build

Generate the build files with `cmake`:

$ cmake ..

Finally, compile:

$ make

>The output binary, `featex.o` should be in the `bin/` directory.


### Usage

View the built-in help with:

$ ./featex --help

Usage: featex.o [OPTION...]
featex -- PocketSphinx phonetic feature extraction for intelligibility
prediction and remediation

-c, --combo=COMBO_PATH Path to combo.dict.
-d, --diphones Toggle play diphones
-i, --infile=INFILE_PATH Path to input raw file.
-p, --phonemes Toggle play phonemes
-P, --phrase='PHRASE' Input phrase
-t, --triphones Toggle play triphones
-u, --utterance Toggle play utterances
-w, --word Toggle play words
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Report bugs to <joshua.gf.arul@gmail.com>

>The input phrase **MUST** be surrounded by quotes.

>If you run into any missing libs while trying to run, try this:
>export LD_LIBRARY_PATH=/usr/local/lib

The numeric feature stream goes to standard output, and verbose debugging output goes to stderr, so in production you will likely have to run it with `2>/dev/null`. If you don't want to prepend the LD_LIBRARY_PATH, which is necessary on redhat but not debian variants, see e.g. https://serverfault.com/a/372998

More info is documented in this [paper](assets/Spoken-English-Intelligibility-Remediation.pdf), and also [here](http://arxiv.org/abs/1709.01713).

A demo can be run using `assets/combo.dict` and `assets/featex.raw`:

$ ./featex.o -c assets/combo.dict -i assets/featex.raw -P 'we drank tea in the afternoon and watched tv`

If you only want to see the end result and filter out all the debug data, redirect `stderr`:

$ ./featex.o -c assets/combo.dict -i assets/featex.raw -P 'we drank tea in the afternoon and watched tv` 2> /dev/null
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading