5151#include <signal.h>
5252#include <pthread.h>
5353
54+ #ifdef HAVE_ACCESSIBILITY
55+ #include "accessibility.h"
56+ #endif
57+
5458#ifdef HAVE_CONFIG_H
5559#include "../../config.h"
5660#endif
@@ -2899,7 +2903,8 @@ static const char* accessibility_unix_language_code(const char* language)
28992903 string_is_equal (language , "ta" ) ||
29002904 string_is_equal (language , "te" ) ||
29012905 string_is_equal (language , "ur" ) ||
2902- string_is_equal (language , "cy" )
2906+ string_is_equal (language , "cy" ) ||
2907+ string_is_equal (language , "ca" )
29032908 )
29042909 return language ;
29052910 else if (
@@ -2908,19 +2913,16 @@ static const char* accessibility_unix_language_code(const char* language)
29082913 )
29092914 return "nb" ;
29102915 else if (string_is_equal (language , "en_gb" ))
2911- return "en-gb" ;
2912- else if (
2913- string_is_equal (language , "ca" ) ||
2914- string_is_equal (language , "ca_ES@valencia" )
2915- )
2916- return "ca" ;
2916+ return "en-GB" ;
2917+ else if (string_is_equal (language , "ca_ES@valencia" ))
2918+ return "ca-VA" ;
29172919 else if (
29182920 string_is_equal (language , "pt_pt" ) ||
29192921 string_is_equal (language , "pt" )
29202922 )
29212923 return "pt" ;
29222924 else if (string_is_equal (language , "pt_bt" ))
2923- return "pt-br " ;
2925+ return "pt-BR " ;
29242926 else if (
29252927 string_is_equal (language , "zh" ) ||
29262928 string_is_equal (language , "zh_cn" ) ||
@@ -2938,27 +2940,69 @@ static const char* accessibility_unix_language_code(const char* language)
29382940static bool accessibility_speak_unix (int speed ,
29392941 const char * speak_text , int priority )
29402942{
2943+ unsigned synthesizer ;
29412944 int pid ;
29422945 const char * language = accessibility_unix_language_code (get_user_language_iso639_1 (true));
29432946 char * voice_out = (char * )malloc (3 + strlen (language ));
29442947 char * speed_out = (char * )malloc (3 + 3 );
29452948 const char * speeds [10 ] = {"80" , "100" , "125" , "150" , "170" , "210" , "260" , "310" , "380" , "450" };
2949+ char * executable = (char * )malloc (16 );
2950+
2951+ settings_t * settings = config_get_ptr ();
2952+ synthesizer = settings -> uints .accessibility_narrator_synthesizer ;
2953+
2954+ switch (synthesizer )
2955+ {
2956+ case ACCESSIBILITY_NARRATOR_SYNTHESIZER_SPEACH_DISPATCHER :
2957+ {
2958+ strlcpy (executable , "spd-say" , 8 );
2959+ speeds [0 ] = "-99" ;
2960+ speeds [1 ] = "-75" ;
2961+ speeds [2 ] = "-50" ;
2962+ speeds [3 ] = "-25" ;
2963+ speeds [4 ] = "0" ;
2964+ speeds [5 ] = "20" ;
2965+ speeds [6 ] = "40" ;
2966+ speeds [7 ] = "60" ;
2967+ speeds [8 ] = "80" ;
2968+ speeds [9 ] = "100" ;
2969+
2970+ voice_out [0 ] = '-' ;
2971+ voice_out [1 ] = 'l' ;
2972+ voice_out [2 ] = '\0' ;
2973+ strlcat (voice_out , language , sizeof (voice_out ));
2974+
2975+ speed_out [0 ] = '-' ;
2976+ speed_out [1 ] = 'r' ;
2977+ speed_out [2 ] = '\0' ;
2978+ strlcat (speed_out , speeds [speed - 1 ], sizeof (speed_out ));
2979+
2980+ break ;
2981+ }
2982+ case ACCESSIBILITY_NARRATOR_SYNTHESIZER_ESPEAK :
2983+ default :
2984+ {
2985+ strlcpy (executable , "espeak" , 7 );
2986+
2987+ voice_out [0 ] = '-' ;
2988+ voice_out [1 ] = 'v' ;
2989+ voice_out [2 ] = '\0' ;
2990+ strlcat (voice_out , language , sizeof (voice_out ));
2991+
2992+ speed_out [0 ] = '-' ;
2993+ speed_out [1 ] = 's' ;
2994+ speed_out [2 ] = '\0' ;
2995+ strlcat (speed_out , speeds [speed - 1 ], sizeof (speed_out ));
2996+
2997+ break ;
2998+ }
2999+ }
29463000
29473001 if (speed < 1 )
29483002 speed = 1 ;
29493003 else if (speed > 10 )
29503004 speed = 10 ;
29513005
2952- voice_out [0 ] = '-' ;
2953- voice_out [1 ] = 'v' ;
2954- voice_out [2 ] = '\0' ;
2955- strlcat (voice_out , language , 3 + strlen (language ));
2956-
2957- speed_out [0 ] = '-' ;
2958- speed_out [1 ] = 's' ;
2959- speed_out [2 ] = '\0' ;
2960- strlcat (speed_out , speeds [speed - 1 ], 6 );
2961-
29623006 if (priority < 10 && speak_pid > 0 )
29633007 {
29643008 /* check if old pid is running */
@@ -2968,7 +3012,7 @@ static bool accessibility_speak_unix(int speed,
29683012
29693013 if (speak_pid > 0 )
29703014 {
2971- /* Kill the running espeak */
3015+ /* Kill the running TTS Engine */
29723016 kill (speak_pid , SIGTERM );
29733017 speak_pid = 0 ;
29743018 }
@@ -2978,19 +3022,20 @@ static bool accessibility_speak_unix(int speed,
29783022 {
29793023 case 0 :
29803024 {
2981- /* child process: replace process with the espeak command */
2982- char * cmd [] = { (char * ) "espeak" , NULL , NULL , NULL , NULL };
3025+ /* child process: replace process with the TTS command */
3026+ char * cmd [] = { NULL , NULL , NULL , NULL , NULL };
3027+ cmd [0 ] = executable ;
29833028 cmd [1 ] = voice_out ;
29843029 cmd [2 ] = speed_out ;
29853030 cmd [3 ] = (char * )speak_text ;
2986- execvp ("espeak" , cmd );
3031+ execvp (executable , cmd );
29873032
2988- RARCH_WARN ("Could not execute espeak .\n" );
3033+ RARCH_WARN ("Could not execute TTS Engine .\n" );
29893034 /* Prevent interfere with the parent process */
29903035 _exit (EXIT_FAILURE );
29913036 }
29923037 case -1 :
2993- RARCH_ERR ("Could not fork for espeak .\n" );
3038+ RARCH_ERR ("Could not fork for the TTS process .\n" );
29943039 default :
29953040 {
29963041 /* parent process */
@@ -3007,6 +3052,8 @@ static bool accessibility_speak_unix(int speed,
30073052 free (voice_out );
30083053 if (speed_out )
30093054 free (speed_out );
3055+ if (executable )
3056+ free (executable );
30103057 return true;
30113058}
30123059#endif
0 commit comments