IFlySpeechEvent.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // IFlySpeechEvent.h
  3. // MSCDemo
  4. //
  5. // Created by admin on 14-8-12.
  6. // Copyright (c) 2014年 iflytek. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. /*!
  10. * 事件类型
  11. */
  12. typedef NS_ENUM(NSUInteger,IFlySpeechEventType){
  13. /*!
  14. * 网络状态消息
  15. * 在消息到达时,可通过onEvent的第2个参数arg1,获取当前网络连接状态值
  16. */
  17. IFlySpeechEventTypeNetPref = 10001,
  18. /**
  19. * 转写音频文件消息
  20. * 在录音模式下,成功创建音频文件时返回。可通过onEvent
  21. * 第4个参数data 指定Key为[IFlySpeechConstant IST_AUDIO_PATH],获取音频文件绝对路径.
  22. * 或通过[IFlySpeechTranscripter getParameter:[IFlySpeechConstant IST_AUDIO_PATH]],
  23. * 获取音频文件绝对路径.
  24. */
  25. IFlySpeechEventTypeISTAudioFile = 10004,
  26. /**
  27. * 转写已上传字节消息
  28. * 在消息到达时,通过onEvent
  29. * 的第二个参数arg1,获取已确认上传到服务器的字节数.
  30. * 若当前音频源为非写音频模式,还可通过onEvent
  31. * 的第三个参数arg2,获取当前所有音频的字节大小.录音模式时,由于所有音频字节大小会变。
  32. * 当停止音频输入后(等待录音时间超时
  33. * [IFlySpeechConstant SPEECH_TIMEOUT]
  34. * ,或调用[IFlySpeechTranscripter stopTranscripting]),
  35. * 且服务器收到所有音频时,第四个参数data,将包含完成标记的布尔值(true),可通过data调用
  36. * 指定KEY为KCIFlySpeechEventKeyISTUploadComplete获取。
  37. * 此消息可能多次返回.
  38. */
  39. IFlySpeechEventTypeISTUploadBytes = 10006,
  40. /**
  41. * 转写缓存剩余
  42. * 此消息仅在音频源为-1时需要关注
  43. * 在调用[IFlySpeechTranscripter writeAudio]写音频时,应该关注此事件。
  44. * 此事件在调用写音频接口、及音频最后被写入底库库时分别回调一次。当事件回调时,通过onEvent
  45. * 的第二个参数arg1,获取当前剩余的缓存大小,当缓存小于要写入的音频时,应该先暂停写音频数据,直到下次缓存大小大于要写入的音频时.
  46. * 最大缓存为128KByte。
  47. */
  48. IFlySpeechEventTypeISTCacheLeft = 10007,
  49. /**
  50. * 转写结果等待时间消息
  51. * 在消息到达时,通过 onEvent
  52. * 的第二个参数arg1,获取当前结果需要的时间.
  53. * 此消息可能多次返回,返回时间不定,且不一定会返回.
  54. */
  55. IFlySpeechEventTypeISTResultTime= 10008,
  56. /**
  57. * 转写转写音频同步ID消息
  58. * 在消息到达时,通过 onEvent
  59. * 的第二个参数arg1,获取当前写音频同步ID.
  60. * 此消息可能多次返回.
  61. */
  62. IFlySpeechEventTypeISTSyncID= 10009,
  63. /**
  64. * 会话开始消息
  65. * 在会话开始成功后返回
  66. */
  67. IFlySpeechEventTypeSessionBegin = 10010,
  68. /**
  69. * 会话结束消息
  70. * 在会话结束前返回
  71. */
  72. IFlySpeechEventTypeSessionEnd = 10011,
  73. /**
  74. * 音量消息,在得到音量时抛出,暂时只有身份验证的声纹业务用到
  75. */
  76. IFlySpeechEventTypeVolume = 10012,
  77. /**
  78. * VAD后端点消息,在检测到VAD后端点时抛出,暂时只有身份验证的声纹业务用到
  79. */
  80. IFlySpeechEventTypeVadEOS = 10013,
  81. /*!
  82. * 服务端会话id
  83. * 在消息到达时,可通过onEvent的第4个参数data(字典类型),
  84. * 指定key KCIFlySpeechEventKeySessionID,获取服务端会话id.
  85. */
  86. IFlySpeechEventTypeSessionID = 20001,
  87. /*!
  88. * TTS合成数据消息
  89. * -(void)onEvent:(int)eventType arg0:(int)arg0 arg1:(int)arg1 data:(NSData *)eventData
  90. * 其中eventData中包含数据
  91. *
  92. */
  93. IFlySpeechEventTypeTTSBuffer = 21001,
  94. /*!
  95. * 通知cancel方法被调用的回调
  96. *
  97. */
  98. IFlySpeechEventTypeTTSCancel = 21002,
  99. /*!
  100. * IVW onshot 听写 or 识别结果
  101. * 在消息到达时,第2个参数arg1包含是否为最后一个结果:1为是,0为否;
  102. * 第4个参数data中包含数据,通过指定KEY为KCIFlySpeechEventKeyIVWResult获取.
  103. */
  104. IFlySpeechEventTypeIVWResult = 22001,
  105. /*!
  106. * 开始处理录音数据
  107. *
  108. */
  109. IFlySpeechEventTypeSpeechStart= 22002,
  110. /*!
  111. * 录音停止
  112. *
  113. */
  114. IFlySpeechEventTypeRecordStop= 22003,
  115. /*!
  116. * 服务端音频url
  117. * 在消息到达时,
  118. * 第4个参数data,包含数据,通过
  119. * 指定KEY为KCIFlySpeechEventKeyAudioUrl获取.
  120. */
  121. IFlySpeechEventTypeAudioUrl = 23001,
  122. /*!
  123. * 变声数据结果返回
  124. *
  125. * 设置voice_change参数获取结果.
  126. */
  127. IFlySpeechEventTypeVoiceChangeResult = 24001
  128. };
  129. #pragma mark - keys for event data
  130. /**
  131. * 转写是否已上传完标记key
  132. */
  133. extern NSString* const KCIFlySpeechEventKeyISTUploadComplete;
  134. /**
  135. * 服务端会话key
  136. */
  137. extern NSString* const KCIFlySpeechEventKeySessionID;
  138. /**
  139. * TTS取音频数据key
  140. */
  141. extern NSString* const KCIFlySpeechEventKeyTTSBuffer;
  142. /**
  143. * IVW oneshot 听写 or 识别结果 key
  144. */
  145. extern NSString* const KCIFlySpeechEventKeyIVWResult;
  146. /**
  147. * 服务端音频url key
  148. */
  149. extern NSString* const KCIFlySpeechEventKeyAudioUrl;