首页 文章

是否可以使用cordova-plugin-speechrecognition显示语音文本

提问于
浏览
0

我正在寻找一种方法来显示使用语音识别所说的文本 . 我使用过cordova-plugin-speechrecognition . 我可以使用startListening功能点击麦克风和speack . 但有没有办法在屏幕上显示语音文字 . 参考:https://ourcodeworld.com/articles/read/401/how-to-use-the-speech-recognition-api-in-cordova

1 回答

  • 0

    您可以将文本放在html文本标记中,在我的示例中为id sstBtn

    function startRecognition(){
        return window.speechRecognition.startRecognition({
            language:"en-US",
            showPopup: true
        }).then(function(data){
            console.log("Results",data);
            var sttElement = parentElement.querySelector('.stt');
            sttElement.innerHTML = data[0]
        }).catch(function(err){
            console.error(err);
        });
    }
    

相关问题