The audio format types are not changable in current STT engine.
Therefore sample rate, channel and audio type are not necessary to transmit the pcm data to cloud.
The application should send pcm data, which consits of 1 channel, 16000 sample rate and signed 16 bit pcm data.
Change-Id: I4f9ad034419bf088d6de9d2a1b4a54adfc6e718a
return 0;
}
-int stt_start_file(stt_h stt, const char* language, const char* type, const char* filepath, stt_audio_type_e audio_type, int channels, int sample_rate)
+int stt_start_file(stt_h stt, const char* language, const char* type, const char* filepath)
{
stt_client_s* client = NULL;
int tmp = __stt_check_precondition(stt, &client);
}
client->internal_state = STT_INTERNAL_STATE_STARTING;
- ret = stt_dbus_request_start_file(client->uid, temp, type, client->silence, appid, client->credential, filepath, audio_type, channels, sample_rate);
+ ret = stt_dbus_request_start_file(client->uid, temp, type, client->silence, appid, client->credential, filepath);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to start file : %s", __stt_get_error_code(ret));
client->internal_state = STT_INTERNAL_STATE_NONE;
}
//LCOV_EXCL_START
-int stt_dbus_request_start_file(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential, const char* filepath, stt_audio_type_e audio_type, int channels, int sample_rate)
+int stt_dbus_request_start_file(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential, const char* filepath)
{
if (NULL == lang || NULL == type || NULL == appid) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
SLOG(LOG_ERROR, TAG_STTC, ">>>> stt start file : Fail to make message");
return STT_ERROR_OPERATION_FAILED;
} else {
- SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start file : uid(%u), language(%s), type(%s), appid(%s), filepath(%s), audio_type(%d), channels(%d), sample_rate(%d)", uid, lang, type, appid, filepath, audio_type, channels, sample_rate);
+ SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start file : uid(%u), language(%s), type(%s), appid(%s), filepath(%s)", uid, lang, type, appid, filepath);
}
char *temp = NULL;
DBUS_TYPE_STRING, &appid,
DBUS_TYPE_STRING, &temp,
DBUS_TYPE_STRING, &filepath,
- DBUS_TYPE_INT32, &audio_type,
- DBUS_TYPE_INT32, &channels,
- DBUS_TYPE_INT32, &sample_rate,
DBUS_TYPE_INVALID);
int ret = __stt_dbus_send_message_without_reply(msg, STT_METHOD_START_FILE);
int stt_dbus_request_cancel(unsigned int uid);
-int stt_dbus_request_start_file(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential, const char* filepath, stt_audio_type_e audio_type, int channels, int sample_rate);
+int stt_dbus_request_start_file(unsigned int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential, const char* filepath);
int stt_dbus_request_cancel_file(unsigned int uid);
* @privlevel public
* @privilege %http://tizen.org/privilege/recorder
* @remarks This function starts sending recorded data from file to engine.
+ * The pcm file should be in raw format as following
+ * - 16000 for sample rate
+ * - 1 channel for mono
+ * - Signed 16 bits per sample
* @param[in] stt The STT handle
* @param[in] language The language selected from stt_foreach_supported_languages()
* @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
* @param[in] filepath PCM filepath for recognition
- * @param[in] audio_type audio type of file
- * @param[in] channel channel of file (e.g. 1 for mono, 2 for stereo)
- * @param[in] sample_rate sample rate of file
* @return @c 0 on success,
* otherwise a negative error value
* @retval #STT_ERROR_NONE Successful
* @see stt_cancel_file()
* @see stt_state_changed_cb()
*/
-int stt_start_file(stt_h stt, const char* language, const char* type, const char* filepath, stt_audio_type_e audio_type, int channels, int sample_rate);
+int stt_start_file(stt_h stt, const char* language, const char* type, const char* filepath);
/**
* @brief Cancels processing file recognition asynchronously.
int silence;
char* credential;
char* filepath;
- stte_audio_type_e audio_type;
- int channels;
- int sample_rate;
int ret = STTD_ERROR_OPERATION_FAILED;
DBUS_TYPE_STRING, &appid,
DBUS_TYPE_STRING, &credential,
DBUS_TYPE_STRING, &filepath,
- DBUS_TYPE_INT32, &audio_type,
- DBUS_TYPE_INT32, &channels,
- DBUS_TYPE_INT32, &sample_rate,
DBUS_TYPE_INVALID);
SLOG(LOG_DEBUG, TAG_STTD, ">>>>> STT Start File");
dbus_error_free(&err);
ret = STTD_ERROR_OPERATION_FAILED;
} else {
- SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start file : uid(%u), lang(%s), type(%s), silence(%d) appid(%s) filepath(%s), audio_type(%d), channels(%d), sample_rate(%d)"
- , uid, lang, type, silence, appid, filepath, audio_type, channels, sample_rate);
- ret = sttd_server_start_file(uid, lang, type, silence, appid, credential, filepath, audio_type, channels, sample_rate);
+ SLOG(LOG_DEBUG, TAG_STTD, "[IN] stt start file : uid(%u), lang(%s), type(%s), silence(%d) appid(%s) filepath(%s)", uid, lang, type, silence, appid, filepath);
+ ret = sttd_server_start_file(uid, lang, type, silence, appid, credential, filepath);
}
if (0 <= ret) {
return 0;
}
-int sttd_engine_agent_recognize_start_file(unsigned int uid, const char* filepath, stte_audio_type_e audio_type, int channels, int sample_rate)
+int sttd_engine_agent_recognize_start_file(unsigned int uid, const char* filepath)
{
int tmp = __sttd_engine_agent_check_precondition();
if (STTD_ERROR_NONE != tmp)
SLOG(LOG_INFO, TAG_STTD, "[Engine Agent] Start recorder");
int ret;
- ret = sttd_recorder_start_file(uid, filepath, audio_type, channels, sample_rate);
+ ret = sttd_recorder_start_file(uid, filepath);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_STTD, "[Engine Agent ERROR] Fail to start recorder : result(%d)", ret);
stt_engine_recognize_cancel();
int sttd_engine_agent_recognize_start_recorder(unsigned int uid, const char* appid);
-int sttd_engine_agent_recognize_start_file(unsigned int uid, const char* filepath, stte_audio_type_e audio_type, int channels, int sample_rate);
+int sttd_engine_agent_recognize_start_file(unsigned int uid, const char* filepath);
int sttd_engine_agent_set_recording_data(const void* data, unsigned int length);
return 0;
}
-static int __calculate_time_of_pcm_data(int bytes, int sample_rate, int channels, int bit_per_sample)
+static int __calculate_time_of_pcm_data(int bytes)
{
- int time = 0;
- if (0 == bytes || 0 == sample_rate || 0 == channels || 0 == bit_per_sample) {
- SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Invalid parameter");
- return 0;
- }
+ const static int SAMPLE_RATE = 16000;
+ const static int CHANNELS = 1;
+ const static int BIT_PER_SAMPLE = 16;
- int sample_per_sec = sample_rate * channels * bit_per_sample / 8;
- time = bytes * 1000 / sample_per_sec;
+ int sample_per_sec = SAMPLE_RATE * CHANNELS * BIT_PER_SAMPLE / 8;
+ int time = bytes * 1000 / sample_per_sec;
return time;
}
-static int __calculate_bit_per_sample(stte_audio_type_e audio_type)
-{
- int bit_per_sample = 0;
- switch (audio_type) {
- case STTE_AUDIO_TYPE_PCM_S16_LE:
- bit_per_sample = 16;
- break;
- case STTE_AUDIO_TYPE_PCM_U8:
- bit_per_sample = 8;
- break;
- default:
- SLOG(LOG_ERROR, TAG_STTD, "[Recorder ERROR] Invalid audio type");
- break;
- }
- return bit_per_sample;
-}
-
-int sttd_recorder_start_file(unsigned int uid, const char *filepath, stte_audio_type_e audio_type, int channels, int sample_rate)
+int sttd_recorder_start_file(unsigned int uid, const char *filepath)
{
if (STTD_RECORDER_STATE_RECORDING == g_recorder_state)
return 0;
int read_byte = fread(pcm_buff, 1, BUFFER_LENGTH, infile);
// sleep for real time of pcm data
- int time = __calculate_time_of_pcm_data(read_byte, sample_rate, channels, __calculate_bit_per_sample(audio_type));
+ int time = __calculate_time_of_pcm_data(read_byte);
usleep(time * 1000);
totalReadBytes += read_byte;
int sttd_recorder_stop();
-int sttd_recorder_start_file(unsigned int uid, const char *filepath, stte_audio_type_e audio_type, int channels, int sample_rate);
+int sttd_recorder_start_file(unsigned int uid, const char *filepath);
int sttd_recorder_stop_file();
return ret;
}
-int sttd_server_start_file(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential,
- const char* filepath, stte_audio_type_e audio_type, int channels, int sample_rate)
+int sttd_server_start_file(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential, const char* filepath)
{
if (NULL == lang || NULL == recognition_type || NULL == filepath) {
SLOG(LOG_ERROR, TAG_STTD, "[Server ERROR] Input parameter is NULL");
}
/* engine start recognition */
- SLOG(LOG_DEBUG, TAG_STTD, "[Server] start : uid(%u), lang(%s), recog_type(%s), appid(%s), file(%s), audio_type(%d), channels(%d), sample_rate(%d)", uid, lang, recognition_type, appid, filepath, audio_type, channels, sample_rate);
+ SLOG(LOG_DEBUG, TAG_STTD, "[Server] start : uid(%u), lang(%s), recog_type(%s), appid(%s), file(%s)", uid, lang, recognition_type, appid, filepath);
/* 1. Set audio session */
ret = sttd_recorder_set_audio_session();
sttdc_send_set_state(uid, APP_STATE_RECORDING);
/* 3. Start to send pcm from file to engine */
- ret = sttd_engine_agent_recognize_start_file(uid, filepath, audio_type, channels, sample_rate);
+ ret = sttd_engine_agent_recognize_start_file(uid, filepath);
if (0 != ret) {
stt_client_unset_current_recognition();
sttd_recorder_unset_audio_session();
int sttd_server_cancel(unsigned int uid);
-int sttd_server_start_file(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential, const char* filepath, stte_audio_type_e audio_type, int channels, int sample_rate);
+int sttd_server_start_file(unsigned int uid, const char* lang, const char* recognition_type, int silence, const char* appid, const char* credential, const char* filepath);
int sttd_server_cancel_file(unsigned int uid);