Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webkit Speech Recognition? #25

Closed
ANTEVETY opened this issue Oct 8, 2019 · 1 comment
Closed

webkit Speech Recognition? #25

ANTEVETY opened this issue Oct 8, 2019 · 1 comment

Comments

@ANTEVETY
Copy link

ANTEVETY commented Oct 8, 2019

Hey. I'm trying to configure voice recognition to speech and it either does not work or is partially supported. I reassembled the plugin with console commands added, but that didn't work. Maybe you noticed and I'm doing something wrong. And how can this be made to work?
in Plugins\BLUI\Source\Blu\Private\BluManager.cpp

BluManager::CPURenderSettings = false;
	/////////////////

        command_line->AppendSwitch("off-screen-rendering-enabled");
	command_line->AppendSwitchWithValue("off-screen-frame-rate", "60");
	command_line->AppendSwitch("enable-font-antialiasing");
	command_line->AppendSwitch("enable-media-stream");
	command_line->AppendSwitch("enable-speech-input");
	command_line->AppendSwitch("enable-speech-api");
	command_line->AppendSwitch("enable-speech-synthesis-api");

	// Should we use the render settings that use less CPU?

I enclose a working demo html code:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Voice recognition and text reading</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
  <div class="controlbuttons" class="container-fluid" class="d-flex justify-content-center">
      <button type="button" class="btn btn-primary" onclick="speech ()">Listen</button>
      <button type="button" class="btn btn-success" onclick="talk ()">Talk</button>
      <button type="button" class="btn btn-danger" onclick="stop ()">Stop</button>
  </div>

  <div class="controlbuttons" class="container-fluid" id="vue">
    <h4>Intermediate result: {{ speaktext }}</h4>
    <h4 style="color:rgb(63, 70, 172);">You said: {{ speakstoptext }}</h4>
  </div>

  <script>
  // Create a recognizer
  var recognizer = new webkitSpeechRecognition();

  // We put an option so that recognition starts even before the user finishes talking
  recognizer.interimResults = true;

  // What language will we recognize?
  recognizer.lang = 'en-US';

  // We use the callback to process the results
  recognizer.onresult = function (event) {
    var result = event.results[event.resultIndex];
    var text = result[0].transcript;
    if (result.isFinal) {
      //alert('You said: ' + text);
      app.speakstoptext = text;
    } else {
      //console.log('Intermediate result: ', text);
      app.speaktext = text;
    }
  };

  function speech () {
    // We begin to listen to the microphone and recognize the voice
    recognizer.start();
  }

  var synth = window.speechSynthesis;
  var utterance = new SpeechSynthesisUtterance('How about we say this now? This is quite a long sentence to say.');

  function talk () {
    synth.speak (utterance);
  }

  function stop () {
    synth.pause();
  }

  </script>

  
  <script>
      var app = new Vue({
      el: '#vue',
      data: {
        speaktext: 'Hello',
        speakstoptext: 'Hello' 
      },
      methods: {
        speak: function(event) {
          this.speak = event.target.value
        },
        speakstop: function(event) {
          this.speakstop = event.target.value
        }
      }
    })
  </script>

  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  <style>
      .controlbuttons {
        border: 1px solid powderblue;
        padding: 30px;
      }
  </style>
</body>
</html>
@getnamo
Copy link
Owner

getnamo commented Oct 8, 2019

I'm assuming you're using web speech api. For chromium it needs the google api keys, see this CEF (what BLUI is based on) discussion https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=12744 and https://code.google.com/archive/p/chromiumembedded/issues/1297

@ANTEVETY ANTEVETY closed this as completed Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants