提交 915fa372 authored 作者: Brian West's avatar Brian West

commit dbea6143d6b63765f2d0eba26728c3903d3d2606

Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Wed Jul 8 17:37:24 2009 +0000

    Added yet another buffer of media frames mpf_frame_buffer.
    There are a number of similar buffers (mpf_jitter_buffer, mpf_buffer, mpf_frame_buffer). All of them produce mpf_frames as output, but input is somewhat dif
ferent. Input is RTP payload in case of mpf_jitter_buffer, synthesized chunks of voice in case of mpf_buffer, and mpf_frame in case of mpf_frame_buffer
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1043 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 1bf7a66012180649bd1f01fd72e483a9e5de3495
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Wed Jul 8 16:33:36 2009 +0000

    Fixed termination of client and server stacks (Issue-28)
    Network client/server stacks generated double TERMINATE_COMPLETE event, while mpf engine generated no TERMINATE_COMPLETE event.
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1042 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 0327cf17779430b51290d22cc7d51130f997f2f2
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Sun Jul 5 19:22:31 2009 +0000

    Enhanced flite plugin to
    - support more than one SPEAK requests in a session (SPEAK -> STOP -> SPEAK or SPEAK-> SPEAK-COMPLETE->SPEAK), task is created upon channel creation and is 
waiting for consecutive SPEAK requests to process
    - properly handle race between STOP request and SPEAK-COMPLETE event
    - respond with IN-PROGRESS, when all the required parameters are checked to be valid and synthesizing is due to start
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1037 f001bc3a-424a-0410-80a0-a715b8f413a8

commit e2f73f9279e54ef3a40cb637a38ab1ff485ea5d3
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Sun Jul 5 03:46:13 2009 +0000

    Separated flite voices (unified voice register/unregister routine, select voice by name)
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1036 f001bc3a-424a-0410-80a0-a715b8f413a8

commit 694783a527cb795ca45982c2388895da06dd6009
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Sat Jul 4 05:06:17 2009 +0000

    Checked content-type to be "text/plain" as flite doesn't support SSML yet.
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1035 f001bc3a-424a-0410-80a0-a715b8f413a8

commit aafdc6e30e77c40e5470cce844f48ec28a254786
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Fri Jul 3 14:55:10 2009 +0000

    Enhanced float value generation to use the precision (digits after decimal sign) user provides by removing optional trailing 0s (if any)
    Issue-35
    
    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1034 f001bc3a-424a-0410-80a0-a715b8f413a8

commit bcc2f137956f5c532c0256b064c8a3d1015a46d0
Author: achaloyan <achaloyan@f001bc3a-424a-0410-80a0-a715b8f413a8>
Date:   Fri Jul 3 07:04:07 2009 +0000

    Enhanced RTP port management (Issue-34, Thanks cpsoares)

    git-svn-id: https://unimrcp.googlecode.com/svn/trunk@1033 f001bc3a-424a-0410-80a0-a715b8f413a8



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14166 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 72b4dfd6
Wed Jul 1 19:53:07 CDT 2009
Thu Jul 9 10:17:26 CDT 2009
......@@ -22,8 +22,6 @@
* @brief Text Stream Parse/Generate Routine
*/
#include <stdlib.h>
#include <stdio.h>
#include "apt_string.h"
#include "apt_pair.h"
......@@ -95,40 +93,17 @@ APT_DECLARE(apt_bool_t) apt_boolean_value_parse(const apt_str_t *str, apt_bool_t
/** Generate boolean-value */
APT_DECLARE(apt_bool_t) apt_boolean_value_generate(apt_bool_t value, apt_text_stream_t *str);
/** Parse size_t value */
static APR_INLINE apr_size_t apt_size_value_parse(const apt_str_t *str)
{
return str->buf ? atol(str->buf) : 0;
}
APT_DECLARE(apr_size_t) apt_size_value_parse(const apt_str_t *str);
/** Generate apr_size_t value */
static APR_INLINE apt_bool_t apt_size_value_generate(apr_size_t value, apt_text_stream_t *stream)
{
int length = sprintf(stream->pos, "%"APR_SIZE_T_FMT, value);
if(length <= 0) {
return FALSE;
}
stream->pos += length;
return TRUE;
}
APT_DECLARE(apt_bool_t) apt_size_value_generate(apr_size_t value, apt_text_stream_t *stream);
/** Parse float value */
static APR_INLINE float apt_float_value_parse(const apt_str_t *str)
{
return str->buf ? (float)atof(str->buf) : 0;
}
APT_DECLARE(float) apt_float_value_parse(const apt_str_t *str);
/** Generate float value */
static APR_INLINE apt_bool_t apt_float_value_generate(float value, apt_text_stream_t *stream)
{
int length = sprintf(stream->pos,"%.2f",value);
if(length <= 0) {
return FALSE;
}
stream->pos += length;
return TRUE;
}
APT_DECLARE(apt_bool_t) apt_float_value_generate(float value, apt_text_stream_t *stream);
/** Generate string value */
static APR_INLINE apt_bool_t apt_string_value_generate(const apt_str_t *str, apt_text_stream_t *stream)
......
......@@ -300,8 +300,6 @@ static apt_bool_t apt_net_client_task_run(apt_task_t *base)
}
apt_net_client_task_pollset_destroy(task);
apt_task_child_terminate(task->base);
return TRUE;
}
......
......@@ -350,8 +350,6 @@ static apt_bool_t apt_net_server_task_run(apt_task_t *base)
}
apt_net_server_task_pollset_destroy(task);
apt_task_child_terminate(task->base);
return TRUE;
}
......
......@@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <stdlib.h>
#include <stdio.h>
#include <apr_uuid.h>
#include "apt_text_stream.h"
......@@ -307,6 +309,45 @@ APT_DECLARE(apt_bool_t) apt_boolean_value_generate(apt_bool_t value, apt_text_st
return TRUE;
}
/** Parse size_t value */
APT_DECLARE(apr_size_t) apt_size_value_parse(const apt_str_t *str)
{
return str->buf ? atol(str->buf) : 0;
}
/** Generate apr_size_t value */
APT_DECLARE(apt_bool_t) apt_size_value_generate(apr_size_t value, apt_text_stream_t *stream)
{
int length = sprintf(stream->pos, "%"APR_SIZE_T_FMT, value);
if(length <= 0) {
return FALSE;
}
stream->pos += length;
return TRUE;
}
/** Parse float value */
APT_DECLARE(float) apt_float_value_parse(const apt_str_t *str)
{
return str->buf ? (float)atof(str->buf) : 0;
}
/** Generate float value */
APT_DECLARE(apt_bool_t) apt_float_value_generate(float value, apt_text_stream_t *stream)
{
char *end;
int length = sprintf(stream->pos,"%f",value);
if(length <= 0) {
return FALSE;
}
/* remove trailing 0s (if any) */
end = stream->pos + length -1;
while(*end == 0x30 && end != stream->pos) end--;
stream->pos = end + 1;
return TRUE;
}
/** Generate value plus the length (number of digits) of the value itself. */
APT_DECLARE(apt_bool_t) apt_var_length_value_generate(apr_size_t *value, apr_size_t max_count, apt_str_t *str)
......
......@@ -20,6 +20,7 @@ include_HEADERS = codecs/g711/g711.h \
include/mpf_context.h \
include/mpf_engine.h \
include/mpf_frame.h \
include/mpf_frame_buffer.h \
include/mpf_message.h \
include/mpf_object.h \
include/mpf_stream.h \
......@@ -55,6 +56,7 @@ libmpf_la_SOURCES = codecs/g711/g711.c \
src/mpf_termination.c \
src/mpf_rtp_termination_factory.c \
src/mpf_file_termination_factory.c \
src/mpf_frame_buffer.c \
src/mpf_timer.c \
src/mpf_encoder.c \
src/mpf_decoder.c \
......
/*
* Copyright 2008 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __MPF_FRAME_BUFFER_H__
#define __MPF_FRAME_BUFFER_H__
/**
* @file mpf_frame_buffer.h
* @brief Buffer of Media Frames
*/
#include "mpf_frame.h"
APT_BEGIN_EXTERN_C
/** Opaque frame buffer declaration */
typedef struct mpf_frame_buffer_t mpf_frame_buffer_t;
/** Create frame buffer */
mpf_frame_buffer_t* mpf_frame_buffer_create(apr_size_t frame_size, apr_size_t frame_count, apr_pool_t *pool);
/** Destroy frame buffer */
void mpf_frame_buffer_destroy(mpf_frame_buffer_t *buffer);
/** Restart frame buffer */
apt_bool_t mpf_frame_buffer_restart(mpf_frame_buffer_t *buffer);
/** Write frame to buffer */
apt_bool_t mpf_frame_buffer_write(mpf_frame_buffer_t *buffer, const mpf_frame_t *frame);
/** Read frame from buffer */
apt_bool_t mpf_frame_buffer_read(mpf_frame_buffer_t *buffer, mpf_frame_t *frame);
APT_END_EXTERN_C
#endif /*__MPF_FRAME_BUFFER_H__*/
......@@ -207,6 +207,10 @@
RelativePath=".\include\mpf_frame.h"
>
</File>
<File
RelativePath=".\include\mpf_frame_buffer.h"
>
</File>
<File
RelativePath=".\include\mpf_jitter_buffer.h"
>
......@@ -332,6 +336,10 @@
RelativePath=".\src\mpf_file_termination_factory.c"
>
</File>
<File
RelativePath=".\src\mpf_frame_buffer.c"
>
</File>
<File
RelativePath=".\src\mpf_jitter_buffer.c"
>
......
......@@ -128,6 +128,7 @@ static apt_bool_t mpf_engine_terminate(apt_task_t *task)
mpf_timer_stop(engine->timer);
mpf_engine_contexts_destroy(engine);
apt_task_child_terminate(task);
return TRUE;
}
......
/*
* Copyright 2009 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mpf_frame_buffer.h"
struct mpf_frame_buffer_t {
apr_byte_t *raw_data;
mpf_frame_t *frames;
apr_size_t frame_count;
apr_size_t frame_size;
apr_size_t write_pos;
apr_size_t read_pos;
apr_thread_mutex_t *guard;
apr_pool_t *pool;
};
mpf_frame_buffer_t* mpf_frame_buffer_create(apr_size_t frame_size, apr_size_t frame_count, apr_pool_t *pool)
{
apr_size_t i;
mpf_frame_buffer_t *buffer = apr_palloc(pool,sizeof(mpf_frame_buffer_t));
buffer->frame_size = frame_size;
buffer->frame_count = frame_count;
buffer->raw_data = apr_palloc(pool,buffer->frame_size*buffer->frame_count);
buffer->frames = apr_palloc(pool,sizeof(mpf_frame_t)*buffer->frame_count);
for(i=0; i<buffer->frame_count; i++) {
buffer->frames[i].type = MEDIA_FRAME_TYPE_NONE;
buffer->frames[i].codec_frame.buffer = buffer->raw_data + i*buffer->frame_size;
}
buffer->write_pos = buffer->read_pos = 0;
apr_thread_mutex_create(&buffer->guard,APR_THREAD_MUTEX_UNNESTED,pool);
return buffer;
}
void mpf_frame_buffer_destroy(mpf_frame_buffer_t *buffer)
{
if(buffer->guard) {
apr_thread_mutex_destroy(buffer->guard);
buffer->guard = NULL;
}
}
apt_bool_t mpf_frame_buffer_restart(mpf_frame_buffer_t *buffer)
{
buffer->write_pos = buffer->read_pos;
return TRUE;
}
static APR_INLINE mpf_frame_t* mpf_frame_buffer_frame_get(mpf_frame_buffer_t *buffer, apr_size_t pos)
{
apr_size_t index = pos % buffer->frame_count;
return &buffer->frames[index];
}
apt_bool_t mpf_frame_buffer_write(mpf_frame_buffer_t *buffer, const mpf_frame_t *frame)
{
mpf_frame_t *write_frame;
void *data = frame->codec_frame.buffer;
apr_size_t size = frame->codec_frame.size;
apr_thread_mutex_lock(buffer->guard);
while(buffer->write_pos - buffer->read_pos < buffer->frame_count && size >= buffer->frame_size) {
write_frame = mpf_frame_buffer_frame_get(buffer,buffer->write_pos);
write_frame->type = frame->type;
write_frame->codec_frame.size = buffer->frame_size;
memcpy(
write_frame->codec_frame.buffer,
data,
write_frame->codec_frame.size);
data = (char*)data + buffer->frame_size;
size -= buffer->frame_size;
buffer->write_pos ++;
}
apr_thread_mutex_unlock(buffer->guard);
/* if size != 0 => non frame alligned or buffer is full */
return size == 0 ? TRUE : FALSE;
}
apt_bool_t mpf_frame_buffer_read(mpf_frame_buffer_t *buffer, mpf_frame_t *media_frame)
{
apr_thread_mutex_lock(buffer->guard);
if(buffer->write_pos > buffer->read_pos) {
/* normal read */
mpf_frame_t *src_media_frame = mpf_frame_buffer_frame_get(buffer,buffer->read_pos);
media_frame->type = src_media_frame->type;
if(media_frame->type & MEDIA_FRAME_TYPE_AUDIO) {
media_frame->codec_frame.size = src_media_frame->codec_frame.size;
memcpy(
media_frame->codec_frame.buffer,
src_media_frame->codec_frame.buffer,
media_frame->codec_frame.size);
}
if(media_frame->type & MEDIA_FRAME_TYPE_EVENT) {
media_frame->event_frame = src_media_frame->event_frame;
}
src_media_frame->type = MEDIA_FRAME_TYPE_NONE;
buffer->read_pos ++;
}
else {
/* underflow */
media_frame->type = MEDIA_FRAME_TYPE_NONE;
}
apr_thread_mutex_unlock(buffer->guard);
return TRUE;
}
......@@ -83,21 +83,6 @@ MPF_DECLARE(mpf_audio_stream_t*) mpf_rtp_stream_create(mpf_termination_t *termin
return rtp_stream->base;
}
static void mpf_rtp_stream_ip_port_set(mpf_rtp_media_descriptor_t *media, mpf_rtp_config_t *config)
{
if(media->base.ip.length == 0) {
media->base.ip = config->ip;
media->base.ext_ip = config->ext_ip;
}
if(media->base.port == 0) {
media->base.port = config->rtp_port_cur;
config->rtp_port_cur += 2;
if(config->rtp_port_cur == config->rtp_port_max) {
config->rtp_port_cur = config->rtp_port_min;
}
}
}
static apt_bool_t mpf_rtp_stream_local_media_create(mpf_rtp_stream_t *rtp_stream, mpf_rtp_media_descriptor_t *local_media, mpf_rtp_media_descriptor_t *remote_media)
{
apt_bool_t status = TRUE;
......@@ -111,9 +96,31 @@ static apt_bool_t mpf_rtp_stream_local_media_create(mpf_rtp_stream_t *rtp_stream
if(remote_media) {
local_media->base.id = remote_media->base.id;
}
if(local_media->base.ip.length == 0) {
local_media->base.ip = rtp_stream->config->ip;
local_media->base.ext_ip = rtp_stream->config->ext_ip;
}
if(local_media->base.port == 0) {
/* RTP port management */
apr_port_t first_port_in_search = rtp_stream->config->rtp_port_cur;
apt_bool_t is_port_ok = FALSE;
mpf_rtp_stream_ip_port_set(local_media,rtp_stream->config);
if(mpf_rtp_socket_create(rtp_stream,local_media) == FALSE) {
do {
local_media->base.port = rtp_stream->config->rtp_port_cur;
rtp_stream->config->rtp_port_cur += 2;
if(rtp_stream->config->rtp_port_cur == rtp_stream->config->rtp_port_max) {
rtp_stream->config->rtp_port_cur = rtp_stream->config->rtp_port_min;
}
if(mpf_rtp_socket_create(rtp_stream,local_media) == TRUE) {
is_port_ok = TRUE;
}
} while((is_port_ok == FALSE) && (first_port_in_search != rtp_stream->config->rtp_port_cur));
if(is_port_ok == FALSE) {
local_media->base.state = MPF_MEDIA_DISABLED;
status = FALSE;
}
}
else if(mpf_rtp_socket_create(rtp_stream,local_media) == FALSE) {
local_media->base.state = MPF_MEDIA_DISABLED;
status = FALSE;
}
......
......@@ -14,6 +14,6 @@ INCLUDES = -Iinclude \
plugin_LTLIBRARIES = mrcpflite.la
mrcpflite_la_SOURCES = src/mrcp_flite.c
mrcpflite_la_SOURCES = src/mrcp_flite.c src/flite_voices.c
mrcpflite_la_LDFLAGS = -module $(PLUGIN_LT_VERSION)
mrcpflite_la_LIBADD = $(UNIMRCP_FLITE_LIBS) -lm
/*
* Copyright 2008 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __FLITE_VOICES_H__
#define __FLITE_VOICES_H__
/**
* @file flite_voices.h
* @brief Flite Voices
*/
#include <flite.h>
#include <apr_hash.h>
#include "mrcp_message.h"
APT_BEGIN_EXTERN_C
typedef struct flite_voices_t flite_voices_t;
flite_voices_t* flite_voices_load(apr_pool_t *pool);
void flite_voices_unload(flite_voices_t *voices);
cst_voice* flite_voices_best_match_get(flite_voices_t *voices, mrcp_message_t *message);
APT_END_EXTERN_C
#endif /*__FLITE_VOICES_H__*/
......@@ -149,11 +149,19 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\include\flite_voices.h"
>
</File>
</Filter>
<Filter
Name="src"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
>
<File
RelativePath=".\src\flite_voices.c"
>
</File>
<File
RelativePath=".\src\mrcp_flite.c"
>
......
/*
* Copyright 2008 Arsen Chaloyan
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "flite_voices.h"
#include "mrcp_synth_header.h"
typedef struct flite_voice_t flite_voice_t;
/** Declaration of flite voice */
struct flite_voice_t {
const char *name;
cst_voice *self;
cst_voice* (*register_voice)(void);
void (*unregister_voice)(cst_voice *);
};
struct flite_voices_t {
apr_hash_t *table;
apr_pool_t *pool;
};
/* declarations for flite voices */
cst_voice *register_cmu_us_awb(void);
cst_voice *register_cmu_us_kal(void);
cst_voice *register_cmu_us_rms(void);
cst_voice *register_cmu_us_slt(void);
void unregister_cmu_us_awb(cst_voice * v);
void unregister_cmu_us_kal(cst_voice * v);
void unregister_cmu_us_rms(cst_voice * v);
void unregister_cmu_us_slt(cst_voice * v);
static apt_bool_t flite_voices_init(flite_voices_t *voices, apr_pool_t *pool)
{
flite_voice_t *voice;
voice = apr_palloc(pool,sizeof(flite_voice_t));
voice->name = "awb";
voice->self = NULL;
voice->register_voice = register_cmu_us_awb;
voice->unregister_voice = unregister_cmu_us_awb;
apr_hash_set(voices->table,voice->name,APR_HASH_KEY_STRING,voice);
voice = apr_palloc(pool,sizeof(flite_voice_t));
voice->name = "kal";
voice->self = NULL;
voice->register_voice = register_cmu_us_kal;
voice->unregister_voice = unregister_cmu_us_kal;
apr_hash_set(voices->table,voice->name,APR_HASH_KEY_STRING,voice);
voice = apr_palloc(pool,sizeof(flite_voice_t));
voice->name = "rms";
voice->self = NULL;
voice->register_voice = register_cmu_us_rms;
voice->unregister_voice = unregister_cmu_us_rms;
apr_hash_set(voices->table,voice->name,APR_HASH_KEY_STRING,voice);
voice = apr_palloc(pool,sizeof(flite_voice_t));
voice->name = "slt";
voice->self = NULL;
voice->register_voice = register_cmu_us_slt;
voice->unregister_voice = unregister_cmu_us_slt;
apr_hash_set(voices->table,voice->name,APR_HASH_KEY_STRING,voice);
return TRUE;
}
flite_voices_t* flite_voices_load(apr_pool_t *pool)
{
flite_voice_t *voice;
apr_hash_index_t *it;
void *val;
flite_voices_t *voices = apr_palloc(pool,sizeof(flite_voices_t));
voices->pool = pool;
voices->table = apr_hash_make(pool);
/* init voices */
flite_voices_init(voices,pool);
/* register voices */
it = apr_hash_first(pool,voices->table);
/* walk through the voices and register them */
for(; it; it = apr_hash_next(it)) {
apr_hash_this(it,NULL,NULL,&val);
voice = val;
if(voice) {
voice->self = voice->register_voice();
}
}
return voices;
}
void flite_voices_unload(flite_voices_t *voices)
{
flite_voice_t *voice;
apr_hash_index_t *it;
void *val;
/* unregister voices */
it = apr_hash_first(voices->pool,voices->table);
/* walk through the voices and register them */
for(; it; it = apr_hash_next(it)) {
apr_hash_this(it,NULL,NULL,&val);
voice = val;
if(voice && voice->self) {
voice->unregister_voice(voice->self);
}
}
}
cst_voice* flite_voices_best_match_get(flite_voices_t *voices, mrcp_message_t *message)
{
cst_voice *voice = NULL;
const char *voice_name = NULL;
mrcp_synth_header_t *synth_header = mrcp_resource_header_get(message);
if(synth_header) {
if(mrcp_resource_header_property_check(message,SYNTHESIZER_HEADER_VOICE_NAME) == TRUE) {
voice_name = synth_header->voice_param.name.buf;
}
}
if(voice_name) {
/* get voice by name */
flite_voice_t *flite_voice;
flite_voice = apr_hash_get(voices->table,voice_name,APR_HASH_KEY_STRING);
if(flite_voice) {
voice = flite_voice->self;
}
}
if(!voice) {
/* still no voice found, get the default one */
flite_voice_t *flite_voice = NULL;
void *val;
apr_hash_index_t *it = apr_hash_first(voices->pool,voices->table);
apr_hash_this(it,NULL,NULL,&val);
if(val) {
flite_voice = val;
voice = flite_voice->self;
}
}
return voice;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论