51
51
#include <signal.h>
52
52
#include <pthread.h>
53
53
54
+ #if (defined(__linux__ ) || defined(__HAIKU__ ) || defined(__unix__ )) && !defined(ANDROID )
55
+ #include "accessibility.h"
56
+ #endif
57
+
54
58
#ifdef HAVE_CONFIG_H
55
59
#include "../../config.h"
56
60
#endif
@@ -2899,7 +2903,8 @@ static const char* accessibility_unix_language_code(const char* language)
2899
2903
string_is_equal (language , "ta" ) ||
2900
2904
string_is_equal (language , "te" ) ||
2901
2905
string_is_equal (language , "ur" ) ||
2902
- string_is_equal (language , "cy" )
2906
+ string_is_equal (language , "cy" ) ||
2907
+ string_is_equal (language , "ca" )
2903
2908
)
2904
2909
return language ;
2905
2910
else if (
@@ -2908,19 +2913,16 @@ static const char* accessibility_unix_language_code(const char* language)
2908
2913
)
2909
2914
return "nb" ;
2910
2915
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" ;
2917
2919
else if (
2918
2920
string_is_equal (language , "pt_pt" ) ||
2919
2921
string_is_equal (language , "pt" )
2920
2922
)
2921
2923
return "pt" ;
2922
2924
else if (string_is_equal (language , "pt_bt" ))
2923
- return "pt-br " ;
2925
+ return "pt-BR " ;
2924
2926
else if (
2925
2927
string_is_equal (language , "zh" ) ||
2926
2928
string_is_equal (language , "zh_cn" ) ||
@@ -2938,27 +2940,69 @@ static const char* accessibility_unix_language_code(const char* language)
2938
2940
static bool accessibility_speak_unix (int speed ,
2939
2941
const char * speak_text , int priority )
2940
2942
{
2943
+ unsigned synthesizer ;
2941
2944
int pid ;
2942
2945
const char * language = accessibility_unix_language_code (get_user_language_iso639_1 (true));
2943
2946
char * voice_out = (char * )malloc (3 + strlen (language ));
2944
2947
char * speed_out = (char * )malloc (3 + 3 );
2945
2948
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
+ }
2946
3000
2947
3001
if (speed < 1 )
2948
3002
speed = 1 ;
2949
3003
else if (speed > 10 )
2950
3004
speed = 10 ;
2951
3005
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
-
2962
3006
if (priority < 10 && speak_pid > 0 )
2963
3007
{
2964
3008
/* check if old pid is running */
@@ -2968,7 +3012,7 @@ static bool accessibility_speak_unix(int speed,
2968
3012
2969
3013
if (speak_pid > 0 )
2970
3014
{
2971
- /* Kill the running espeak */
3015
+ /* Kill the running TTS Engine */
2972
3016
kill (speak_pid , SIGTERM );
2973
3017
speak_pid = 0 ;
2974
3018
}
@@ -2978,19 +3022,20 @@ static bool accessibility_speak_unix(int speed,
2978
3022
{
2979
3023
case 0 :
2980
3024
{
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 ;
2983
3028
cmd [1 ] = voice_out ;
2984
3029
cmd [2 ] = speed_out ;
2985
3030
cmd [3 ] = (char * )speak_text ;
2986
- execvp ("espeak" , cmd );
3031
+ execvp (executable , cmd );
2987
3032
2988
- RARCH_WARN ("Could not execute espeak .\n" );
3033
+ RARCH_WARN ("Could not execute TTS Engine .\n" );
2989
3034
/* Prevent interfere with the parent process */
2990
3035
_exit (EXIT_FAILURE );
2991
3036
}
2992
3037
case -1 :
2993
- RARCH_ERR ("Could not fork for espeak .\n" );
3038
+ RARCH_ERR ("Could not fork for the TTS process .\n" );
2994
3039
default :
2995
3040
{
2996
3041
/* parent process */
@@ -3007,6 +3052,8 @@ static bool accessibility_speak_unix(int speed,
3007
3052
free (voice_out );
3008
3053
if (speed_out )
3009
3054
free (speed_out );
3055
+ if (executable )
3056
+ free (executable );
3010
3057
return true;
3011
3058
}
3012
3059
#endif
0 commit comments