Browse Source

Fix the return status code from Synthesize when the voices cannot be found.

master
Reece H. Dunn 7 years ago
parent
commit
8585b0b47d
3 changed files with 71 additions and 2 deletions
  1. 1
    0
      CHANGELOG.md
  2. 1
    1
      src/libespeak-ng/speech.c
  3. 69
    1
      tests/api.c

+ 1
- 0
CHANGELOG.md View File

* Fix running `make clean ; make`. * Fix running `make clean ; make`.
* Fix reading stdin buffers larger than 1000. * Fix reading stdin buffers larger than 1000.
* Fixed various language and parent BCP 47 codes (`jp` is now `ja`). * Fixed various language and parent BCP 47 codes (`jp` is now `ja`).
* Fixed several crashes and bugs in `espeak_SetVoiceByName/Properties`.


new languages: new languages:



+ 1
- 1
src/libespeak-ng/speech.c View File



espeak_ng_STATUS status; espeak_ng_STATUS status;
if (translator == NULL) { if (translator == NULL) {
status = espeak_SetVoiceByName("en");
status = espeak_ng_SetVoiceByName("en");
if (status != ENS_OK) if (status != ENS_OK)
return status; return status;
} }

+ 69
- 1
tests/api.c View File

assert(p_decoder == NULL); assert(p_decoder == NULL);


const char *test = "One two three."; const char *test = "One two three.";
assert(espeak_Synth(test, strlen(test)+1, 0, POS_CHARACTER, 0, espeakCHARS_AUTO, NULL, NULL) == EE_INTERNAL_ERROR);
assert(espeak_Synth(test, strlen(test)+1, 0, POS_CHARACTER, 0, espeakCHARS_AUTO, NULL, NULL) == EE_NOT_FOUND);
assert(translator == NULL);
assert(p_decoder == NULL);

assert(espeak_Synchronize() == EE_OK);
assert(translator == NULL);
assert(p_decoder == NULL);

assert(espeak_Terminate() == EE_OK);
assert(event_list == NULL);
assert(translator == NULL);
assert(p_decoder == NULL);
}

// endregion
// region espeak_ng_Synthesize

void
test_espeak_ng_synthesize()
{
printf("testing espeak_ng_Synthesize\n");

assert(event_list == NULL);
assert(translator == NULL);
assert(p_decoder == NULL);

assert(espeak_Initialize(AUDIO_OUTPUT_RETRIEVAL, 0, NULL, 0) == 22050);
assert(event_list != NULL);
assert(translator == NULL);
assert(p_decoder == NULL);

const char *test = "One two three.";
assert(espeak_ng_Synthesize(test, strlen(test)+1, 0, POS_CHARACTER, 0, espeakCHARS_AUTO, NULL, NULL) == ENS_OK);
assert(translator != NULL);
assert(strcmp(translator->dictionary_name, "en") == 0);
assert(p_decoder != NULL);

assert(espeak_Synchronize() == EE_OK);
assert(translator != NULL);
assert(strcmp(translator->dictionary_name, "en") == 0);
assert(p_decoder != NULL);

assert(espeak_Terminate() == EE_OK);
assert(event_list == NULL);
assert(translator == NULL);
assert(p_decoder == NULL);
}

void
test_espeak_ng_synthesize_no_voices(const char *path)
{
printf("testing espeak_ng_Synthesize in path with no voices\n");

assert(event_list == NULL);
assert(translator == NULL);
assert(p_decoder == NULL);

assert(espeak_Initialize(AUDIO_OUTPUT_RETRIEVAL, 0, path, espeakINITIALIZE_DONT_EXIT) == 22050);
assert(event_list != NULL);
assert(translator == NULL);
assert(p_decoder == NULL);

const char *test = "One two three.";
assert(espeak_ng_Synthesize(test, strlen(test)+1, 0, POS_CHARACTER, 0, espeakCHARS_AUTO, NULL, NULL) == ENS_VOICE_NOT_FOUND);
assert(translator == NULL); assert(translator == NULL);
assert(p_decoder == NULL); assert(p_decoder == NULL);


test_espeak_synth_no_voices(progdir); test_espeak_synth_no_voices(progdir);
test_espeak_synth(); test_espeak_synth();


test_espeak_ng_synthesize();
test_espeak_ng_synthesize(); // Check that this does not crash when run a second time.
test_espeak_ng_synthesize_no_voices(progdir);
test_espeak_ng_synthesize();

test_espeak_set_voice_by_name_null_voice(); test_espeak_set_voice_by_name_null_voice();
test_espeak_set_voice_by_name_blank_voice(); test_espeak_set_voice_by_name_blank_voice();
test_espeak_set_voice_by_name_valid_voice(); test_espeak_set_voice_by_name_valid_voice();

Loading…
Cancel
Save