Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Meson build system #22

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
55 changes: 55 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
project(
'gst-deepspeech',
'cpp',
version: '1.4.0',
license: 'LGPL-2.0-or-later',
meson_version: '>= 0.58',
)

# Dependencies

cxx = meson.get_compiler('cpp')

gst_min_version = '1.0.0'
gst_not_found_message = '''
You need to install or upgrade the GStreamer development
packages on your system. On debian-based systems these are
libgstreamer1.0-dev and libgstreamer-plugins-base1.0-dev.
on RPM-based systems gstreamer1.0-devel, libgstreamer1.0-devel
or similar. The minimum version required is @0@.
'''.format(gst_min_version)

gstreamer = dependency(
'gstreamer-1.0',
version: '>= ' + gst_min_version,
not_found_message: gst_not_found_message
)
gstreamer_base = dependency(
'gstreamer-base-1.0',
version: '>= ' + gst_min_version,
not_found_message: gst_not_found_message
)
gstreamer_controller = dependency(
'gstreamer-controller-1.0',
version: '>= ' + gst_min_version,
not_found_message: gst_not_found_message
)
gstreamer_audio = dependency(
'gstreamer-audio-1.0',
version: '>= ' + gst_min_version,
not_found_message: gst_not_found_message
)

stt = cxx.find_library('stt')

# Paths

prefix = get_option('prefix')
libdir = prefix / get_option('libdir')

plugins_install_dir = gstreamer.get_variable(
'pluginsdir',
pkgconfig_define: ['libdir', libdir],
)

subdir('src')
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ plugin_LTLIBRARIES = libgstdeepspeech.la
libgstdeepspeech_la_SOURCES = gstdeepspeech.cc gstdeepspeech.h
libgstdeepspeech_la_CXXFLAGS = $(GST_CFLAGS)
libgstdeepspeech_la_LIBADD = $(GST_LIBS)
libgstdeepspeech_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -ldeepspeech
libgstdeepspeech_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -lstt
libgstdeepspeech_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = gstdeepspeech.h
17 changes: 8 additions & 9 deletions src/gstdeepspeech.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#endif

#include <gst/gst.h>
#include <deepspeech.h>
#include <string.h>
#include <sstream>

Expand Down Expand Up @@ -132,8 +131,8 @@ gpointer run_model_async(void * instance_data, void * pool_data)
g_mutex_lock(&mutex);
void *data = malloc(sizeof(short) * info.size);
memcpy(data, info.data, info.size);
DS_FeedAudioContent(deepspeech->streaming_state, (const short *) data, (unsigned int) info.size);
result = DS_IntermediateDecode(deepspeech->streaming_state);
STT_FeedAudioContent(deepspeech->streaming_state, (const short *) data, (unsigned int) info.size);
result = STT_IntermediateDecode(deepspeech->streaming_state);
g_mutex_unlock(&mutex);

if (strlen(result) > 0) {
Expand All @@ -154,8 +153,8 @@ void process_final_text(GstDeepSpeech * deepspeech, GstBuffer *buf) {
gst_buffer_map(buf, &info, GST_MAP_READ);
void *data = malloc(sizeof(short) * info.size);
memcpy(data, info.data, info.size);
DS_FeedAudioContent(deepspeech->streaming_state, (const short *) data, (unsigned int) info.size);
result = DS_FinishStream(deepspeech->streaming_state);
STT_FeedAudioContent(deepspeech->streaming_state, (const short *) data, (unsigned int) info.size);
result = STT_FinishStream(deepspeech->streaming_state);

if (strlen(result) > 0) {
GstMessage *msg = gst_deepspeech_message_new (deepspeech, buf, result, false);
Expand Down Expand Up @@ -249,21 +248,21 @@ gst_deepspeech_init (GstDeepSpeech * deepspeech)
static void
gst_deepspeech_load_model (GstDeepSpeech * deepspeech)
{
int status = DS_CreateModel(deepspeech->speech_model_path, &deepspeech->model_state);
int status = STT_CreateModel(deepspeech->speech_model_path, &deepspeech->model_state);
if (status != 0) {
fprintf(stderr, "Could not create model.\n");
return;
}

DS_SetModelBeamWidth(deepspeech->model_state, DEFAULT_BEAM_WIDTH);
STT_SetModelBeamWidth(deepspeech->model_state, DEFAULT_BEAM_WIDTH);

status = DS_EnableExternalScorer(deepspeech->model_state, deepspeech->scorer_path);
status = STT_EnableExternalScorer(deepspeech->model_state, deepspeech->scorer_path);
if (status != 0) {
fprintf(stderr, "Could not enable scorer.\n");
return;
}

status = DS_CreateStream(deepspeech->model_state, &deepspeech->streaming_state);
status = STT_CreateStream(deepspeech->model_state, &deepspeech->streaming_state);
if (status != 0) {
fprintf(stderr, "Could not create stream.\n");
return;
Expand Down
2 changes: 1 addition & 1 deletion src/gstdeepspeech.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
#include "deepspeech.h"
#include <coqui-stt.h>

G_BEGIN_DECLS

Expand Down
28 changes: 28 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cdata = configuration_data()
cdata.set_quoted('VERSION', meson.project_version())
cdata.set_quoted('PACKAGE', meson.project_name())

config_h = configure_file(
output: 'config.h',
configuration: cdata,
)

libgstdeepspeech = shared_library(
'gstdeepspeech',
sources: [
'gstdeepspeech.cc',
config_h,
],
cpp_args: [
'-DHAVE_CONFIG_H',
],
dependencies: [
gstreamer,
gstreamer_base,
gstreamer_controller,
gstreamer_audio,
stt,
],
install: true,
install_dir: plugins_install_dir,
)