Cordova: Is there a way to detect whether Voice Dictation has ended on iOS

Please note that this question is for Cordova/PhoneGap/Hybrid apps.

I have a <textarea> for which I want the app to behave in a certain way only when voice dictation input has ended -- ie user tabs "Done". However, this is proving to be rather difficult.

iOS's UIKit provides dictationRecordingDidEnd event under UITextInput but I am not sure if this can even be used in a hybrid app. (iOS Developer Library doc here)

EDIT: I am using ionic-plugin-keyboard .

Any ideas would be greatly appreciated.


Maybe you can try to use the SpeechRecognitionPlugin or cordova-plugin-iflyspeech

For the cordova-plugin-iflyspeech you have 13 events to have control of the voice control in your iOS device like:

SpeechBegin
SpeechEnd
SpeechCancel
SpeechResults
SpeechError  
VolumeChanged

SpeakBegin
SpeakPaused
SpeakResumed
SpeakCancel
SpeakCompleted 
SpeakProgress
BufferProgress

And has support for a big number of languages like: English (US), English (UK), French, Spanish, Italian, etc.

This is an example of the documentation

function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
    $('div#status').html( 'speech engine ready' );
}
function startReading() {
    var text = $('textarea#read').val();
    navigator.speech.startSpeaking( text, {voice_name: 'xiaoyan'} );
}
function stopReading() {
    navigator.speech.stopSpeaking();
}
function startListening() {
    $('div#status').html( 'Listening, please speak.' );

    navigator.speech.startListening({language:'en-US'} function(str) {
            // this is what the device hear and understand
            $('textarea#read').val( str );
        });
}
function stopListening() {
    navigator.speech.stopListening();
}

And here you can bind the iOS method dictationRecordingDidEnd to: stopListening(); or cancelListening(); methods, depending the action.

链接地址: http://www.djcxy.com/p/90076.html

上一篇: 将Angular2集成到现有的JSF项目中

下一篇: 科尔多瓦:有没有办法来检测语音听写是否已在iOS上结束