qtts.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /**
  2. * @file qtts.h
  3. * @brief iFLY Speech Synthesizer Header File
  4. *
  5. * This file contains the quick application programming interface (API) declarations
  6. * of TTS. Developer can include this file in your project to build applications.
  7. * For more information, please read the developer guide.
  8. * Use of this software is subject to certain restrictions and limitations set
  9. * forth in a license agreement entered into between iFLYTEK, Co,LTD.
  10. * and the licensee of this software. Please refer to the license
  11. * agreement for license use rights and restrictions.
  12. *
  13. * Copyright (C) 1999 - 2009 by ANHUI USTC iFLYTEK, Co,LTD.
  14. * All rights reserved.
  15. *
  16. * @author Speech Dept.
  17. * @version 1.0
  18. * @date 2009/11/26
  19. *
  20. * @see
  21. *
  22. * <b>History:</b><br>
  23. * <table>
  24. * <tr> <th>Version <th>Date <th>Author <th>Notes</tr>
  25. * <tr> <td>1.0 <td>2009/11/26 <td>Speech <td>Create this file</tr>
  26. * </table>
  27. *
  28. */
  29. #ifndef __QTTS_H__
  30. #define __QTTS_H__
  31. #if !defined(MSPAPI)
  32. #if defined(WIN32)
  33. #define MSPAPI __stdcall
  34. #else
  35. #define MSPAPI
  36. #endif /* WIN32 */
  37. #endif /* MSPAPI */
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif /* C++ */
  41. #include "msp_types.h"
  42. /**
  43. * @fn QTTSSessionBegin
  44. * @brief Begin a TTS Session
  45. *
  46. * Create a tts session to synthesize data.
  47. *
  48. * @return const char* - Return the new session id in success, otherwise return NULL, error code.
  49. * @param const char* params - [in] parameters when the session created.
  50. * @param const char** sessionID - [out] return a string to this session.
  51. * @see
  52. */
  53. const char* MSPAPI QTTSSessionBegin(const char* params, int* errorCode);
  54. typedef const char* (MSPAPI *Proc_QTTSSessionBegin)(const char* params, int* errorCode);
  55. #ifdef MSP_WCHAR_SUPPORT
  56. const wchar_t* MSPAPI QTTSSessionBeginW(const wchar_t* params, int* errorCode);
  57. typedef const wchar_t* (MSPAPI *Proc_QTTSSessionBeginW)(const wchar_t* params, int* errorCode);
  58. #endif
  59. /**
  60. * @fn QTTSTextPut
  61. * @brief Put Text Buffer to TTS Session
  62. *
  63. * Writing text string to synthesizer.
  64. *
  65. * @return int MSPAPI - Return 0 in success, otherwise return error code.
  66. * @param const char* sessionID - [in] The session id returned by sesson begin
  67. * @param const char* textString - [in] text buffer
  68. * @param unsigned int textLen - [in] text size in bytes
  69. * @see
  70. */
  71. int MSPAPI QTTSTextPut(const char* sessionID, const char* textString, unsigned int textLen, const char* params);
  72. typedef int (MSPAPI *Proc_QTTSTextPut)(const char* sessionID, const char* textString, unsigned int textLen, const char* params);
  73. #ifdef MSP_WCHAR_SUPPORT
  74. int MSPAPI QTTSTextPutW(const wchar_t* sessionID, const wchar_t* textString, unsigned int textLen, const wchar_t* params);
  75. typedef int (MSPAPI *Proc_QTTSTextPutW)(const wchar_t* sessionID, const wchar_t* textString, unsigned int textLen, const wchar_t* params);
  76. #endif
  77. /**
  78. * @fn QTTSAudioGet
  79. * @brief Synthesize text to audio
  80. *
  81. * Synthesize text to audio, and return audio information.
  82. *
  83. * @return const void* - Return current synthesized audio data buffer, size returned by QTTSTextSynth.
  84. * @param const char* sessionID - [in] session id returned by session begin
  85. * @param unsigned int* audioLen - [out] synthesized audio size in bytes
  86. * @param int* synthStatus - [out] synthesizing status
  87. * @param int* errorCode - [out] error code if failed, 0 to success.
  88. * @see
  89. */
  90. const void* MSPAPI QTTSAudioGet(const char* sessionID, unsigned int* audioLen, int* synthStatus, int* errorCode);
  91. typedef const void* (MSPAPI *Proc_QTTSAudioGet)(const char* sessionID, unsigned int* audioLen, int* synthStatus, int* errorCode);
  92. #ifdef MSP_WCHAR_SUPPORT
  93. const void* MSPAPI QTTSAudioGetW(const wchar_t* sessionID, unsigned int* audioLen, int* synthStatus, int* errorCode);
  94. typedef const void* (MSPAPI *Proc_QTTSAudioGetW)(const wchar_t* sessionID, unsigned int* audioLen, int* synthStatus, int* errorCode);
  95. #endif
  96. /**
  97. * @fn QTTSAudioInfo
  98. * @brief Get Synthesized Audio information
  99. *
  100. * Get synthesized audio data information.
  101. *
  102. * @return const char * - Return audio info string.
  103. * @param const char* sessionID - [in] session id returned by session begin
  104. * @see
  105. */
  106. const char* MSPAPI QTTSAudioInfo(const char* sessionID);
  107. typedef const char* (MSPAPI *Proc_QTTSAudioInfo)(const char* sessionID);
  108. #ifdef MSP_WCHAR_SUPPORT
  109. const wchar_t* MSPAPI QTTSAudioInfoW(const wchar_t* sessionID);
  110. typedef const wchar_t* (MSPAPI *Proc_QTTSAudioInfoW)(const wchar_t* sessionID);
  111. #endif
  112. /**
  113. * @fn QTTSSessionEnd
  114. * @brief End a Recognizer Session
  115. *
  116. * End the recognizer session, release all resource.
  117. *
  118. * @return int MSPAPI - Return 0 in success, otherwise return error code.
  119. * @param const char* session_id - [in] session id string to end
  120. * @param const char* hints - [in] user hints to end session, hints will be logged to CallLog
  121. * @see
  122. */
  123. int MSPAPI QTTSSessionEnd(const char* sessionID, const char* hints);
  124. typedef int (MSPAPI *Proc_QTTSSessionEnd)(const char* sessionID, const char* hints);
  125. #ifdef MSP_WCHAR_SUPPORT
  126. int MSPAPI QTTSSessionEndW(const wchar_t* sessionID, const wchar_t* hints);
  127. typedef int (MSPAPI *Proc_QTTSSessionEndW)(const wchar_t* sessionID, const wchar_t* hints);
  128. #endif
  129. /**
  130. * @fn QTTSGetParam
  131. * @brief get params related with msc
  132. *
  133. * the params could be local or server param, we only support netflow params "upflow" & "downflow" now
  134. *
  135. * @return int - Return 0 if success, otherwise return errcode.
  136. * @param const char* sessionID - [in] session id of related param, set NULL to got global param
  137. * @param const char* paramName - [in] param name,could pass more than one param split by ','';'or'\n'
  138. * @param const char* paramValue - [in] param value buffer, malloced by user
  139. * @param int *valueLen - [in, out] pass in length of value buffer, and return length of value string
  140. * @see
  141. */
  142. int MSPAPI QTTSGetParam(const char* sessionID, const char* paramName, char* paramValue, unsigned int* valueLen);
  143. typedef int (MSPAPI *Proc_QTTSGetParam)(const char* sessionID, const char* paramName, char* paramValue, unsigned int* valueLen);
  144. #ifdef MSP_WCHAR_SUPPORT
  145. int MSPAPI QTTSGetParamW(const wchar_t* sessionID, const wchar_t* paramName, wchar_t* paramValue, unsigned int* valueLen);
  146. typedef int (MSPAPI *Proc_QTTSGetParamW)(const wchar_t* sessionID, const wchar_t* paramName, wchar_t* paramValue, unsigned int* valueLen);
  147. #endif
  148. /**
  149. * @fn QTTSSetParam
  150. * @brief set params related with msc
  151. *
  152. * the params could be local or server param, we only support netflow params "upflow" & "downflow" now
  153. *
  154. * @return int - Return 0 if success, otherwise return errcode.
  155. * @param const char* sessionID - [in] session id of related param, set NULL to got global param
  156. * @param const char* paramName - [in] param name,could pass more than one param split by ','';'or'\n'
  157. * @param const char* paramValue - [in] param value buffer, malloced by user
  158. * @see
  159. */
  160. int MSPAPI QTTSSetParam(const char *sessionID, const char *paramName, const char *paramValue);
  161. typedef int (MSPAPI *Proc_QTTSSetParam)(const char* sessionID, const char* paramName, char* paramValue);
  162. #ifdef MSP_WCHAR_SUPPORT
  163. int MSPAPI QTTSSetParamW(const wchar_t* sessionID, const wchar_t* paramName, wchar_t* paramValue);
  164. typedef int (MSPAPI *Proc_QTTSSetParamW)(const wchar_t* sessionID, const wchar_t* paramName, wchar_t* paramValue);
  165. #endif
  166. typedef void ( *tts_result_ntf_handler)( const char *sessionID, const char *audio, int audioLen, int synthStatus, int ced, const char *audioInfo, int audioInfoLen, void *userData );
  167. typedef void ( *tts_status_ntf_handler)( const char *sessionID, int type, int status, int param1, const void *param2, void *userData);
  168. typedef void ( *tts_error_ntf_handler)(const char *sessionID, int errorCode, const char *detail, void *userData);
  169. int MSPAPI QTTSRegisterNotify(const char *sessionID, tts_result_ntf_handler rsltCb, tts_status_ntf_handler statusCb, tts_error_ntf_handler errCb, void *userData);
  170. #ifdef __cplusplus
  171. } /* extern "C" */
  172. #endif /* C++ */
  173. #endif /* __QTTS_H__ */