使用web形式实现语音识别

开心得嘞!终于在web界面实现接入语音识别接口啦!

相关步骤的具体实现

还是熟悉的步骤,先进入讯飞官网:https://www.xfyun.cn/

然后注册、创建新应用,获取到自己的相关的三个参数!!!!!!!

这三个:

语音识别的话,主要是发生在前端,主要是跟js文件、css文件以及html文件有关,后端的话,就是获取到输入框里面语音识别的结果,然后传输到后台的servlet里面,之后的程序,

就是按照我们之前的操作来就好啦!简简单单的查询啦!没问题的嘞!

接下来继续说前端的语音识别:

前端的识别的界面就很好写,我借鉴了相关的代码:

<div class="btn-group">
                            <section class="voice-box">
                                        <input class="form-control" style="width:1100px" type="search" name="voice" id="voice-txt" placeholder="语音识别内容">
                                        <button type="button" id="start-btn" class="btn btn-sm btn-outline-secondary" style="font-size: 30px">语音识别</button>
                            </section>
                        </div>

                        <section class="fixed-box" id="fixed-box">
                            <div class="fixed-main">
                                <button class="fixed-close" id="close-btn"></button>
                                <div id="fixed-txt">Hello! 请说出你想说的话!!!</div>
                                <div class="fixed-icon">
                                    <img src="./images/index/dog1.png" alt="" />
                                </div>
                            </div>
                        </section>

然后需要在script标签里面接上讯飞的语音识别接口(好吧,还是借鉴到大佬的代码了)

之后的代码,在这里:

转载了网友的代码:https://github.com/MuGuiLin/VoiceDictation

posted @ 2023-04-15 20:00  yesyes1  阅读(398)  评论(0编辑  收藏  举报