Speech to Text Compatible with SN

david_hreben
Giga Expert

Hello Guys,

Do you have any recomendation for any API that can be integrated to SN for speech to text functionality? The idea is to capture text from speech and save it in SN to later be sent as a text to watson for analysis. Anything would be helpful. Thanks!

4 REPLIES 4

Jace Benson
Mega Sage

This was actually the winning idea for K16 or K17.  Pretty much let you talk to your browser to do things.

https://github.com/CloudPires/LUDI

 

I could only get it to work on chrome, not ff, but it is a year old.

sushant007
Kilo Guru

How can i import this project to my servicenow developer instance?

I downloaded / cloned the branch , but not sure how these customer updates be imported?

Can you please help with this?

You need to install the app via the studio page and then import from git.

Siddarth2
Tera Contributor

Hi David,

 

You can create an OnLoad client script on table  using below script which would create a button next to the OOB fields mentioned at bottom, you can amend the code as per your requirements... This solves half the ask to convert speech to text, this needs to be packaged into JSON as an API call which needs to be processed by WATSON.

 

function addVoiceButton(fieldName) {
  var field = g_form.getControl(fieldName);
  if (!field) return;

  // Prevent adding multiple buttons
  if (field.nextSibling && field.nextSibling.classList && field.nextSibling.classList.contains('voice-record-btn')) {
    return;
  }

  var recordBtn = document.createElement('button');
  recordBtn.type = 'button';
  recordBtn.innerHTML = '🎙️';
  recordBtn.title = 'Voice to Text';
  recordBtn.className = 'voice-record-btn';
  recordBtn.style.marginLeft = '10px';
  recordBtn.style.fontSize = '1.6rem';
  recordBtn.style.cursor = 'pointer';

  recordBtn.onclick = function() {
    if (!('webkitSpeechRecognition' in window)) {
      alert('Speech recognition not supported in this browser.');
      return;
    }
    var recognition = new webkitSpeechRecognition();
    recognition.continuous = false;
    recognition.interimResults = false;
    recognition.lang = 'en-US';
    recognition.onresult = function(event) {
      if (event.results.length > 0) {
        var transcript = event.results[0][0].transcript;
        // Insert transcript at cursor position
        var start = field.selectionStart;
        var end = field.selectionEnd;
        var value = field.value;
        field.value = value.substring(0, start) + transcript + value.substring(end);
        g_form.setValue(fieldName, field.value);
        field.selectionStart = field.selectionEnd = start + transcript.length;
        field.focus();
      }
    };
    recognition.onerror = function(event) {
      alert('Speech recognition error: ' + event.error);
    };
    recognition.start();
  };

  field.insertAdjacentElement('afterend', recordBtn);
}

function onLoad() {
  addVoiceButton('description');
  addVoiceButton('short_description');
 }

onLoad();
 
 
Mark this as helpful.
Thanks
Siddarth