Brian West 915fa372d8 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
2009-07-09 15:19:27 +00:00

161 lines
4.2 KiB
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;
}