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

Web Speech API SpeechSynthesisUtterance pitch, rate, volume attribute tests verification #8795

Open
guest271314 opened this issue Dec 24, 2017 · 3 comments

Comments

@guest271314
Copy link
Contributor

guest271314 commented Dec 24, 2017

Setting SpeechSynthesisUtterance.volume does not appear to change volume of audio output of window.speechSynthesis.speak() at Chromium or Firefox at *nix

async function speechSynthesisUtteranceTests() {
  // 12-24-2017
  console.group("SpeechSynthesisUtterance pitch, rate, volume attribute tests")
  const text = `hello universe`;
  // https://w3c.github.io/speech-api/speechapi.html#dfn-utterancepitch
  // `pitch` 0-2 
  for (let i = 0; i < 2; i += 0.3333333333333333) {
    const utterance = new SpeechSynthesisUtterance(text);
    utterance.pitch = i;
    console.log(`SpeechSynthesisUtterance pitch: ${utterance.pitch}`);
    await new Promise(resolve => {
      utterance.onend = e => {
        utterance.onend = null;
        resolve()
      }
      window.speechSynthesis.speak(utterance);
    })
  }
  // https://w3c.github.io/speech-api/speechapi.html#dfn-utterancerate
  // `rate` 0.1-10
  for (let i = .1; i < 10; i += .1) {
    const utterance = new SpeechSynthesisUtterance(text);
    utterance.rate = i;
    console.log(`SpeechSynthesisUtterance rate: ${utterance.rate}`);
    await new Promise(resolve => {
      utterance.onend = e => {
        utterance.onend = null;
        resolve()
      }
      window.speechSynthesis.speak(utterance);
    })
  }
  // https://w3c.github.io/speech-api/speechapi.html#dfn-utterancevolume
  // volume 0-1
  for (let i = 0; i < 1; i += 0.3333333333333333 / 2) {
    const utterance = new SpeechSynthesisUtterance(text);
    utterance.volume = i;
    console.log(`SpeechSynthesisUtterance volume: ${utterance.volume}`);
    await new Promise(resolve => {
      utterance.onend = e => {
        utterance.onend = null;
        resolve()
      }
      window.speechSynthesis.speak(utterance)
    })
  }
  console.groupEnd()
}
speechSynthesisUtteranceTests();

We could utilize a uniform procedure to verify the results within the required test format.

One approach would be to record the output of window.speechSynthesis.speak() using MediaRecorder then perform the tests on the output using AudioContext.AnalyzerNode, though not certain if the audio output of the recording will reflect the original audio output.

@gsnedders
Copy link
Member

I'm tentatively labelling this as untestable, because I'm not sure we can test it yet.

We can't use MediaRecorder because we can't rely on having a microphone (given most vendor's CI systems run on VMs that won't have any, and certainly couldn't rely on being on being otherwise quiet).

@guest271314
Copy link
Contributor Author

@gsnedders

We can't use MediaRecorder because we can't rely on having a microphone

A microphone is not necessary to record output of speechSynthesis.speak() guest271314/SpeechSynthesisRecorder@87be7b9. The issue with using MediaRecorder is that the resulting audio/webm would be different from the original audio output.

From perspective here "untestable" means that the implementation is not capable of being tested, which is not the case and needs to be verified as well.

We simply need to consider and try the possible available approaches and concur on the results.

@gsnedders
Copy link
Member

From perspective here "untestable" means that the implementation is not capable of being tested, which is not the case and needs to be verified as well.

FWIW, "untestable" means we can't do it with an automated test with no human in the loop.

But yeah, if MediaRecorder can get the audio output (which I didn't realise it could), then we can almost certainly do this well enough.

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