Menu

I am trying to pass some strings trough espeak and it reads them but it gives me "segmentation fault"

Help
rezaee
2017-12-12
2017-12-12
  • rezaee

    rezaee - 2017-12-12

    This is my code. I want to get 5 strings from the user and espeak reads each of them when user interred it. But I get segmentation fault(core dumped) message.

    #include <string.h>
    #include <malloc.h>
    #include <espeak/speak_lib.h>
    
    int test()
    {
    
    espeak_POSITION_TYPE position_type;
    espeak_AUDIO_OUTPUT output;
    char *path=NULL;
    int Buflength = 500, Options=0;
    void* user_data;
    t_espeak_callback *SynthCallback;
    espeak_PARAMETER Parm;
    
    
    
    char Voice[] = {"English"};
    
    int i=0;
    char text[1000];
    unsigned int Size,position=0, end_position=0, flags=espeakCHARS_AUTO, *unique_identifier;
    
    
        output = AUDIO_OUTPUT_PLAYBACK;
    
        espeak_Initialize(output, Buflength, path, Options ); 
        espeak_SetVoiceByName(Voice);
        const char *langNativeString = "en_US";
        espeak_VOICE voice={0};
    
            voice.languages = langNativeString;
            voice.name = "US";
            voice.variant = 2;
            voice.gender = 1;
           Size = strlen(text)+1;
    
    
    for (i=0; i<5; i++)
    {
    
    scanf("%s ", &text);
    
    printf("%s", text);
    
        espeak_Synth( text, Size, position, position_type, end_position, flags,
        unique_identifier, user_data );
        espeak_Synchronize( );
    fflush(stdout);
    
    }
    
    return 0;
    }
    
    
    
    
    
    
    int main(int argc, char* argv[] ) 
    {
        test();
    
        return 0;
    }
    

    I tried some modification but none of them worked. I want the program works like this:

    User input: hi

    espeak says: hi

    user input: one

    espeak says: one

    (for 5
    inputs)

    But when I try to interring more than 4 characters as input,it gives segmentation fault error!

     
  • Valdis Vitolins

    Valdis Vitolins - 2017-12-12

    I recommend you to use eSpeakNG instead of eSpeak. Look at example code and discussion here:
    https://github.com/espeak-ng/espeak-ng/issues/337

    eSpeak project is inactive since disappearance of Jonathan Duddington.
    Active development and support of issues now happens in espeak-ng project
    https://github.com/espeak-ng/espeak-ng maintained by Reece H. Dunn.
    Mailing list of espeak-ng project is https://groups.io/g/espeak-ng

     

Log in to post a comment.

MongoDB Logo MongoDB