【技术博客文章】火山安卓调用讯飞语音识别
一、布局配置①用到线性布局器、文本框、编辑框、按钮、进度对话框类、简单下拉列表框,按下图布局
https://www.lkuaiy.com/image/editor/15951140797666.png
②配置讯飞语音支持库,创建讯飞语音对象变量
https://www.lkuaiy.com/image/editor/15951140974189.png
https://www.lkuaiy.com/image/editor/15951141057956.png
二、文本转语音
①"通知_被创建"事件下,先初始化语音引擎
https://www.lkuaiy.com/image/editor/15951141232102.png
③创建列表事件
https://www.lkuaiy.com/image/editor/15951141397887.png
https://www.lkuaiy.com/image/editor/15951141483674.png
https://www.lkuaiy.com/image/editor/15951141543966.gif
④设置按钮事件
先检查是否有网络,然后开始转换语音
红箭头处是窗口2的功能,下面会讲到
https://www.lkuaiy.com/image/editor/15951141675676.png
⑤设置讯飞事件
https://www.lkuaiy.com/image/editor/15951141822147.png
https://www.lkuaiy.com/image/editor/15951141942133.png
https://www.lkuaiy.com/image/editor/15951142023987.png
三、语音识别
①新建一个窗口(Ctrl D)
https://www.lkuaiy.com/image/editor/15951142139779.png
②布局界面
添加按钮和编辑框,布局如下图
并创建讯飞识别对象类变量
https://www.lkuaiy.com/image/editor/15951142285427.png
https://www.lkuaiy.com/image/editor/15951142435883.png
③按钮事件下创建识别功能
https://www.lkuaiy.com/image/editor/15951142653183.png
④同样的,给讯飞识别对象添加事件
https://www.lkuaiy.com/image/editor/15951143361626.png
https://www.lkuaiy.com/image/editor/15951143462637.png
https://www.lkuaiy.com/image/editor/15951143565170.png
四、演示效果
这里只能演示过程,听不到声音,具体请安装到手机测试
https://www.lkuaiy.com/image/editor/15951143679597.gif
本资源下载地址:点击下载本文对应哪里源码
推广火山,义不容辞 推广火山,义不容辞 我的识别结果是如下的JSON字符串,怎么提取文字呢?
{"sn":1,"ls":false,"bg":0,"ed":0,"ws":[{"bg":69,"cw":[{"sc":0.0,"w":"白日"}]},{"bg":141,"cw":[{"sc":0.0,"w":"依"}]},{"bg":169,"cw":[{"sc":0.0,"w":"山"}]},{"bg":197,"cw":[{"sc":0.0,"w":"尽"}]}]}
{"sn":2,"ls":true,"bg":0,"ed":0,"ws":[{"bg":236,"cw":[{"sc":0.0,"w":"。"}]}]}
页:
[1]