static bool g_utterance_started_cb = false;
static bool g_utterance_completed_cb = false;
static int g_utt_id = -1;
+static char* g_pcm_data = nullptr;
+static long g_pcm_size = 0;
static const char *g_text = "Speech Synthesis is the artificial production of human speech. A computer system used for this purpose is called a speech computer or speech synthesizer,\
and can be implemented in software or hardware products. A text-to-speech (TTS) system converts normal language text into speech; other systems render symbolic linguistic\
representations like phonetic transcriptions into speech.\
return true;
}
+static void __get_test_PCM_Data()
+{
+ const char* pcm_path = tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_APP"), "/org.tizen.tts-unittests/res/test_pcm.dat");
+ FILE* fp_in = fopen(pcm_path, "rb");
+ if (fp_in == nullptr) {
+ return;
+ }
+
+ fseek(fp_in, 0, SEEK_END);
+ long size = ftell(fp_in);
+ fseek(fp_in, 0, SEEK_SET);
+ if (size <= 0) {
+ fclose(fp_in);
+ return;
+ }
+
+ char* data = (char*)calloc(sizeof(char), size);
+ size_t read_size = fread(data, sizeof(char), size, fp_in);
+ fclose(fp_in);
+
+ if (read_size <= 0) {
+ free(data);
+ return;
+ }
+
+ g_pcm_size = size;
+ g_pcm_data = data;
+
+ return;
+}
+
namespace {
class TTSTest : public testing::Test {
g_tts = NULL;
is_created_hndl = -1;
+ free(g_pcm_data);
+ g_pcm_data = nullptr;
+ g_pcm_size = 0;
+
ecore_shutdown();
}
};
EXPECT_EQ(true, __is_state_changed(TTS_STATE_READY, 5));
g_utterance_completed_cb = false;
- const char* pcm_path = tzplatform_mkpath(tzplatform_getid("TZ_SYS_RO_APP"), "/org.tizen.tts-unittests/res/test_pcm.dat");
- FILE* fp_in = fopen(pcm_path, "rb");
- ASSERT_NE(fp_in, nullptr);
-
- fseek(fp_in, 0, SEEK_END);
- size_t size = ftell(fp_in);
- fseek(fp_in, 0, SEEK_SET);
+ __get_test_PCM_Data();
+ ASSERT_NE(g_pcm_data, nullptr);
+ ASSERT_GT(g_pcm_size, 0);
const size_t shift_size = 12000;
- char* data = (char*)calloc(sizeof(char), size);
- size_t read_size = fread(data, sizeof(char), size, fp_in);
- ASSERT_GT(read_size, 0);
-
- int data_num = size / shift_size;
+ int data_num = g_pcm_size / shift_size;
for (int i = 0; i <= data_num; i++ ) {
if (0 == i) {
- EXPECT_EQ(tts_add_pcm(g_tts, 1, &data[i*shift_size], shift_size, 0, g_sample_rate), TTS_ERROR_NONE);
+ EXPECT_EQ(tts_add_pcm(g_tts, 1, &g_pcm_data[i*shift_size], shift_size, 0, g_sample_rate), TTS_ERROR_NONE);
} else if (data_num == i) {
- EXPECT_EQ(tts_add_pcm(g_tts, 3, &data[i*shift_size], size % shift_size, 0, g_sample_rate), TTS_ERROR_NONE);
+ EXPECT_EQ(tts_add_pcm(g_tts, 3, &g_pcm_data[i*shift_size], g_pcm_size % shift_size, 0, g_sample_rate), TTS_ERROR_NONE);
} else {
- EXPECT_EQ(tts_add_pcm(g_tts, 2, &data[i*shift_size], shift_size, 0, g_sample_rate), TTS_ERROR_NONE);
+ EXPECT_EQ(tts_add_pcm(g_tts, 2, &g_pcm_data[i*shift_size], shift_size, 0, g_sample_rate), TTS_ERROR_NONE);
}
}
- free(data);
-
EXPECT_EQ(tts_play_pcm(g_tts), TTS_ERROR_NONE);
EXPECT_EQ(true, __is_state_changed(TTS_STATE_PLAYING, 5));