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

fix: speechSynthesis now returns voices on Windows #14070

Merged
merged 1 commit into from
Aug 24, 2018

Conversation

robinwassen
Copy link
Contributor

@robinwassen robinwassen commented Aug 14, 2018

The implementation of tts_win.cc was brought up-to-speed with Chromium 70.0.3522.1 (https://chromium.googlesource.com/chromium/src.git/+/70.0.3522.1/chrome/browser/speech/tts_win.cc).

This to solve the issue with no voices being returned on Windows (#11585).

Ping @AlbrechtStriffler

Checklist
  • PR description included and stakeholders cc'd
  • npm test passes
  • tests are changed or added
  • relevant documentation is changed or added
  • PR title follows semantic commit guidelines
Steps to test this
Setup text-to-speech in Windows
  1. Install Microsoft Speech Platform - Runtime (https://www.microsoft.com/en-us/download/details.aspx?id=27225)
  2. Install some text-to-speech voices (https://www.microsoft.com/en-us/download/details.aspx?id=27224)
Run the demo application
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Hello World!</title>
  </head>
  <body>

    <form id="speechSynthesisForm">
      <h2>speechSynthesis demo</h2>
      <label for="voiceSelect">Voice</label>
      <select id="voiceSelect">
        <option>No voices available</option>
      </select>
      <div>
        <label for="textInput">Text to speak</label>
        <input type="text" id="textInput" />
      </div>
      <input type="submit" value="Speak" />
    </form>

    <script>
      (function() {
        var synth = speechSynthesis;

        var voiceSelect = document.getElementById("voiceSelect");
        var textInput = document.getElementById("textInput");
        var speechSynthesisForm = document.getElementById("speechSynthesisForm");

        function populateVoiceList() {
          var voices = synth.getVoices();

          if (voices.length == 0) {
            return;
          }

          voiceSelect.innerHTML = "";
          for (var i = 0; i < voices.length; i++) {
            var voiceOption = document.createElement("option");
            voiceOption.innerText = voices[i].name;
            voiceOption.value = voices[i].voiceURI;
            voiceSelect.appendChild(voiceOption);
          }
        }

        function speak() {
          var voices = synth.getVoices();

          if (voices.length == 0) {
            return;
          }

          var selectedVoice = null;
          for (var i = 0; i < voices.length; i++) {
            if (voices[i].voiceURI === voiceSelect.value) {
              selectedVoice = voices[i];
              break;
            }
          }

          var utterance = new SpeechSynthesisUtterance(textInput.value);
          utterance.voice = selectedVoice;
          synth.speak(utterance);
        }

        populateVoiceList();
        synth.onvoiceschanged = populateVoiceList;

        speechSynthesisForm.onsubmit = function(e) {
          e.preventDefault();
          speak();
        }
      })();
    </script>
  </body>
</html>

demo_app

Notes: speech synthesis APIs now return OS voices on Windows

The implementation was brought up-to-speed with Chromium 70.0.3522.1 (https://chromium.googlesource.com/chromium/src.git/+/70.0.3522.1/chrome/browser/speech/tts_win.cc).

This to solve issues with Windows not returning voices (electron#11585).
@robinwassen robinwassen requested a review from a team August 14, 2018 07:12
@MarshallOfSound
Copy link
Member

refs: https://cs.chromium.org/chromium/src/chrome/browser/speech/tts_win.cc?q=tts_win&dr

Can you add a test for this, to verify that windows OS level voices are returned on Windows 👍

@robinwassen
Copy link
Contributor Author

@MarshallOfSound That might be a problem since the OS level voices depend on the Windows installation, I had no voices available before I installed the Microsoft Speech Platform and some voices on my PC at home.

If you have any idea how a test for this might work I would be glad to implement it.

@MarshallOfSound
Copy link
Member

@robinwassen Fair enough, if it's not something we can test predictably out of the box let's not waste time figuring it out 👍

@MarshallOfSound MarshallOfSound merged commit 4cf264f into electron:master Aug 24, 2018
@release-clerk
Copy link

release-clerk bot commented Aug 24, 2018

Release Notes Persisted

speech synthesis APIs now return OS voices on Windows

@robinwassen robinwassen deleted the tts-win-upgrade branch September 17, 2018 08:22
@AlbrechtStriffler
Copy link

Ok, so as far as I can tell this issue is fixed and merged to the master. Thanks a lot for that!
I just checked the electron releases and there it seems like the fix hasn't made it into an official release yet. I also checked by updating our app to electron 3.0.2 and see if the voices are back - no luck.
I'm sorry, I don't really know the process here with electron, but is there an estimate when this fix makes it into an official release (nightly or better)?

@deepak1556
Copy link
Member

@AlbrechtStriffler there will be a beta release from master by this Friday, you can expect this fix in that release. Thanks!

@vdegenne
Copy link

vdegenne commented Feb 6, 2019

I'd like to reopen this issue because it doesn't work for me, though I followed the instructions mentioned above.
I am running Windows 10 (x64), Electron v4.0.4 (Chromium v69.0.3497.106) and Node v10.11.0.
I installed the Speech Platform Runtime (x64) following the link from this page and I have some TTS modules installed on my computer.
But running the demo leaves me with the "No voices available" option and no idea what to do next.
I tried to add app.commandLine.appendSwitch('--enable-speech-dispatcher'); in my code but it does nothing too.

If I download Chromium Version 74.0.3696.0 (Developer Build) (64-bit) the voices installed on my OS are present when invoking .getVoices().
I can't tell if the problem comes from the version of Chromium embedded in Electron which appears to be old compared to the version which works. Or is Electron preventing the Chromium host to load any voices ? I really can't tell.

At least I would like to upgrade the version of Chromium used by Electron so I could know where the problem comes from and maybe fix the no-voices issue. How can I do that ?

@vdegenne
Copy link

vdegenne commented Feb 6, 2019

Commenting my own comment above. It seems that it works now, I removed the dev dependencies in my local project and use global electron. I think this was the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants