+++ /dev/null
-Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+\r
+\r
#include "stt_client.h"
#include "stt_dbus.h"
-#define CONNECTION_RETRY_COUNT 3
+#define CONNECTION_RETRY_COUNT 2
-int __check_stt_daemon();
+static int __check_stt_daemon();
int stt_create(stt_h* stt)
{
return STT_ERROR_INVALID_PARAMETER;
}
- /* check stt-daemon. */
- __check_stt_daemon();
-
if (0 == stt_client_get_size()) {
if (0 != stt_dbus_open_connection()) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to open connection\n ");
}
}
+ /* Send hello */
+ if (0 != stt_dbus_request_hello()) {
+ __check_stt_daemon();
+ }
+
if (0 != stt_client_new(stt)) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to create client!!!!!");
return STT_ERROR_OUT_OF_MEMORY;
}
/* request initialization */
- int i = 0;
+ int i = 1;
+ bool silence_supported = false;
+ bool profanity_supported = false;
+ bool punctuation_supported = false;
+
while (1) {
- ret = stt_dbus_request_initialize((*stt)->handle);
+ ret = stt_dbus_request_initialize((*stt)->handle, &silence_supported, &profanity_supported, &punctuation_supported);
if (STT_ERROR_ENGINE_NOT_FOUND == ret) {
stt_client_destroy(*stt);
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : STT Engine Not founded");
return ret;
} else if(0 != ret) {
- sleep(1);
+ usleep(1);
if(CONNECTION_RETRY_COUNT == i) {
stt_client_destroy(*stt);
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to initialize : TIMED OUT");
i++;
} else {
/* success to connect stt-daemon */
+ stt_client_set_option_supported(*stt, silence_supported, profanity_supported, punctuation_supported);
+ SLOG(LOG_DEBUG, TAG_STTC, "Supported options : silence(%s), profanity(%s), punctuation(%s)",
+ silence_supported ? "true" : "false", profanity_supported ? "true" : "false", punctuation_supported ? "true" : "false");
break;
}
}
return STT_ERROR_INVALID_PARAMETER;
}
- if (type >= STT_OPTION_PROFANITY_FALSE && type <= STT_OPTION_PROFANITY_AUTO)
- client->profanity = type;
- else {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
- return STT_ERROR_INVALID_PARAMETER;
+ if (true == client->profanity_supported) {
+ if (type >= STT_OPTION_PROFANITY_FALSE && type <= STT_OPTION_PROFANITY_AUTO)
+ client->profanity = type;
+ else {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
+ return STT_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ return STT_ERROR_NOT_SUPPORTED_FEATURE;
}
return STT_ERROR_NONE;
return STT_ERROR_INVALID_PARAMETER;
}
- if (type >= STT_OPTION_PUNCTUATION_FALSE && type <= STT_OPTION_PUNCTUATION_AUTO)
- client->punctuation = type;
- else {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
- return STT_ERROR_INVALID_PARAMETER;
+ if (true == client->punctuation_supported) {
+ if (type >= STT_OPTION_PUNCTUATION_FALSE && type <= STT_OPTION_PUNCTUATION_AUTO)
+ client->punctuation = type;
+ else {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
+ return STT_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ return STT_ERROR_NOT_SUPPORTED_FEATURE;
}
return STT_ERROR_NONE;
return STT_ERROR_INVALID_PARAMETER;
}
- if (type >= STT_OPTION_SILENCE_DETECTION_FALSE && type <= STT_OPTION_SILENCE_DETECTION_AUTO)
- client->silence = type;
- else {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
- return STT_ERROR_INVALID_PARAMETER;
+ if (true == client->silence_supported) {
+ if (type >= STT_OPTION_SILENCE_DETECTION_FALSE && type <= STT_OPTION_SILENCE_DETECTION_AUTO)
+ client->silence = type;
+ else {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Type is invalid");
+ return STT_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ return STT_ERROR_NOT_SUPPORTED_FEATURE;
}
return STT_ERROR_NONE;
static bool __stt_is_alive()
{
FILE *fp = NULL;
- char buff[256];
- char cmd[256];
- int i=0;
+ char buff[256] = {'\0',};
+ char cmd[256] = {'\0',};
memset(buff, '\0', 256);
memset(cmd, '\0', 256);
- if ((fp = popen("ps -eo \"cmd\"", "r")) == NULL) {
- SLOG(LOG_DEBUG, TAG_STTC, "[ERROR] popen error \n");
+ fp = popen("ps", "r");
+ if (NULL == fp) {
+ SLOG(LOG_DEBUG, TAG_STTC, "[STT SETTING ERROR] popen error \n");
return FALSE;
}
- while(fgets(buff, 255, fp)) {
- if (i == 0) {
- i++;
- continue;
- }
-
- sscanf(buff, "%s", cmd);
+ while (fgets(buff, 255, fp)) {
+ strcpy(cmd, buff + 26);
if( 0 == strncmp(cmd, "[stt-daemon]", strlen("[stt-daemon]")) ||
- 0 == strncmp(cmd, "stt-daemon", strlen("stt-daemon")) ||
- 0 == strncmp(cmd, "/usr/bin/stt-daemon", strlen("/usr/bin/stt-daemon"))
- ) {
+ 0 == strncmp(cmd, "stt-daemon", strlen("stt-daemon")) ||
+ 0 == strncmp(cmd, "/usr/bin/stt-daemon", strlen("/usr/bin/stt-daemon"))) {
+ SLOG(LOG_DEBUG, TAG_STTC, "stt-daemon is ALIVE !! \n");
fclose(fp);
return TRUE;
}
- i++;
}
+
fclose(fp);
+ SLOG(LOG_DEBUG, TAG_STTC, "THERE IS NO stt-daemon !! \n");
+
return FALSE;
}
+
static void __my_sig_child(int signo, siginfo_t *info, void *data)
{
int status;
return 0;
/* fork-exec stt-daemon */
- SLOG(LOG_DEBUG, TAG_STTC, "THERE IS NO stt-daemon \n");
-
int pid, i;
struct sigaction act, dummy;
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __STT_H__
#define __STT_H__
STT_ERROR_INVALID_STATE = -0x0100031, /**< Invalid state */
STT_ERROR_INVALID_LANGUAGE = -0x0100032, /**< Invalid language */
STT_ERROR_ENGINE_NOT_FOUND = -0x0100033, /**< No available engine */
- STT_ERROR_OPERATION_FAILED = -0x0100034 /**< Operation failed */
+ STT_ERROR_OPERATION_FAILED = -0x0100034, /**< Operation failed */
+ STT_ERROR_NOT_SUPPORTED_FEATURE = -0x0100035 /**< Not supported feature of current engine */
}stt_error_e;
/**
*/
#define STT_RECOGNITION_TYPE_COMMAND_TTS "stt.recognition.type.COMMAND.TTS"
+/**
+* @brief Result message : None message
+*/
+#define STT_RESULT_MESSAGE_NONE "stt.result.message.none"
+
+/**
+* @brief Result warning message : The speech has started too soon
+*/
+#define STT_RESULT_MESSAGE_WARNING_TOO_SOON "stt.result.message.warning.too.soon"
+
+/**
+* @brief Result warning message : The speech is too short
+*/
+#define STT_RESULT_MESSAGE_WARNING_TOO_SHORT "stt.result.message.warning.too.short"
+
+/**
+* @brief Result warning message : The speech is too long
+*/
+#define STT_RESULT_MESSAGE_WARNING_TOO_LONG "stt.result.message.warning.too.long"
+
+/**
+* @brief Result warning message : The speech is too quiet to listen
+*/
+#define STT_RESULT_MESSAGE_WARNING_TOO_QUIET "stt.result.message.warning.too.quiet"
+
+/**
+* @brief Result warning message : The speech is too loud to listen
+*/
+#define STT_RESULT_MESSAGE_WARNING_TOO_LOUD "stt.result.message.warning.too.loud"
+
+/**
+* @brief Result warning message : The speech is too fast to listen
+*/
+#define STT_RESULT_MESSAGE_WARNING_TOO_FAST "stt.result.message.warning.too.fast"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too soon
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_SOON "stt.result.message.error.too.soon"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too short
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_SHORT "stt.result.message.error.too.short"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too long
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_LONG "stt.result.message.error.too.long"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too quiet to listen
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_QUIET "stt.result.message.error.too.quiet"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too loud to listen
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_LOUD "stt.result.message.error.too.loud"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too fast to listen
+*/
+#define STT_RESULT_MESSAGE_ERROR_TOO_FAST "stt.result.message.error.too.fast"
+
+
/**
* @brief Enumerations of state.
*/
* this function is called.
*
* @param[in] stt The handle for STT
-* @param[in] type Recognition type
-* @param[in] data Result data
-* @param[in] data_count Result count
-* @param[in] msg Engine message
+* @param[in] type Recognition type (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_COMMAND)
+* @param[in] data Result texts
+* @param[in] data_count Result text count
+* @param[in] msg Engine message (e.g. #STT_RESULT_MESSAGE_WARNING_TOO_SOON, #STT_RESULT_MESSAGE_ERROR_TOO_SHORT)
* @param[in] user_data The user data passed from the callback registration function
*
* @pre stt_stop() will invoke this callback if you register it using stt_set_result_cb().
*
* @param[in] stt The handle for STT
* @param[in] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n
-* followed by ISO 639-1 for the two-letter language code. \n
-* For example, "ko_KR" for Korean, "en_US" for American English.
+* followed by ISO 639-1 for the two-letter language code. \n
+* For example, "ko_KR" for Korean, "en_US" for American English.
* @param[in] user_data The user data passed from the foreach function
*
* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
*
* @param[in] stt The handle for STT
* @param[out] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n
-* followed by ISO 639-1 for the two-letter language code. \n
-* For example, "ko_KR" for Korean, "en_US" for American English.
+* followed by ISO 639-1 for the two-letter language code. \n
+* For example, "ko_KR" for Korean, "en_US" for American English.
*
* @return 0 on success, otherwise a negative error value
* @retval #STT_ERROR_NONE Successful
* @retval #STT_ERROR_NONE Successful
* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #STT_ERROR_INVALID_STATE Invalid state
+* @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
*
* @pre The state should be #STT_STATE_READY.
*/
* @retval #STT_ERROR_NONE Successful
* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #STT_ERROR_INVALID_STATE Invalid state
+* @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
*
* @pre The state should be #STT_STATE_READY.
*/
* @retval #STT_ERROR_NONE Successful
* @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #STT_ERROR_INVALID_STATE Invalid state
+* @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
*
* @pre The state should be #STT_STATE_READY.
*/
/**
* @brief Starts recording and recognition.
*
-* @remark This function starts recording in the daemon and sending recording data to engine.
-* This work continues until stt_stop(), stt_cancel() or silence detected.
+* @remark This function starts recording in the daemon and sending recording data to engine. \n
+* This work continues until stt_stop(), stt_cancel() or silence detected.
*
* @param[in] stt The handle for STT
* @param[in] language The language selected from stt_foreach_supported_languages()
-* @param[in] type The type for recognition (e.g. #RECOGNITION_TYPE_FREE, #RECOGNITION_TYPE_WEB_SEARCH)
+* @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_WEB_SEARCH)
*
* @return 0 on success, otherwise a negative error value
* @retval #STT_ERROR_NONE Successful
* @retval #STT_ERROR_INVALID_LANGUAGE Invalid language
*
* @pre The state should be #STT_STATE_READY.
-* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
-* If this function succeeds, the STT state will be #STT_STATE_RECORDING.
+* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
+* If this function succeeds, the STT state will be #STT_STATE_RECORDING.
*
* @see stt_stop()
* @see stt_cancel()
* @retval #STT_ERROR_OPERATION_FAILED Operation failure
*
* @pre The state should be #STT_STATE_RECORDING.
-* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
-* If this function succeeds, the STT state will be #STT_STATE_PROCESSING.
-* After processing of engine, stt_result_cb() is called.
+* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
+* If this function succeeds, the STT state will be #STT_STATE_PROCESSING. \n
+* After processing of engine, stt_result_cb() is called.
*
* @see stt_start()
* @see stt_cancel()
/**
* @brief Cancels processing recognition and recording.
*
-* @remark This function cancels recording and engine cancels recognition processing.
-* After successful cancel, stt_state_changed_cb() is called otherwise
-* if error is occurred, stt_error_cb() is called.
+* @remark This function cancels recording and engine cancels recognition processing. \n
+* After successful cancel, stt_state_changed_cb() is called otherwise if error is occurred, stt_error_cb() is called.
*
* @param[in] stt The handle for STT
*
* @retval #STT_ERROR_OPERATION_FAILED Operation failure
*
* @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING.
-* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb().
-* If this function succeeds, the STT state will be #STT_STATE_READY.
+* @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
+* If this function succeeds, the STT state will be #STT_STATE_READY.
*
* @see stt_start()
* @see stt_stop()
client->error_cb = NULL;
client->error_user_data = NULL;
+ client->silence_supported = false;
+ client->profanity_supported = false;
+ client->punctuation_supported = false;
+
client->profanity = STT_OPTION_PROFANITY_AUTO;
client->punctuation = STT_OPTION_PUNCTUATION_AUTO;
client->silence = STT_OPTION_SILENCE_DETECTION_AUTO;
}
+int stt_client_set_option_supported(stt_h stt, bool silence, bool profanity, bool punctuation)
+{
+ stt_client_s* client = stt_client_get(stt);
+
+ /* check handle */
+ if (NULL == client)
+ return STT_ERROR_INVALID_PARAMETER;
+
+ client->silence_supported = silence;
+ client->profanity_supported = profanity;
+ client->punctuation_supported = punctuation;
+
+ return 0;
+}
+
void* error_user_data;
/* option */
+ bool silence_supported;
+ bool profanity_supported;
+ bool punctuation_supported;
+
stt_option_profanity_e profanity;
stt_option_punctuation_e punctuation;
stt_option_silence_detection_e silence;
int stt_client_not_use_callback(stt_client_s* client);
+int stt_client_set_option_supported(stt_h stt, bool silence, bool profanity, bool punctuation);
+
#ifdef __cplusplus
}
#endif
#include <Ecore.h>
+static int g_waiting_time = 1500;
+static int g_waiting_start_time = 2000;
+
static Ecore_Fd_Handler* g_fd_handler = NULL;
static DBusConnection* g_conn = NULL;
{
DBusConnection* conn = (DBusConnection*)data;
DBusMessage* msg = NULL;
+ DBusMessage *reply = NULL;
if (NULL == conn)
return ECORE_CALLBACK_RENEW;
DBusError err;
dbus_error_init(&err);
+
char if_name[64];
snprintf(if_name, 64, "%s%d", STT_CLIENT_SERVICE_INTERFACE, getpid());
- if( dbus_message_is_signal(msg, if_name, STT_SIGNAL_RESULT)) {
+ if (dbus_message_is_method_call(msg, if_name, STT_METHOD_RESULT)) {
SLOG(LOG_DEBUG, TAG_STTC, "===== Get Result");
int uid = 0;
DBusMessageIter args;
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get result : invalid uid \n");
}
+
+ reply = dbus_message_new_method_return(msg);
+ dbus_connection_send(conn, reply, NULL);
+ dbus_connection_flush(conn);
+ dbus_message_unref(reply);
+
SLOG(LOG_DEBUG, TAG_STTC, "=====");
SLOG(LOG_DEBUG, TAG_STTC, " ");
- }/* STT_SIGNAL_RESULT */
+ }/* STT_METHOD_RESULT */
- else if( dbus_message_is_signal(msg, if_name, STT_SIGNAL_PARTIAL_RESULT)) {
+ else if (dbus_message_is_method_call(msg, if_name, STT_METHOD_PARTIAL_RESULT)) {
SLOG(LOG_DEBUG, TAG_STTC, "===== Get Partial Result");
int uid = 0;
DBusMessageIter args;
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get partial result : invalid uid \n");
}
+ reply = dbus_message_new_method_return(msg);
+ dbus_connection_send(conn, reply, NULL);
+ dbus_connection_flush(conn);
+ dbus_message_unref(reply);
+
SLOG(LOG_DEBUG, TAG_STTC, "=====");
SLOG(LOG_DEBUG, TAG_STTC, " ");
- }/* STT_SIGNAL_PARTIAL_RESULT */
+ }/* STT_METHOD_PARTIAL_RESULT */
- else if( dbus_message_is_signal(msg, if_name, STT_SIGNAL_STOP)) {
+ else if (dbus_message_is_method_call(msg, if_name, STT_METHOD_STOPED)) {
SLOG(LOG_DEBUG, TAG_STTC, "===== Get Silence Detection");
int uid;
dbus_message_get_args(msg, &err,
SLOG(LOG_DEBUG, TAG_STTC, "<<<< Get stop by daemon signal : uid(%d)\n", uid);
__stt_cb_stop_by_daemon(uid);
}
+
+ reply = dbus_message_new_method_return(msg);
+ dbus_connection_send(conn, reply, NULL);
+ dbus_connection_flush(conn);
+ dbus_message_unref(reply);
+
SLOG(LOG_DEBUG, TAG_STTC, "=====");
SLOG(LOG_DEBUG, TAG_STTC, " ");
- }/* STT_SIGNAL_STOP */
+ }/* STT_METHOD_STOP */
- else if( dbus_message_is_signal(msg, if_name, STT_SIGNAL_ERROR)) {
+ else if (dbus_message_is_method_call(msg, if_name, STT_METHOD_ERROR)) {
SLOG(LOG_DEBUG, TAG_STTC, "===== Get Error");
int uid;
int reason;
SLOG(LOG_DEBUG, TAG_STTC, "<<<< Get Error signal : uid(%d), reason(%d), msg(%s)\n", uid, reason, err_msg);
__stt_cb_error(uid, reason);
}
+
+ reply = dbus_message_new_method_return(msg);
+ dbus_connection_send(conn, reply, NULL);
+ dbus_connection_flush(conn);
+ dbus_message_unref(reply);
+
SLOG(LOG_DEBUG, TAG_STTC, "=====");
SLOG(LOG_DEBUG, TAG_STTC, " ");
- }/* STT_SIGNAL_ERROR */
+ }/* STT_METHOD_ERROR */
/* free the message */
dbus_message_unref(msg);
return 0;
}
-int stt_dbus_request_initialize(int uid)
+int stt_dbus_request_hello()
+{
+ DBusMessage* msg;
+
+ msg = dbus_message_new_method_call(
+ STT_SERVER_SERVICE_NAME,
+ STT_SERVER_SERVICE_OBJECT_PATH,
+ STT_SERVER_SERVICE_INTERFACE,
+ STT_METHOD_HELLO);
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_STTC, ">>>> Request stt hello : Fail to make message \n");
+ return STT_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request stt hello");
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ DBusMessage* result_msg = NULL;
+ int result = 0;
+
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 500, &err);
+
+ dbus_message_unref(msg);
+
+ if (NULL != result_msg) {
+ dbus_message_unref(result_msg);
+
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt hello");
+ result = 0;
+ } else {
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< stt hello : no response");
+ result = STT_ERROR_OPERATION_FAILED;
+ }
+
+ return result;
+}
+
+
+int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* profanity_supported, bool* punctuation_supported)
{
DBusMessage* msg;
DBusMessage* result_msg;
int result = STT_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
- dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+ dbus_message_get_args(result_msg, &err,
+ DBUS_TYPE_INT32, &result,
+ DBUS_TYPE_INT32, silence_supported,
+ DBUS_TYPE_INT32, profanity_supported,
+ DBUS_TYPE_INT32, punctuation_supported,
+ DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)\n", err.message);
}
if (0 == result) {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d \n", result);
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d , silence(%d), profanity(%d), punctuation(%d)",
+ result, *silence_supported, *profanity_supported, *punctuation_supported);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< stt initialize : result = %d \n", result);
}
DBusMessage* result_msg;
int result = STT_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBusMessageIter args;
int result = STT_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err );
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err );
if (NULL != result_msg) {
if (dbus_message_iter_init(result_msg, &args)) {
int result = STT_ERROR_OPERATION_FAILED;
char* temp_lang = NULL;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
int result = STT_ERROR_OPERATION_FAILED;
int support = -1;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBusMessage* result_msg;
int result = STT_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_start_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBusMessage* result_msg;
int result = STT_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBusMessage* result_msg;
int result = STT_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
int result = STT_ERROR_OPERATION_FAILED;
double vol = 0;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
int stt_dbus_close_connection();
-int stt_dbus_request_initialize(int uid);
+int stt_dbus_request_hello();
+
+int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* profanity_supported, bool* punctuation_supported);
int stt_dbus_request_finalize(int uid);
#include "stt_setting.h"
#include "stt_setting_dbus.h"
+#define CONNECTION_RETRY_COUNT 2
+
static bool g_is_setting_initialized = false;
static int __check_stt_daemon();
SLOG(LOG_DEBUG, TAG_STTC, "===== Initialize STT Setting");
int ret = 0;
-
- /* Check daemon */
- __check_stt_daemon();
-
if (true == g_is_setting_initialized) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] STT Setting has already been initialized. \n");
+ SLOG(LOG_WARN, TAG_STTC, "[WARNING] STT Setting has already been initialized. \n");
SLOG(LOG_DEBUG, TAG_STTC, "=====");
SLOG(LOG_DEBUG, TAG_STTC, " ");
- return STT_SETTING_ERROR_INVALID_STATE;
+ return STT_SETTING_ERROR_NONE;
}
if (0 != stt_setting_dbus_open_connection()) {
return STT_SETTING_ERROR_OPERATION_FAILED;
}
+ /* Send hello */
+ if (0 != stt_setting_dbus_request_hello()) {
+ __check_stt_daemon();
+ }
+
/* do request */
- int i = 0;
+ int i = 1;
while(1) {
ret = stt_setting_dbus_request_initialize();
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Engine not found");
break;
} else if(ret) {
- sleep(1);
- if (i == 10) {
+ usleep(1);
+ if (i == CONNECTION_RETRY_COUNT) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Connection Time out");
ret = STT_SETTING_ERROR_TIMED_OUT;
break;
}
}
- if (0 == ret) {
+ if (STT_SETTING_ERROR_NONE == ret) {
g_is_setting_initialized = true;
SLOG(LOG_DEBUG, TAG_STTC, "[SUCCESS] Initialize");
}
int ret = 0;
if (false == g_is_setting_initialized) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Not initialized");
+ SLOG(LOG_WARN, TAG_STTC, "[WARNING] Not initialized");
SLOG(LOG_DEBUG, TAG_STTC, "=====");
SLOG(LOG_DEBUG, TAG_STTC, " ");
- return STT_SETTING_ERROR_INVALID_STATE;
+ return STT_SETTING_ERROR_NONE;
}
ret = stt_setting_dbus_request_finalilze();
FILE *fp = NULL;
char buff[256] = {'\0',};
char cmd[256] = {'\0',};
- int i=0;
- memset(buff, '\0', sizeof(char));
- memset(cmd, '\0', sizeof(char));
+ memset(buff, '\0', sizeof(char) * 256);
+ memset(cmd, '\0', sizeof(char) * 256);
- if ((fp = popen("ps -eo \"cmd\"", "r")) == NULL) {
- SLOG(LOG_DEBUG, TAG_STTC, "[STT ERROR] popen error \n");
+ fp = popen("ps", "r");
+ if (NULL == fp) {
+ SLOG(LOG_DEBUG, TAG_STTC, "[STT SETTING ERROR] popen error \n");
return FALSE;
}
while (fgets(buff, 255, fp)) {
- if (i == 0) {
- i++;
- continue;
- }
-
- sscanf(buff, "%s", cmd);
+ strcpy(cmd, buff + 26);
if( 0 == strncmp(cmd, "[stt-daemon]", strlen("[stt-daemon]")) ||
- 0 == strncmp(cmd, "stt-daemon", strlen("stt-daemon")) ||
- 0 == strncmp(cmd, "/usr/bin/stt-daemon", strlen("/usr/bin/stt-daemon"))
- ) {
+ 0 == strncmp(cmd, "stt-daemon", strlen("stt-daemon")) ||
+ 0 == strncmp(cmd, "/usr/bin/stt-daemon", strlen("/usr/bin/stt-daemon"))) {
SLOG(LOG_DEBUG, TAG_STTC, "stt-daemon is ALIVE !! \n");
fclose(fp);
return TRUE;
}
-
- i++;
}
+
fclose(fp);
SLOG(LOG_DEBUG, TAG_STTC, "THERE IS NO stt-daemon !! \n");
return 0;
/* fork-exec stt-daemom */
- SLOG(LOG_DEBUG, TAG_STTC, "THERE IS NO stt-daemon \n");
-
int pid = 0, i = 0;
struct sigaction act, dummy;
act.sa_handler = NULL;
switch(pid) {
case -1:
- SLOG(LOG_DEBUG, TAG_STTC, "fail to create STT-DAEMON \n");
+ SLOG(LOG_DEBUG, TAG_STTC, "Fail to create stt-daemon");
break;
case 0:
#include "stt_main.h"
#include "stt_setting_dbus.h"
+static int g_waiting_time = 1500;
+
static DBusConnection* g_conn = NULL;
int stt_setting_dbus_open_connection()
return 0;
}
+
+int stt_setting_dbus_request_hello()
+{
+ DBusMessage* msg;
+
+ msg = dbus_message_new_method_call(
+ STT_SERVER_SERVICE_NAME,
+ STT_SERVER_SERVICE_OBJECT_PATH,
+ STT_SERVER_SERVICE_INTERFACE,
+ STT_SETTING_METHOD_HELLO);
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting hello : Fail to make message \n");
+ return STT_SETTING_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting hello");
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ DBusMessage* result_msg = NULL;
+ int result = 0;
+
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 500, &err);
+
+ dbus_message_unref(msg);
+
+ if (NULL != result_msg) {
+ dbus_message_unref(result_msg);
+
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting hello");
+ result = 0;
+ } else {
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< setting hello : no response");
+ result = -1;
+ }
+
+ return result;
+}
+
int stt_setting_dbus_request_initialize()
{
DBusMessage* msg;
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
DBusMessageIter args;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
char* temp;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_STRING, &temp, DBUS_TYPE_INVALID);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
DBusMessageIter args;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
char* temp_char;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
DBusMessageIter args;
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL == result_msg) {
dbus_message_unref(msg);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
- result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 3000, &err);
+ result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
* Message Definition for APIs
*******************************************************************************************/
+#define STT_METHOD_HELLO "stt_method_hello"
#define STT_METHOD_INITIALIZE "stt_method_initialize"
#define STT_METHOD_FINALIZE "stt_method_finalilze"
#define STT_METHOD_GET_SUPPORT_LANGS "stt_method_get_support_langs"
#define STT_METHOD_STOP "stt_method_stop"
#define STT_METHOD_CANCEL "stt_method_cancel"
-#define STT_SIGNAL_RESULT "stt_signal_result"
-#define STT_SIGNAL_PARTIAL_RESULT "stt_signal_partial_result"
-#define STT_SIGNAL_STOP "stt_signal_stop"
-#define STT_SIGNAL_ERROR "stt_signal_error"
-
-#define STT_SIGNAL_STOP_BY_DAEMON "STT_SIGNAL_STOP_BY_DAEMON"
+#define STT_METHOD_RESULT "sttd_method_result"
+#define STT_METHOD_PARTIAL_RESULT "sttd_method_partial_result"
+#define STT_METHOD_STOPED "sttd_method_stop"
+#define STT_METHOD_ERROR "sttd_method_error"
+#define STTD_METHOD_STOP_BY_DAEMON "sttd_method_stop_by_daemon"
/******************************************************************************************
* Message Definition for Setting
*******************************************************************************************/
+#define STT_SETTING_METHOD_HELLO "stt_setting_method_hello"
#define STT_SETTING_METHOD_INITIALIZE "stt_setting_method_initialize"
#define STT_SETTING_METHOD_FINALIZE "stt_setting_method_finalilze"
#define STT_SETTING_METHOD_GET_ENGINE_LIST "stt_setting_method_get_engine_list"
-stt (0.1.1) unstable; urgency=low
+stt (0.1.1-1) unstable; urgency=low
- * Beta release
- * Git: tizen2/pkgs/s/stt
- * Tag: stt_0.1.1
+ * 1.0 release
+ * Git: pkgs/s/stt
+ * Tag: stt_0.1.1-1
- -- Dongyeol Lee <dy3.lee@samsung.com> Fri, 17 Feb 2012 13:49:31 +0900
+ -- Dongyeol Lee <dy3.lee@samsung.com> Mon, 19 Mar 2012 10:54:03 +0900
Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
Version: 0.1.1
Release: 1
Group: libs
-License: Apache-2.0
-Source0: %{name}-%{version}.tar.gz
+License: Samsung
+Source0: stt-0.1.1.tar.gz
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(glib-2.0)
make %{?jobs:-j%jobs}
%install
+rm -rf %{buildroot}
%make_install
%files
+%defattr(-,root,root,-)
%{_libdir}/libstt.so
%{_libdir}/libstt_setting.so
%{_bindir}/stt-daemon
%files devel
+%defattr(-,root,root,-)
%{_libdir}/pkgconfig/stt.pc
%{_libdir}/pkgconfig/stt-setting.pc
%{_includedir}/stt.h
return -1;
}
+ char service_name[64];
+ memset(service_name, 0, 64);
+ snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
+
char target_if_name[128];
snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send result signal : uid(%d), type(%s), result count(%d)", uid, type, data_count);
- msg = dbus_message_new_signal(
- STT_CLIENT_SERVICE_OBJECT_PATH,
- target_if_name,
- STT_SIGNAL_RESULT );
+ msg = dbus_message_new_method_call(
+ service_name,
+ STT_CLIENT_SERVICE_OBJECT_PATH,
+ target_if_name,
+ STT_METHOD_RESULT);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message");
return -1;
}
+ char service_name[64];
+ memset(service_name, 0, 64);
+ snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
+
char target_if_name[128];
snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
DBusMessage* msg;
SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send result signal : uid(%d), result(%s)", uid, data);
-
- msg = dbus_message_new_signal(
- STT_CLIENT_SERVICE_OBJECT_PATH,
- target_if_name,
- STT_SIGNAL_PARTIAL_RESULT );
+
+ msg = dbus_message_new_method_call(
+ service_name,
+ STT_CLIENT_SERVICE_OBJECT_PATH,
+ target_if_name,
+ STT_METHOD_PARTIAL_RESULT);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message");
return -1;
}
+ char service_name[64];
+ memset(service_name, 0, 64);
+ snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
+
char target_if_name[128];
snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
DBusMessage* msg;
SLOG(LOG_DEBUG, TAG_STTD, "[Dbus] send error signal : reason(%d), Error Msg(%s)", reason, err_msg);
- msg = dbus_message_new_signal(
- STT_CLIENT_SERVICE_OBJECT_PATH, /* object name of the signal */
- target_if_name, /* interface name of the signal */
- STT_SIGNAL_ERROR ); /* name of the signal */
+
+ msg = dbus_message_new_method_call(
+ service_name,
+ STT_CLIENT_SERVICE_OBJECT_PATH,
+ target_if_name,
+ STT_METHOD_PARTIAL_RESULT);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create message");
return -1;
}
+ char service_name[64];
+ memset(service_name, 0, 64);
+ snprintf(service_name, 64, "%s%d", STT_CLIENT_SERVICE_NAME, pid);
+
char target_if_name[64];
snprintf(target_if_name, sizeof(target_if_name), "%s%d", STT_CLIENT_SERVICE_INTERFACE, pid);
DBusMessage* msg;
- /* create a signal & check for errors */
- msg = dbus_message_new_signal(
- STT_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */
- target_if_name, /* interface name of the signal */
- STT_SIGNAL_STOP ); /* name of the signal */
+ msg = dbus_message_new_method_call(
+ service_name,
+ STT_CLIENT_SERVICE_OBJECT_PATH,
+ target_if_name,
+ STT_METHOD_STOPED);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] Fail to create stop message");
/* daemon internal event */
- if (dbus_message_is_signal(msg, STT_SERVER_SERVICE_INTERFACE, STT_SIGNAL_STOP_BY_DAEMON))
+ if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STTD_METHOD_STOP_BY_DAEMON))
sttd_dbus_server_stop_by_daemon(msg);
/* client event */
+ else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_HELLO))
+ sttd_dbus_server_hello(conn, msg);
+
else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_METHOD_INITIALIZE))
sttd_dbus_server_initialize(conn, msg);
/* setting event */
+ else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_HELLO))
+ sttd_dbus_server_hello(conn, msg);
+
else if (dbus_message_is_method_call(msg, STT_SERVER_SERVICE_INTERFACE, STT_SETTING_METHOD_INITIALIZE))
sttd_dbus_server_setting_initialize(conn, msg);
{
DBusMessage* msg;
- msg = dbus_message_new_signal(
- STT_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */
- STT_SERVER_SERVICE_INTERFACE, /* interface name of the signal */
- STT_SIGNAL_STOP_BY_DAEMON ); /* name of the signal */
+ msg = dbus_message_new_method_call(
+ STT_SERVER_SERVICE_NAME,
+ STT_SERVER_SERVICE_OBJECT_PATH,
+ STT_SERVER_SERVICE_INTERFACE,
+ STTD_METHOD_STOP_BY_DAEMON);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTD, "[Dbus ERROR] >>>> Fail to make message for 'stop by daemon'");
* Dbus Client-Daemon Server
*/
+int sttd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg)
+{
+ SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Hello");
+
+ DBusMessage* reply;
+ reply = dbus_message_new_method_return(msg);
+
+ if (NULL != reply) {
+ if (!dbus_connection_send(conn, reply, NULL)) {
+ SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Out Of Memory!");
+ }
+
+ dbus_connection_flush(conn);
+ dbus_message_unref(reply);
+ } else {
+ SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Fail to create reply message!!");
+ }
+
+ SLOG(LOG_DEBUG, TAG_STTD, "<<<<<");
+ SLOG(LOG_DEBUG, TAG_STTD, " ");
+
+ return 0;
+}
+
int sttd_dbus_server_initialize(DBusConnection* conn, DBusMessage* msg)
{
DBusError err;
int pid;
int uid;
+ bool silence_supported = false;
+ bool profanity_supported = false;
+ bool punctuation_supported = false;
+
int ret = STTD_ERROR_OPERATION_FAILED;
dbus_message_get_args(msg, &err,
ret = STTD_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt initialize : pid(%d), uid(%d)", pid , uid);
- ret = sttd_server_initialize(pid, uid);
+ ret = sttd_server_initialize(pid, uid, &silence_supported, &profanity_supported, &punctuation_supported);
}
DBusMessage* reply;
reply = dbus_message_new_method_return(msg);
if (NULL != reply) {
- dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+ dbus_message_append_args(reply,
+ DBUS_TYPE_INT32, &ret,
+ DBUS_TYPE_INT32, &silence_supported,
+ DBUS_TYPE_INT32, &profanity_supported,
+ DBUS_TYPE_INT32, &punctuation_supported,
+ DBUS_TYPE_INVALID);
if (0 == ret) {
- SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d)", ret);
+ SLOG(LOG_DEBUG, TAG_STTD, "[OUT SUCCESS] Result(%d), silence(%d), profanity(%d), punctuation(%d)",
+ ret, silence_supported, profanity_supported, punctuation_supported);
} else {
SLOG(LOG_ERROR, TAG_STTD, "[OUT ERROR] Result(%d)", ret);
}
#include <dbus/dbus.h>
+
+int sttd_dbus_server_hello(DBusConnection* conn, DBusMessage* msg);
+
/*
* Dbus Server functions for APIs
*/
bool is_loaded;
bool need_network;
bool support_silence_detection;
+ bool support_profanity_filter;
+ bool support_punctuation_override;
void *handle;
/* engine base setting */
}
}
- /* get file name from engine directory and get engine infomation from each filename */
+ /* Get file name from default engine directory */
DIR *dp;
struct dirent *dirp;
- dp = opendir(ENGINE_DIRECTORY);
- if (NULL == dp) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] __internal_update_engine_list : error opendir");
- return -1;
- }
- while (NULL != (dirp = readdir(dp))) {
- sttengine_info_s* info;
- char* filepath;
- int filesize;
-
- filesize = strlen(ENGINE_DIRECTORY) + strlen(dirp->d_name) + 5;
- filepath = (char*) g_malloc0(sizeof(char) * filesize);
-
- if (NULL != filepath) {
- strncpy(filepath, ENGINE_DIRECTORY, strlen(ENGINE_DIRECTORY) );
- strncat(filepath, "/", strlen("/") );
- strncat(filepath, dirp->d_name, strlen(dirp->d_name) );
- } else {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Memory not enough!!" );
- continue;
- }
-
- /* get its info and update engine list */
- if (0 == __internal_get_engine_info(filepath, &info)) {
- /* add engine info to g_engine_list */
- g_engine_list = g_list_append(g_engine_list, info);
+ dp = opendir(ENGINE_DIRECTORY_DEFAULT);
+ if (NULL != dp) {
+ while (NULL != (dirp = readdir(dp))) {
+ sttengine_info_s* info;
+ char* filepath;
+ int filesize;
+
+ filesize = strlen(ENGINE_DIRECTORY_DEFAULT) + strlen(dirp->d_name) + 5;
+ filepath = (char*) g_malloc0(sizeof(char) * filesize);
+
+ if (NULL != filepath) {
+ strncpy(filepath, ENGINE_DIRECTORY_DEFAULT, strlen(ENGINE_DIRECTORY_DEFAULT) );
+ strncat(filepath, "/", strlen("/") );
+ strncat(filepath, dirp->d_name, strlen(dirp->d_name) );
+ } else {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Memory not enough!!" );
+ continue;
+ }
+
+ /* get its info and update engine list */
+ if (0 == __internal_get_engine_info(filepath, &info)) {
+ /* add engine info to g_engine_list */
+ g_engine_list = g_list_append(g_engine_list, info);
+ }
+
+ if (NULL != filepath)
+ g_free(filepath);
}
- if (NULL != filepath)
- g_free(filepath);
+ closedir(dp);
+ } else {
+ SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Fail to open default directory");
}
+
+ /* Get file name from downloadable engine directory */
+ dp = opendir(ENGINE_DIRECTORY_DOWNLOAD);
+ if (NULL != dp) {
+ while (NULL != (dirp = readdir(dp))) {
+ sttengine_info_s* info;
+ char* filepath;
+ int filesize;
+
+ filesize = strlen(ENGINE_DIRECTORY_DOWNLOAD) + strlen(dirp->d_name) + 5;
+ filepath = (char*) g_malloc0(sizeof(char) * filesize);
+
+ if (NULL != filepath) {
+ strncpy(filepath, ENGINE_DIRECTORY_DOWNLOAD, strlen(ENGINE_DIRECTORY_DOWNLOAD) );
+ strncat(filepath, "/", strlen("/") );
+ strncat(filepath, dirp->d_name, strlen(dirp->d_name) );
+ } else {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Memory not enough!!" );
+ continue;
+ }
- closedir(dp);
+ /* get its info and update engine list */
+ if (0 == __internal_get_engine_info(filepath, &info)) {
+ /* add engine info to g_engine_list */
+ g_engine_list = g_list_append(g_engine_list, info);
+ }
+
+ if (NULL != filepath)
+ g_free(filepath);
+ }
+
+ closedir(dp);
+ } else {
+ SLOG(LOG_WARN, TAG_STTD, "[Engine Agent WARNING] Fail to open downloadable directory");
+ }
if (0 >= g_list_length(g_engine_list)) {
SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] No Engine");
g_cur_engine.is_loaded = false;
g_cur_engine.is_set = true;
g_cur_engine.need_network = data->use_network;
- g_cur_engine.support_silence_detection = data->support_silence_detection;
g_cur_engine.profanity_filter = g_default_profanity_filter;
g_cur_engine.punctuation_override = g_default_punctuation_override;
return STTD_ERROR_OPERATION_FAILED;
}
+ /* check and set profanity filter */
ret = g_cur_engine.pefuncs->set_profanity_filter(g_cur_engine.profanity_filter);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail to set profanity filter value to engine");
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent] Not support profanity filter");
+ g_cur_engine.support_profanity_filter = false;
+ } else {
+ g_cur_engine.support_profanity_filter = true;
}
+ /* check and set punctuation */
if (NULL == g_cur_engine.pefuncs->set_punctuation) {
SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_punctuation of engine is NULL!!");
return STTD_ERROR_OPERATION_FAILED;
ret = g_cur_engine.pefuncs->set_punctuation(g_cur_engine.punctuation_override);
if (0 != ret) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail to set punctuation override value to engine");
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Not support punctuation override");
+ g_cur_engine.support_punctuation_override = false;
+ } else {
+ g_cur_engine.support_punctuation_override = true;
}
-
- if (true == g_cur_engine.support_silence_detection) {
- if (NULL == g_cur_engine.pefuncs->set_silence_detection) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_silence_detection of engine is NULL!!");
- return STTD_ERROR_OPERATION_FAILED;
- }
- ret = g_cur_engine.pefuncs->set_silence_detection(g_cur_engine.silence_detection);
- if (0 != ret) {
- SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Fail to set silence detection value(%s)", g_cur_engine.silence_detection ? "true":"false");
- }
+ /* check and set silence detection */
+ if (NULL == g_cur_engine.pefuncs->set_silence_detection) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] set_silence_detection of engine is NULL!!");
+ return STTD_ERROR_OPERATION_FAILED;
+ }
+
+ ret = g_cur_engine.pefuncs->set_silence_detection(g_cur_engine.silence_detection);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine ERROR] Not support silence detection");
+ g_cur_engine.support_silence_detection = false;
+ } else {
+ g_cur_engine.support_silence_detection = true;
}
/* select default language */
return g_cur_engine.need_network;
}
+int sttd_engine_get_option_supported(bool* silence, bool* profanity, bool* punctuation)
+{
+ if (false == g_agent_init) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not Initialized" );
+ return STTD_ERROR_INVALID_STATE;
+ }
+
+ if (false == g_cur_engine.is_loaded) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Not loaded engine");
+ return STTD_ERROR_OPERATION_FAILED;
+ }
+
+ if (NULL == silence || NULL == profanity || NULL == punctuation) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Invalid Parameter");
+ return STTD_ERROR_INVALID_PARAMETER;
+ }
+
+ *silence = g_cur_engine.support_silence_detection;
+ *profanity = g_cur_engine.support_profanity_filter;
+ *punctuation = g_cur_engine.support_punctuation_override;
+
+ return 0;
+}
+
/*
* STT Engine Interfaces for client
*/
/** Get state of current engine to need network */
bool sttd_engine_agent_need_network();
+int sttd_engine_get_option_supported(bool* silence, bool* profanity, bool* punctuation);
+
/*
* STT Engine Interfaces for client
*/
#define TAG_STTD "sttd"
-#define ENGINE_DIRECTORY "/usr/lib/voice/stt/1.0/engine"
-#define ENGINE_DIRECTORY_DOWNLOAD "/opt/apps/voice/stt/engine"
+#define ENGINE_DIRECTORY_DEFAULT "/usr/lib/voice/stt/1.0/engine"
+#define ENGINE_DIRECTORY_DEFAULT_SETTING "/usr/lib/voice/stt/1.0/setting"
+
+#define ENGINE_DIRECTORY_DOWNLOAD "/opt/apps/voice/stt/1.0/engine"
+#define ENGINE_DIRECTORY_DOWNLOAD_SETTING "/opt/apps/voice/stt/1.0/setting"
/* for debug message */
#define RECORDER_DEBUG
STTD_ERROR_INVALID_STATE = -0x0100031, /**< Invalid state */
STTD_ERROR_INVALID_LANGUAGE = -0x0100032, /**< Invalid language */
STTD_ERROR_ENGINE_NOT_FOUND = -0x0100033, /**< No available engine */
- STTD_ERROR_OPERATION_FAILED = -0x0100034 /**< Operation failed */
+ STTD_ERROR_OPERATION_FAILED = -0x0100034, /**< Operation failed */
+ STTD_ERROR_NOT_SUPPORTED_FEATURE= -0x0100035 /**< Not supported feature of current engine */
}stt_error_e;
typedef struct {
/* Check if initialized */
ret = __recorder_setup();
- if (ret) {
+ if (0 != ret) {
SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Fail to call __recorder_setup");
+ return STTD_ERROR_OPERATION_FAILED;
}
/* Start camcorder */
ret = __recorder_run();
- if (ret) {
- SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Fail to call __recorder_run");
+ if (0 != ret) {
+ SLOG(LOG_DEBUG, TAG_STTD, "[Recorder] Fail to call __recorder_run");
+ return STTD_ERROR_OPERATION_FAILED;
}
__recorder_state_set(STTD_RECORDER_STATE_RECORDING);
* STT Server Functions for Client
*/
-int sttd_server_initialize(int pid, int uid)
+int sttd_server_initialize(int pid, int uid, bool* silence, bool* profanity, bool* punctuation)
{
if (false == g_is_engine) {
if (0 != sttd_engine_agent_initialize_current_engine()) {
return STTD_ERROR_OPERATION_FAILED;
}
+ SLOG(LOG_DEBUG, TAG_STTD, "[Server] audio type(%d), channel(%d)", (int)atype, (int)sttchannel);
+
/* Add client information to client manager */
if (0 != sttd_client_add(pid, uid)) {
SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to add client info");
return STTD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_DEBUG, TAG_STTD, "[Server SUCCESS] audio type(%d), channel(%d)", (int)atype, (int)sttchannel);
+ if (0 != sttd_engine_get_option_supported(silence, profanity, punctuation)) {
+ SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Fail to get engine options supported");
+ return STTD_ERROR_OPERATION_FAILED;
+ }
+
+ SLOG(LOG_DEBUG, TAG_STTD, "[Server Success] Initialize");
return STTD_ERROR_NONE;
}
* API for client
*/
-int sttd_server_initialize(int pid, int uid);
+int sttd_server_initialize(int pid, int uid, bool* silence, bool* profanity, bool* punctuation);
int sttd_server_finalize(const int uid);
STTP_ERROR_INVALID_STATE = -0x0100031, /**< Invalid state */
STTP_ERROR_INVALID_LANGUAGE = -0x0100032, /**< Invalid language */
STTP_ERROR_OPERATION_FAILED = -0x0100034, /**< Operation failed */
- STTP_ERROR_NOT_SUPPORTED = -0x0100035 /**< Not supported function */
+ STTP_ERROR_NOT_SUPPORTED_FEATURE= -0x0100035 /**< Not supported feature */
}sttp_error_e;
/**
*/
#define STTP_RECOGNITION_TYPE_COMMAND_TTS "stt.recognition.type.COMMAND.TTS"
+/**
+* @brief Result message : None message
+*/
+#define STTP_RESULT_MESSAGE_NONE "stt.result.message.none"
+
+/**
+* @brief Result warning message : The speech has started too soon
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_SOON "stt.result.message.warning.too.soon"
+
+/**
+* @brief Result warning message : The speech is too short
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_SHORT "stt.result.message.warning.too.short"
+
+/**
+* @brief Result warning message : The speech is too long
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_LONG "stt.result.message.warning.too.long"
+
+/**
+* @brief Result warning message : The speech is too quiet to listen
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_QUIET "stt.result.message.warning.too.quiet"
+
+/**
+* @brief Result warning message : The speech is too loud to listen
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_LOUD "stt.result.message.warning.too.loud"
+
+/**
+* @brief Result warning message : The speech is too fast to listen
+*/
+#define STTP_RESULT_MESSAGE_WARNING_TOO_FAST "stt.result.message.warning.too.fast"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too soon
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_SOON "stt.result.message.error.too.soon"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too short
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_SHORT "stt.result.message.error.too.short"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too long
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_LONG "stt.result.message.error.too.long"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too quiet to listen
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_QUIET "stt.result.message.error.too.quiet"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too loud to listen
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_LOUD "stt.result.message.error.too.loud"
+
+/**
+* @brief Result error message : Recognition was failed because the speech started too fast to listen
+*/
+#define STTP_RESULT_MESSAGE_ERROR_TOO_FAST "stt.result.message.error.too.fast"
/**
* @brief Called to get recognition result.
*
* @param[in] event A result event
-* @param[in] type A recognition type
+* @param[in] type A recognition type (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_COMMAND)
* @param[in] data Result texts
* @param[in] data_count Result text count
-* @param[in] msg engine A Message
+* @param[in] msg Engine message (e.g. #STTP_RESULT_MESSAGE_WARNING_TOO_SOON, #STTP_RESULT_MESSAGE_ERROR_TOO_SHORT)
* @param[in] user_data The user data passed from the start function
*
* @pre sttpe_stop() will invoke this callback.
* @return 0 on success, otherwise a negative error value
* @retval #STTP_ERROR_NONE Successful
* @retval #STTP_ERROR_INVALID_STATE Not initialized
-* @retval #STTP_ERROR_NOT_SUPPORTED Not supported
+* @retval #STTP_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
*/
typedef int (* sttpe_set_profanity_filter)(bool value);
* @return 0 on success, otherwise a negative error value
* @retval #STTP_ERROR_NONE Successful
* @retval #STTP_ERROR_INVALID_STATE Not initialized
-* @retval #STTP_ERROR_NOT_SUPPORTED Not supported
+* @retval #STTP_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
*/
typedef int (* sttpe_set_punctuation_override)(bool value);
* @return 0 on success, otherwise a negative error value
* @retval #STTP_ERROR_NONE Successful
* @retval #STTP_ERROR_INVALID_STATE Not initialized
-* @retval #STTP_ERROR_NOT_SUPPORTED Not supported
+* @retval #STTP_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
*/
typedef int (* sttpe_set_silence_detection)(bool value);
* @brief Start recognition.
*
* @param[in] language A language.
-* @param[in] type A recognition type.
+* @param[in] type A recognition type. (e.g. #STTP_RECOGNITION_TYPE_FREE, #STTP_RECOGNITION_TYPE_WEB_SEARCH)
* @param[in] user_data The user data to be passed to the callback function.
*
* @return 0 on success, otherwise a negative error value