IFlySpeechEvent.h 5.1 KB

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