mirror of
https://github.com/jambonz/freeswitch-modules.git
synced 2025-12-19 08:47:44 +00:00
Fix/docker build (#32)
* explicit flags for boost * remove pragma statements * remove some logging in mod_azure_tts * pragma back in * compile error fixes * mod_azure_tts: set Playback-File-Type to tts_stream
This commit is contained in:
@@ -15,4 +15,4 @@ endif
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
mod_audio_fork_la_LIBADD = $(switch_builddir)/libfreeswitch.la
|
mod_audio_fork_la_LIBADD = $(switch_builddir)/libfreeswitch.la
|
||||||
mod_audio_fork_la_LDFLAGS = -avoid-version -module -no-undefined -shared `pkg-config --libs libwebsockets` -lstdc++
|
mod_audio_fork_la_LDFLAGS = -avoid-version -module -no-undefined -shared `pkg-config --libs libwebsockets` -lstdc++ -lboost_system -lboost_thread
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "vector_math.h"
|
#include "vector_math.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#define GRANULAR_VOLUME_MAX (50)
|
#define GRANULAR_VOLUME_MAX (50)
|
||||||
#define SMAX 32767
|
#define SMAX 32767
|
||||||
@@ -153,6 +154,7 @@ typedef union {
|
|||||||
} vector_data_t;
|
} vector_data_t;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#pragma message("Building without vector math support")
|
||||||
void vector_add(int16_t* a, int16_t* b, size_t len) {
|
void vector_add(int16_t* a, int16_t* b, size_t len) {
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
a[i] += b[i];
|
a[i] += b[i];
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ extern "C" {
|
|||||||
CircularBuffer_t *cBuffer = (CircularBuffer_t *) a->circularBuffer;
|
CircularBuffer_t *cBuffer = (CircularBuffer_t *) a->circularBuffer;
|
||||||
std::vector<uint16_t> pcm_data;
|
std::vector<uint16_t> pcm_data;
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Synthesizing: received data\n");
|
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Synthesizing: received data\n");
|
||||||
|
|
||||||
if (a->flushed) {
|
if (a->flushed) {
|
||||||
return;
|
return;
|
||||||
@@ -204,6 +204,7 @@ extern "C" {
|
|||||||
switch_event_t *event;
|
switch_event_t *event;
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_PLAYBACK_START) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, SWITCH_EVENT_PLAYBACK_START) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_channel_event_set_data(channel, event);
|
switch_channel_event_set_data(channel, event);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-File-Type", "tts_stream");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_time_to_first_byte_ms", time_to_first_byte_ms.c_str());
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_time_to_first_byte_ms", time_to_first_byte_ms.c_str());
|
||||||
if (a->cache_filename) {
|
if (a->cache_filename) {
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_cache_filename", a->cache_filename);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "variable_tts_cache_filename", a->cache_filename);
|
||||||
@@ -314,7 +315,7 @@ extern "C" {
|
|||||||
a->flushed = 1;
|
a->flushed = 1;
|
||||||
if (!download_complete) {
|
if (!download_complete) {
|
||||||
if (a->file) {
|
if (a->file) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "closing audio cache file %s because download was interrupted\n", a->cache_filename);
|
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "closing audio cache file %s because download was interrupted\n", a->cache_filename);
|
||||||
if (fclose(a->file) != 0) {
|
if (fclose(a->file) != 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error closing audio cache file\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error closing audio cache file\n");
|
||||||
}
|
}
|
||||||
@@ -322,7 +323,7 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (a->cache_filename) {
|
if (a->cache_filename) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "removing audio cache file %s because download was interrupted\n", a->cache_filename);
|
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "removing audio cache file %s because download was interrupted\n", a->cache_filename);
|
||||||
if (unlink(a->cache_filename) != 0) {
|
if (unlink(a->cache_filename) != 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cleanupConn: error removing audio cache file %s: %d:%s\n",
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cleanupConn: error removing audio cache file %s: %d:%s\n",
|
||||||
a->cache_filename, errno, strerror(errno));
|
a->cache_filename, errno, strerror(errno));
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_azure_tts_shutdown);
|
|||||||
SWITCH_MODULE_DEFINITION(mod_azure_tts, mod_azure_tts_load, mod_azure_tts_shutdown, NULL);
|
SWITCH_MODULE_DEFINITION(mod_azure_tts, mod_azure_tts_load, mod_azure_tts_shutdown, NULL);
|
||||||
|
|
||||||
static void clearAzure(azure_t* a, int freeAll) {
|
static void clearAzure(azure_t* a, int freeAll) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "clearAzure\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "clearAzure\n");
|
||||||
|
|
||||||
if (a->cache_filename) free(a->cache_filename);
|
if (a->cache_filename) free(a->cache_filename);
|
||||||
if (a->api_key) free(a->api_key);
|
if (a->api_key) free(a->api_key);
|
||||||
@@ -46,7 +46,7 @@ static azure_t * createOrRetrievePrivateData(switch_speech_handle_t *sh) {
|
|||||||
sh->private_info = a;
|
sh->private_info = a;
|
||||||
memset(a, 0, sizeof(*a));
|
memset(a, 0, sizeof(*a));
|
||||||
switch_mutex_init(&a->mutex, SWITCH_MUTEX_NESTED, sh->memory_pool);
|
switch_mutex_init(&a->mutex, SWITCH_MUTEX_NESTED, sh->memory_pool);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "allocated azure_t\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "allocated azure_t\n");
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ switch_status_t a_speech_open(switch_speech_handle_t *sh, const char *voice_name
|
|||||||
azure_t *a = createOrRetrievePrivateData(sh);
|
azure_t *a = createOrRetrievePrivateData(sh);
|
||||||
a->voice_name = strdup(voice_name);
|
a->voice_name = strdup(voice_name);
|
||||||
a->rate = rate;
|
a->rate = rate;
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "a_speech_open voice: %s, rate %d, channels %d\n", voice_name, rate, channels);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "a_speech_open voice: %s, rate %d, channels %d\n", voice_name, rate, channels);
|
||||||
return azure_speech_open(a);
|
return azure_speech_open(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ static switch_status_t a_speech_close(switch_speech_handle_t *sh, switch_speech_
|
|||||||
{
|
{
|
||||||
switch_status_t rc;
|
switch_status_t rc;
|
||||||
azure_t *a = createOrRetrievePrivateData(sh);
|
azure_t *a = createOrRetrievePrivateData(sh);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "a_speech_close\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "a_speech_close\n");
|
||||||
|
|
||||||
switch_mutex_destroy(a->mutex);
|
switch_mutex_destroy(a->mutex);
|
||||||
|
|
||||||
@@ -84,8 +84,6 @@ static switch_status_t a_speech_feed_tts(switch_speech_handle_t *sh, char *text,
|
|||||||
a->flushed = 0;
|
a->flushed = 0;
|
||||||
a->samples_rate = 0;
|
a->samples_rate = 0;
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "a_speech_feed_tts\n");
|
|
||||||
|
|
||||||
return azure_speech_feed_tts(a, text, flags);
|
return azure_speech_feed_tts(a, text, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +93,6 @@ static switch_status_t a_speech_feed_tts(switch_speech_handle_t *sh, char *text,
|
|||||||
static switch_status_t a_speech_read_tts(switch_speech_handle_t *sh, void *data, size_t *datalen, switch_speech_flag_t *flags)
|
static switch_status_t a_speech_read_tts(switch_speech_handle_t *sh, void *data, size_t *datalen, switch_speech_flag_t *flags)
|
||||||
{
|
{
|
||||||
azure_t *a = createOrRetrievePrivateData(sh);
|
azure_t *a = createOrRetrievePrivateData(sh);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "a_speech_read_tts\n");
|
|
||||||
return azure_speech_read_tts(a, data, datalen, flags);
|
return azure_speech_read_tts(a, data, datalen, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +102,6 @@ static switch_status_t a_speech_read_tts(switch_speech_handle_t *sh, void *data,
|
|||||||
static void a_speech_flush_tts(switch_speech_handle_t *sh)
|
static void a_speech_flush_tts(switch_speech_handle_t *sh)
|
||||||
{
|
{
|
||||||
azure_t *a = createOrRetrievePrivateData(sh);
|
azure_t *a = createOrRetrievePrivateData(sh);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "w_speech_flush_tts\n");
|
|
||||||
azure_speech_flush_tts(a);
|
azure_speech_flush_tts(a);
|
||||||
|
|
||||||
clearAzure(a, 0);
|
clearAzure(a, 0);
|
||||||
@@ -114,7 +110,7 @@ static void a_speech_flush_tts(switch_speech_handle_t *sh)
|
|||||||
static void a_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val)
|
static void a_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val)
|
||||||
{
|
{
|
||||||
azure_t *a = createOrRetrievePrivateData(sh);
|
azure_t *a = createOrRetrievePrivateData(sh);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "a_text_param_tts: %s=%s\n", param, val);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "a_text_param_tts: %s=%s\n", param, val);
|
||||||
if (0 == strcmp(param, "api_key")) {
|
if (0 == strcmp(param, "api_key")) {
|
||||||
if (a->api_key) free(a->api_key);
|
if (a->api_key) free(a->api_key);
|
||||||
a->api_key = strdup(val);
|
a->api_key = strdup(val);
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ endif
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
mod_dub_la_LIBADD = $(switch_builddir)/libfreeswitch.la
|
mod_dub_la_LIBADD = $(switch_builddir)/libfreeswitch.la
|
||||||
mod_dub_la_LDFLAGS = -avoid-version -module -no-undefined -shared `pkg-config --libs boost` -lstdc++ -lmpg123
|
mod_dub_la_LDFLAGS = -avoid-version -module -no-undefined -lstdc++ -lmpg123 -lboost_system -lboost_thread
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "vector_math.h"
|
#include "vector_math.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|
||||||
#define GRANULAR_VOLUME_MAX (50)
|
#define GRANULAR_VOLUME_MAX (50)
|
||||||
#define SMAX 32767
|
#define SMAX 32767
|
||||||
@@ -153,6 +155,7 @@ typedef union {
|
|||||||
} vector_data_t;
|
} vector_data_t;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#pragma message("Building without vector math support")
|
||||||
void vector_add(int16_t* a, int16_t* b, size_t len) {
|
void vector_add(int16_t* a, int16_t* b, size_t len) {
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
a[i] += b[i];
|
a[i] += b[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user