科大讯飞语音评测web api调研

文档地址:https://doc.xfyun.cn/rest_api/%E8%AF%AD%E9%9F%B3%E8%AF%84%E6%B5%8B.html

  • 评测需要: 一段语音(不超过3分钟) + 试卷(需要评测文本内容)

  • 异常情况
    科大讯飞语音评测web api调研_第1张图片

  • VLC播放pcm文件命令
    /Applications/VLC.app/Contents/MacOS/VLC --demux=rawaud --rawaud-channels 1 --rawaud-samplerate 16000 /Users/xmly/Desktop/testAudioPCM.raw

  • java demo 调用语音评测,测试内容为7个单词长度的句子
    This is an example of sentence test.
    所用时长:
    47s左右

后续发现,在官方提供的HttpUtil中

while ((line = in.readLine()) != null){
    result += line;
}

此部分耗时44s

调整代码后证明,调用科大讯飞web api平均耗时在3-4s;

  • simple result
{"data": {"read_sentence": {"rec_paper": {"read_chapter": {"total_score": "81.468280", "sentence": {"beg_pos": "0", "end_pos": "526", "index": "0", "total_score": "81.468280"}, "beg_pos": "0", "end_pos": "526", "except_info": "0", "is_rejected": "false"}}, "lan": "en", "type": "study", "version": "6.5.0.1011"}}, "code": "0", "desc": "success", "sid": "wse006cd90f@ch4b530fc179b3477600"}
  • entirety result
{"data": {"read_sentence": {"version": "6.5.0.1011", "rec_paper": {"read_chapter": {"sentence": {"content": "this is an example of sentence test", "end_pos": "430", "index": "0", "total_score": "93.939920", "word_count": "7", "word": [{"beg_pos": "65", "content": "this", "end_pos": "114", "global_index": "0", "syll": {"phone": [{"beg_pos": "65", "content": "dh", "dp_message": "0", "end_pos": "92"}, {"dp_message": "0", "end_pos": "102", "beg_pos": "92", "content": "ih"}, {"end_pos": "114", "beg_pos": "102", "content": "s", "dp_message": "0"}], "beg_pos": "65", "content": "dh ih s", "end_pos": "114", "syll_accent": "0", "syll_score": "68.969360"}, "dp_message": "0", "index": "0", "property": "0", "total_score": "68.969360"}, {"content": "is", "dp_message": "0", "property": "0", "index": "1", "total_score": "80.281940", "syll": {"syll_accent": "0", "syll_score": "80.281940", "phone": [{"content": "ih", "dp_message": "0", "end_pos": "132", "beg_pos": "114"}, {"beg_pos": "132", "content": "z", "dp_message": "0", "end_pos": "142"}], "beg_pos": "114", "content": "ih z", "end_pos": "142"}, "beg_pos": "114", "end_pos": "142", "global_index": "1"}, {"dp_message": "0", "end_pos": "174", "global_index": "2", "beg_pos": "142", "content": "an", "total_score": "76.959800", "syll": {"phone": [{"beg_pos": "142", "content": "ax", "dp_message": "0", "end_pos": "160"}, {"dp_message": "0", "end_pos": "174", "beg_pos": "160", "content": "n"}], "beg_pos": "142", "content": "ax n", "end_pos": "174", "syll_accent": "0", "syll_score": "76.959800"}, "index": "2", "property": "0"}, {"syll": [{"beg_pos": "174", "content": "ih g", "end_pos": "192", "syll_accent": "0", "syll_score": "83.943980", "phone": [{"beg_pos": "174", "content": "ih", "dp_message": "0", "end_pos": "185"}, {"beg_pos": "185", "content": "g", "dp_message": "0", "end_pos": "192"}]}, {"beg_pos": "192", "content": "z ae m p l", "end_pos": "248", "syll_accent": "1", "syll_score": "87.469600", "phone": [{"beg_pos": "192", "content": "z", "dp_message": "0", "end_pos": "205"}, {"content": "ae", "dp_message": "0", "end_pos": "216", "beg_pos": "205"}, {"dp_message": "0", "end_pos": "222", "beg_pos": "216", "content": "m"}, {"beg_pos": "222", "content": "p", "dp_message": "0", "end_pos": "227"}, {"beg_pos": "227", "content": "l", "dp_message": "0", "end_pos": "248"}]}], "beg_pos": "174", "content": "example", "global_index": "3", "index": "3", "property": "0", "total_score": "86.462260", "dp_message": "0", "end_pos": "248"}, {"beg_pos": "248", "content": "sil", "end_pos": "251"}, {"syll": {"beg_pos": "251", "content": "ax v", "end_pos": "262", "syll_accent": "0", "syll_score": "67.311540", "phone": [{"end_pos": "254", "beg_pos": "251", "content": "ax", "dp_message": "0"}, {"content": "v", "dp_message": "0", "end_pos": "262", "beg_pos": "254"}]}, "beg_pos": "251", "content": "of", "dp_message": "0", "global_index": "4", "index": "4", "property": "0", "total_score": "67.311540", "end_pos": "262"}, {"beg_pos": "262", "dp_message": "0", "end_pos": "314", "index": "5", "property": "0", "total_score": "86.392880", "content": "sentence", "global_index": "5", "syll": [{"phone": [{"dp_message": "0", "end_pos": "274", "beg_pos": "262", "content": "s"}, {"beg_pos": "274", "content": "eh", "dp_message": "0", "end_pos": "282"}, {"beg_pos": "282", "content": "n", "dp_message": "0", "end_pos": "288"}], "beg_pos": "262", "content": "s eh n", "end_pos": "288", "syll_accent": "1", "syll_score": "79.942500"}, {"content": "t ax n s", "end_pos": "314", "syll_accent": "0", "syll_score": "91.230660", "phone": [{"dp_message": "0", "end_pos": "295", "beg_pos": "288", "content": "t"}, {"beg_pos": "295", "content": "ax", "dp_message": "0", "end_pos": "300"}, {"beg_pos": "300", "content": "n", "dp_message": "0", "end_pos": "306"}, {"content": "s", "dp_message": "0", "end_pos": "314", "beg_pos": "306"}], "beg_pos": "288"}]}, {"global_index": "6", "index": "6", "property": "0", "content": "test", "dp_message": "0", "end_pos": "361", "total_score": "77.092740", "syll": {"syll_accent": "0", "syll_score": "77.092740", "phone": [{"content": "t", "dp_message": "0", "end_pos": "326", "beg_pos": "314"}, {"dp_message": "0", "end_pos": "336", "beg_pos": "326", "content": "eh"}, {"end_pos": "344", "beg_pos": "336", "content": "s", "dp_message": "0"}, {"content": "t", "dp_message": "0", "end_pos": "361", "beg_pos": "344"}], "beg_pos": "314", "content": "t eh s t", "end_pos": "361"}, "beg_pos": "314"}], "beg_pos": "0"}, "beg_pos": "0", "content": "This is an example of sentence test.", "end_pos": "430", "except_info": "0", "is_rejected": "false", "total_score": "93.939920", "word_count": "7"}}, "lan": "en", "type": "study"}}, "code": "0", "desc": "success", "sid": "wse006d97bc@ch6e350fc1ccdb477500"}
  • 乱说结果
{"data": {"read_sentence": {"type": "study", "version": "6.5.0.1011", "rec_paper": {"read_chapter": {"is_rejected": "true", "total_score": "26.000040", "sentence": {"end_pos": "430", "index": "0", "total_score": "26.000040", "beg_pos": "0"}, "beg_pos": "0", "end_pos": "430", "except_info": "28676"}}, "lan": "en"}}, "code": "0", "desc": "success", "sid": "wse006d91fb@ch6e350fc1c9a3477500"}

测试样例代码见:
https://github.com/yzy199391/kedaxunfeiIseDemo

你可能感兴趣的:(java代码实践)