@@ -285,7 +285,7 @@ function sepiaFW_build_speech_synthesis(Speech, sepiaSessionId){
285285 //set a voice
286286 Speech . setVoice = function ( newVoice ) {
287287 //console.error("TRACE SET VOICE - v: " + newVoice); //DEBUG
288- if ( ! voices || ! voices . length || ! voices . filter ( function ( v ) { return v . name = newVoice ; } ) ) {
288+ if ( ! voices || ! voices . length || ! voices . filter ( function ( v ) { return v . name == newVoice ; } ) ) {
289289 //console.error("VOICE NOT FOUND, setting empty"); //DEBUG
290290 newVoice = "" ;
291291 }
@@ -774,13 +774,20 @@ function sepiaFW_build_speech_synthesis(Speech, sepiaSessionId){
774774
775775 //get audio URL
776776 Speech . sepiaTTS . getURL = function ( message , successCallback , errorCallback , options ) {
777- //TODO: implement 'options.oneTimeVoice' and 'options.oneTimeLanguage'
777+ if ( ! options ) options = { } ;
778+ var lang = Speech . getLanguage ( ) ;
779+ var voice = Speech . sepiaTTS . settings . voice ;
780+ //use 'options.oneTimeVoice' and 'options.oneTimeLanguage'?
781+ if ( options . oneTimeVoice && options . oneTimeVoice . name ) {
782+ voice = options . oneTimeVoice . name ;
783+ lang = options . oneTimeLanguage ;
784+ }
778785 var apiUrl = SepiaFW . config . assistAPI + "tts" ;
779786 var submitData = {
780787 text : message ,
781- lang : Speech . getLanguage ( ) ,
788+ lang : lang ,
782789 mood : ( ( SepiaFW . assistant ) ? SepiaFW . assistant . getMood ( ) : Speech . sepiaTTS . settings . mood ) ,
783- voice : Speech . sepiaTTS . settings . voice ,
790+ voice : voice ,
784791 gender : Speech . sepiaTTS . settings . gender ,
785792 speed : Speech . sepiaTTS . settings . speed ,
786793 tone : Speech . sepiaTTS . settings . tone ,
@@ -883,7 +890,7 @@ function sepiaFW_build_speech_synthesis(Speech, sepiaSessionId){
883890 }
884891
885892 Speech . maryTTS . getURL = function ( message , successCallback , errorCallback , options ) {
886- //TODO: implement ' options.oneTimeVoice' and 'options.oneTimeLanguage'
893+ if ( ! options ) options = { } ;
887894 if ( ! Speech . voiceCustomServer ) {
888895 var err = { name : "MissingServerInfo" , message : "Custom Mary-TTS API is missing server URL." } ;
889896 SepiaFW . debug . error ( "Speech.maryTTS - getURL ERROR: " + JSON . stringify ( err ) ) ;
@@ -915,11 +922,18 @@ function sepiaFW_build_speech_synthesis(Speech, sepiaSessionId){
915922 }
916923 }
917924 //console.error("Speech.maryTTS.settings.voice", Speech.maryTTS.settings.voice); //DEBUG
918- var voiceInfo = Speech . maryTTS . settings . voice . split ( / \s + / g) ; //example: "dfki-spike-hsmm en_GB male hmm"
925+ var voiceName ;
926+ //use 'options.oneTimeVoice' and 'options.oneTimeLanguage'?
927+ if ( options . oneTimeVoice && options . oneTimeVoice . name ) {
928+ voiceName = options . oneTimeVoice . name ;
929+ } else {
930+ voiceName = Speech . maryTTS . settings . voice ;
931+ }
932+ var voiceInfo = voiceName . split ( / \s + / g) ; //example: "dfki-spike-hsmm en_GB male hmm"
919933 var apiUrl = Speech . voiceCustomServer . replace ( / \/ $ / , "" ) + "/process"
920934 + "?INPUT_TYPE=TEXT" + "&OUTPUT_TYPE=AUDIO" + "&AUDIO=WAVE_FILE"
921935 + "&LOCALE=" + encodeURIComponent ( voiceInfo [ 1 ] )
922- + "&VOICE=" + encodeURIComponent ( voiceInfo [ 0 ] ) //Larynx special: + ";hifi_gan:vctk_small"
936+ + "&VOICE=" + encodeURIComponent ( voiceInfo [ 0 ] ) //TODO: Larynx special: + ";hifi_gan:vctk_small"
923937 + "&INPUT_TEXT=" + encodeURIComponent ( message )
924938 ;
925939 SepiaFW . debug . info ( "Speech.maryTTS - getURL SUCCESS: " + apiUrl ) ;
@@ -958,7 +972,7 @@ function sepiaFW_build_speech_synthesis(Speech, sepiaSessionId){
958972 voicesArray . push ( {
959973 //default webSpeech voice format:
960974 default : true ,
961- lang : vInfo [ 1 ] ,
975+ lang : vInfo [ 1 ] . replace ( / [ _ ] / g , "-" ) , //make sure this has correct format xx-XX
962976 localService : false ,
963977 name : vString ,
964978 voiceURI : vString
0 commit comments