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

Can the recorded audioOutput be saved to the file system? #11

Closed
fninsiima opened this issue Jun 22, 2018 · 1 comment
Closed

Can the recorded audioOutput be saved to the file system? #11

fninsiima opened this issue Jun 22, 2018 · 1 comment

Comments

@fninsiima
Copy link

fninsiima commented Jun 22, 2018

Just wondering if there is an option of saving the recording to file system

@guest271314
Copy link
Owner

@fninsiima Yes, you can use tts.blob(), <a> element with download attribute, and href attribute set to Blob URL

let ttsRecorder = new SpeechSynthesisRecorder({
  text:"The revolution will not be televised", 
  utteranceOptions:{
    voice: "english-us espeak",
    lang: "en-US",
    pitch: .75,
    rate: 1,
    volume: 1
  }
});

ttsRecorder.start()
.then(tts => tts.blob())
.then(({tts, data}) => {
  const a = document.createElement("a");
  const blobURL = URL.createObjectURL(data);
  a.download = "synthesizedAudio";
  a.href = blobURL;
  document.body.appendChild(a);
  a.click();
})
.catch(err => console.log(err))

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

No branches or pull requests

2 participants