Send synthesized PCM data from TTS engine to client
[platform/core/uifw/tts.git] / client / tts_core.h
1 /*
2 *  Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
3 *  Licensed under the Apache License, Version 2.0 (the "License");
4 *  you may not use this file except in compliance with the License.
5 *  You may obtain a copy of the License at
6 *  http://www.apache.org/licenses/LICENSE-2.0
7 *  Unless required by applicable law or agreed to in writing, software
8 *  distributed under the License is distributed on an "AS IS" BASIS,
9 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 *  See the License for the specific language governing permissions and
11 *  limitations under the License.
12 */
13
14
15 #ifndef __TTS_CORE_H_
16 #define __TTS_CORE_H_
17
18 #include "tts_client.h"
19 #include "tts_internal.h"
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 // common function
26 int tts_core_notify_state_changed(tts_client_s* client, tts_state_e current_state);
27 int tts_core_notify_utt_started(tts_client_s* client, int utt_id);
28 int tts_core_notify_utt_completeted(tts_client_s* client, int utt_id);
29 int tts_core_notify_error_async(tts_client_s* client, tts_error_e reason, int utt_id, const char* err_msg);
30 int tts_core_notify_default_voice_changed(tts_client_s* client, const char* before_lang, int before_voice_type, const char* language, int voice_type);
31 int tts_core_notify_engine_changed(tts_client_s* client, const char* engine_id, const char* language, int voice_type, bool need_credential);
32 int tts_core_notify_screen_reader_changed(tts_client_s* client, bool value);
33 int tts_core_notify_service_state_changed(tts_client_s* client, tts_service_state_e before_state, tts_service_state_e current_state);
34 int tts_core_notify_synthesized_pcm(tts_client_s* client, int utt_id, tts_synthesized_pcm_event_e event, const char* pcm_data, int pcm_data_size, tts_audio_type_e audio_type, int sample_rate);
35
36 bool tts_core_is_valid_text(const char* text);
37 bool tts_core_check_screen_reader(tts_client_s* client);
38 bool tts_core_check_credential(tts_client_s* client);
39
40 const char* tts_core_covert_error_code(tts_error_e err);
41
42 // called by tts.c
43 int tts_core_initialize();
44 int tts_core_deinitialize();
45
46 int tts_core_prepare(tts_client_s* client);
47 int tts_core_prepare_sync(tts_client_s* client);
48 int tts_core_unprepare(tts_client_s* client);
49 int tts_core_reprepare();
50
51 int tts_core_foreach_supported_voices(tts_client_s* client, const char* engine_id, tts_supported_voice_cb callback, void* user_data);
52
53 // called by tts_ipc
54 int tts_core_add_text(tts_client_s* client, const char* text, const char* language, int voice_type, int speed, int* utt_id);
55 int tts_core_play(tts_client_s* client);
56 int tts_core_stop(tts_client_s* client);
57 int tts_core_pause(tts_client_s* client);
58 int tts_core_repeat(tts_client_s* client, char** text_repeat, int* utt_id);
59
60 int tts_core_add_pcm(tts_client_s* client, int event, const void* data, unsigned int data_size, int audio_type, int rate);
61 int tts_core_play_pcm(tts_client_s* client);
62 int tts_core_stop_pcm(tts_client_s* client);
63
64 int tts_core_set_private_data(tts_client_s* client, const char* key, const char* data);
65 int tts_core_get_private_data(tts_client_s* client, const char* key, char** data);
66
67 int tts_core_get_service_state(tts_client_s* client, tts_service_state_e* service_state);
68
69 int tts_core_receive_hello(unsigned int uid, int ret, tts_service_state_e service_state, int credential_needed);
70 int tts_core_handle_service_reset();
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #endif /* __TTS_CORE_H_ */