I am utilizing WebSpeech API to permit customers speech recognition on my web site. I am utilizing instance 3 on this web page: https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html.
My code appears like this:
operate _google_speech_speak_form($type, &$form_state) { $modulepath = drupal_get_path('module','google_speech'); $type['textarea'] = array( '#sort' => 'textfield', '#title' => t('Converse It'), '#prefix' => '<div id="api">', '#suffix' => '</div>', ); $type['button'] = array( '#sort' => 'button', '#attributes' => array('onclick' => 'return (false);'), '#worth' => t('Click on to Converse'), ); $type['submitt'] = array( '#sort' => 'button', '#worth' => t('Save'), ); $type['#after_build'] = array('_google_speech_speak_after_build'); return $type;} operate _google_speech_speak_form_submit($type, &$form_state) { $speechkey = $form_state['values']['textarea']; drupal_set_message($speechkey); echo "check";} operate _google_speech_speak_after_build($type, &$form_state) { drupal_add_js(drupal_get_path('module', 'google_speech').'/webspeech.js'); return $type;}
Webspeech.js:
Drupal.behaviors.[google_speech] = operate(context) { $('#edit-button').click on(operate() { var recognizing; var recognition = new webkitSpeechRecognition(); recognition.steady = true; reset(); recognition.onend = reset; recognition.onresult = operate (occasion) { for (var i = resultIndex; i < occasion.outcomes.size; ++i) { if (occasion.outcomes.remaining) { textarea.worth += occasion.outcomes[i][0].transcript; } } } operate reset() { recognizing = false; button.innerHTML = "Click on to Converse"; } operate toggleStartStop() { if (recognizing) { recognition.cease(); reset(); } else { recognition.begin(); recognizing = true; button.innerHTML = "Click on to Cease"; } } }); };
I referred to this query: The way to make type buttons name solely javascript? Drupal Development “toggle” button shouldn’t be refreshing Drupal Development web page (which is nice) nevertheless it’s additionally not toggling speech recognition prefer it ought to. There aren’t any errors on Drupal Development display screen or in Drupal Development logs. Any concepts?