1616 * If not, see <http://www.gnu.org/licenses/>.
1717 */
1818
19+ #include "accessibility.h"
1920#include <stdio.h>
2021#include <stdint.h>
2122#include <stddef.h>
@@ -2899,7 +2900,8 @@ static const char* accessibility_unix_language_code(const char* language)
28992900 string_is_equal (language , "ta" ) ||
29002901 string_is_equal (language , "te" ) ||
29012902 string_is_equal (language , "ur" ) ||
2902- string_is_equal (language , "cy" )
2903+ string_is_equal (language , "cy" ) ||
2904+ string_is_equal (language , "ca" )
29032905 )
29042906 return language ;
29052907 else if (
@@ -2908,19 +2910,16 @@ static const char* accessibility_unix_language_code(const char* language)
29082910 )
29092911 return "nb" ;
29102912 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" ;
2913+ return "en-GB" ;
2914+ else if (string_is_equal (language , "ca_ES@valencia" ))
2915+ return "ca-VA" ;
29172916 else if (
29182917 string_is_equal (language , "pt_pt" ) ||
29192918 string_is_equal (language , "pt" )
29202919 )
29212920 return "pt" ;
29222921 else if (string_is_equal (language , "pt_bt" ))
2923- return "pt-br " ;
2922+ return "pt-BR " ;
29242923 else if (
29252924 string_is_equal (language , "zh" ) ||
29262925 string_is_equal (language , "zh_cn" ) ||
@@ -2938,27 +2937,69 @@ static const char* accessibility_unix_language_code(const char* language)
29382937static bool accessibility_speak_unix (int speed ,
29392938 const char * speak_text , int priority )
29402939{
2940+ unsigned synthesizer ;
29412941 int pid ;
29422942 const char * language = accessibility_unix_language_code (get_user_language_iso639_1 (true));
29432943 char * voice_out = (char * )malloc (3 + strlen (language ));
29442944 char * speed_out = (char * )malloc (3 + 3 );
29452945 const char * speeds [10 ] = {"80" , "100" , "125" , "150" , "170" , "210" , "260" , "310" , "380" , "450" };
2946+ char * executable = (char * )malloc (16 );
2947+
2948+ settings_t * settings = config_get_ptr ();
2949+ synthesizer = settings -> uints .accessibility_narrator_synthesizer ;
2950+
2951+ switch (synthesizer )
2952+ {
2953+ case ACCESSIBILITY_NARRATOR_SYNTHESIZER_SPEACH_DISPATCHER :
2954+ {
2955+ strlcpy (executable , "spd-say" , 8 );
2956+ speeds [0 ] = "-99" ;
2957+ speeds [1 ] = "-75" ;
2958+ speeds [2 ] = "-50" ;
2959+ speeds [3 ] = "-25" ;
2960+ speeds [4 ] = "0" ;
2961+ speeds [5 ] = "20" ;
2962+ speeds [6 ] = "40" ;
2963+ speeds [7 ] = "60" ;
2964+ speeds [8 ] = "80" ;
2965+ speeds [9 ] = "100" ;
2966+
2967+ voice_out [0 ] = '-' ;
2968+ voice_out [1 ] = 'l' ;
2969+ voice_out [2 ] = '\0' ;
2970+ strlcat (voice_out , language , sizeof (voice_out ));
2971+
2972+ speed_out [0 ] = '-' ;
2973+ speed_out [1 ] = 'r' ;
2974+ speed_out [2 ] = '\0' ;
2975+ strlcat (speed_out , speeds [speed - 1 ], sizeof (speed_out ));
2976+
2977+ break ;
2978+ }
2979+ case ACCESSIBILITY_NARRATOR_SYNTHESIZER_ESPEAK :
2980+ default :
2981+ {
2982+ strlcpy (executable , "espeak" , 7 );
2983+
2984+ voice_out [0 ] = '-' ;
2985+ voice_out [1 ] = 'v' ;
2986+ voice_out [2 ] = '\0' ;
2987+ strlcat (voice_out , language , sizeof (voice_out ));
2988+
2989+ speed_out [0 ] = '-' ;
2990+ speed_out [1 ] = 's' ;
2991+ speed_out [2 ] = '\0' ;
2992+ strlcat (speed_out , speeds [speed - 1 ], sizeof (speed_out ));
2993+
2994+ break ;
2995+ }
2996+ }
29462997
29472998 if (speed < 1 )
29482999 speed = 1 ;
29493000 else if (speed > 10 )
29503001 speed = 10 ;
29513002
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-
29623003 if (priority < 10 && speak_pid > 0 )
29633004 {
29643005 /* check if old pid is running */
@@ -2968,7 +3009,7 @@ static bool accessibility_speak_unix(int speed,
29683009
29693010 if (speak_pid > 0 )
29703011 {
2971- /* Kill the running espeak */
3012+ /* Kill the running TTS Engine */
29723013 kill (speak_pid , SIGTERM );
29733014 speak_pid = 0 ;
29743015 }
@@ -2978,19 +3019,20 @@ static bool accessibility_speak_unix(int speed,
29783019 {
29793020 case 0 :
29803021 {
2981- /* child process: replace process with the espeak command */
2982- char * cmd [] = { (char * ) "espeak" , NULL , NULL , NULL , NULL };
3022+ /* child process: replace process with the TTS command */
3023+ char * cmd [] = { NULL , NULL , NULL , NULL , NULL };
3024+ cmd [0 ] = executable ;
29833025 cmd [1 ] = voice_out ;
29843026 cmd [2 ] = speed_out ;
29853027 cmd [3 ] = (char * )speak_text ;
2986- execvp ("espeak" , cmd );
3028+ execvp (executable , cmd );
29873029
2988- RARCH_WARN ("Could not execute espeak .\n" );
3030+ RARCH_WARN ("Could not execute TTS Engine .\n" );
29893031 /* Prevent interfere with the parent process */
29903032 _exit (EXIT_FAILURE );
29913033 }
29923034 case -1 :
2993- RARCH_ERR ("Could not fork for espeak .\n" );
3035+ RARCH_ERR ("Could not fork for the TTS process .\n" );
29943036 default :
29953037 {
29963038 /* parent process */
@@ -3007,6 +3049,8 @@ static bool accessibility_speak_unix(int speed,
30073049 free (voice_out );
30083050 if (speed_out )
30093051 free (speed_out );
3052+ if (executable )
3053+ free (executable );
30103054 return true;
30113055}
30123056#endif
0 commit comments