Нема описа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Form Input Groups
  3. */
  4. 'use strict';
  5. (function () {
  6. const speechToText = $('.speech-to-text'); // ! jQuery dependency for speech to text
  7. // Speech To Text
  8. if (speechToText.length) {
  9. var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition;
  10. if (SpeechRecognition !== undefined && SpeechRecognition !== null) {
  11. var recognition = new SpeechRecognition(),
  12. listening = false;
  13. speechToText.on('click', function () {
  14. const $this = $(this);
  15. recognition.onspeechstart = function () {
  16. listening = true;
  17. };
  18. if (listening === false) {
  19. recognition.start();
  20. }
  21. recognition.onerror = function (event) {
  22. listening = false;
  23. };
  24. recognition.onresult = function (event) {
  25. $this.closest('.form-send-message').find('.message-input').val(event.results[0][0].transcript);
  26. };
  27. recognition.onspeechend = function (event) {
  28. listening = false;
  29. recognition.stop();
  30. };
  31. });
  32. }
  33. }
  34. })();