Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a native client using TensorFlow C API
- Loading branch information
Showing
50 changed files
with
5,752 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Description: Deepspeech native client library. | ||
|
||
cc_library( | ||
name = "deepspeech", | ||
srcs = ["deepspeech.cc", | ||
"c_speech_features/c_speech_features.c", | ||
"kiss_fft130/kiss_fft.c", | ||
"kiss_fft130/tools/kiss_fftr.c"], | ||
hdrs = ["deepspeech.h", | ||
"c_speech_features/c_speech_features.h", | ||
"kiss_fft130/kiss_fft.h", | ||
"kiss_fft130/_kiss_fft_guts.h", | ||
"kiss_fft130/tools/kiss_fftr.h"], | ||
includes = ["c_speech_features", | ||
"kiss_fft130"], | ||
deps = [ | ||
"//tensorflow/core:tensorflow" | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
TFDIR ?= ../../tensorflow | ||
CFLAGS ?= -O2 -Wall | ||
|
||
default: deepspeech | ||
|
||
clean: | ||
rm -f deepspeech | ||
|
||
deepspeech: client.cc | ||
c++ -o deepspeech ${CFLAGS} client.cc `pkg-config --cflags --libs sox` -L${TFDIR}/bazel-bin/tensorflow -L${TFDIR}/bazel-bin/native_client -ldeepspeech -ltensorflow | ||
|
||
run: deepspeech | ||
LD_LIBRARY_PATH=${TFDIR}/bazel-bin/tensorflow:${TFDIR}/bazel-bin/native_client:${LD_LIBRARY_PATH} ./deepspeech ${ARGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# DeepSpeech native client | ||
|
||
A native client for running queries on an exported DeepSpeech model. | ||
|
||
## Requirements | ||
|
||
* [TensorFlow source](https://www.tensorflow.org/install/install_sources) | ||
* [libsox](https://sourceforge.net/projects/sox/) | ||
|
||
## Preparation | ||
|
||
Create a symbolic link in the TensorFlow checkout to the deepspeech `native_client` directory. | ||
|
||
``` | ||
cd tensorflow | ||
ln -s ../DeepSpeech/native_client ./ | ||
``` | ||
|
||
## Building | ||
|
||
Before building the TensorFlow stand-alone library, you will need to prepare your environment to configure and build TensorFlow. Follow the [instructions](https://www.tensorflow.org/install/install_sources) on the TensorFlow site for your platform, up to the end of 'Configure the installation'. | ||
|
||
To build the TensorFlow library, execute the following command: | ||
|
||
``` | ||
bazel build -c opt //tensorflow:libtensorflow.so | ||
``` | ||
|
||
Then you can build the DeepSpeech native library. | ||
|
||
``` | ||
bazel build -c opt //native_client:deepspeech | ||
``` | ||
|
||
Finally, you can change to the `native_client` directory and use the `Makefile`. By default, the `Makefile` will assume there is a TensorFlow checkout in a directory above the DeepSpeech checkout. If that is not the case, set the environment variable `TFDIR` to point to the right directory. | ||
|
||
``` | ||
cd ../DeepSpeech/native_client | ||
make deepspeech | ||
``` | ||
|
||
## Running | ||
|
||
The client can be run via the `Makefile`. The client will accept audio of any format your installation of SoX supports. | ||
|
||
``` | ||
ARGS="/path/to/output_graph.pb /path/to/audio/file.ogg" make run | ||
``` |
Oops, something went wrong.