{"id":21293203,"url":"https://github.com/guest271314/speechsynthesisrecorder","last_synced_at":"2025-07-11T16:32:29.368Z","repository":{"id":57367253,"uuid":"94657026","full_name":"guest271314/SpeechSynthesisRecorder","owner":"guest271314","description":"Get audio output from window.speechSynthesis.speak() call  as ArrayBuffer, AudioBuffer, Blob, MediaSource, MediaStream, ReadableStream, other object or data types","archived":false,"fork":false,"pushed_at":"2018-07-23T22:16:34.000Z","size":41,"stargazers_count":82,"open_issues_count":7,"forks_count":19,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-12T18:16:10.181Z","etag":null,"topics":["audio","mediarecorder","speech-api","speech-synthesis"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guest271314.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-18T00:46:49.000Z","updated_at":"2024-09-29T02:32:11.000Z","dependencies_parsed_at":"2022-08-23T20:10:17.455Z","dependency_job_id":null,"html_url":"https://github.com/guest271314/SpeechSynthesisRecorder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guest271314%2FSpeechSynthesisRecorder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guest271314%2FSpeechSynthesisRecorder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guest271314%2FSpeechSynthesisRecorder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guest271314%2FSpeechSynthesisRecorder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guest271314","download_url":"https://codeload.github.com/guest271314/SpeechSynthesisRecorder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225741166,"owners_count":17516895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","mediarecorder","speech-api","speech-synthesis"],"created_at":"2024-11-21T13:53:45.770Z","updated_at":"2024-11-21T13:53:46.392Z","avatar_url":"https://github.com/guest271314.png","language":"JavaScript","readme":"# SpeechSynthesisRecorder.js\n\nUse [`navigator.mediaDevices.getUserMedia()`][getUserMedia] and \n[`MediaRecorder`][MediaRecorder] to get audio output from \n[`window.speechSynthesis.speak()`][speak] call as [`ArrayBuffer`][ArrayBuffer], \n[`AudioBuffer`][AudioBuffer], [`Blob`][Blob], [`MediaSource`][MediaSource], \n[`ReadableStream`][ReadableStream], or other object or data \ntypes, see [MediaStream, ArrayBuffer, Blob audio result from speak() for recording?](https://lists.w3.org/Archives/Public/public-speech-api/2017Jun/0000.html).\n\n## Install\n\nAdd the following script tag\n\n```html\n\u003cscript type=\"text/javascript\" src=\"https://unpkg.com/speech-synthesis-recorder@1.2.1/SpeechSynthesisRecorder.js\"\u003e\u003c/script\u003e\n```\n\nor npm install\n\n```bash\n$ npm install --save speech-synthesis-recorder\n```\n\n## Usage\n\nSelect `Monitor of Built-in Audio Analog Stereo` option instead of \n`Built-in Audio Analog Stereo` option at `navigator.mediaDevices.getUserMedia()` \nprompt.\n\n```js\nlet ttsRecorder = new SpeechSynthesisRecorder({\n  text: \"The revolution will not be televised\", \n  utteranceOptions: {\n    voice: \"english-us espeak\",\n    lang: \"en-US\",\n    pitch: .75,\n    rate: 1\n  }\n});\n```\n\n### ArrayBuffer\n\n```js\nttsRecorder.start()\n  // `tts` : `SpeechSynthesisRecorder` instance, `data` : audio as `dataType` or method call result\n  .then(tts =\u003e tts.arrayBuffer())\n  .then(({tts, data}) =\u003e {\n    // do stuff with `ArrayBuffer`, `AudioBuffer`, `Blob`,\n    // `MediaSource`, `MediaStream`, `ReadableStream`\n    // `data` : `ArrayBuffer`\n    tts.audioNode.src = URL.createObjectURL(new Blob([data], {type:tts.mimeType}));\n    tts.audioNode.title = tts.utterance.text;\n    tts.audioNode.onloadedmetadata = () =\u003e {\n      console.log(tts.audioNode.duration);\n      tts.audioNode.play();\n    }\n  })\n```\n\n### AudioBuffer\n\n```js\nttsRecorder.start()\n  .then(tts =\u003e tts.audioBuffer())\n  .then(({tts, data}) =\u003e {\n    // `data` : `AudioBuffer`\n    let source = tts.audioContext.createBufferSource();\n    source.buffer = data;\n    source.connect(tts.audioContext.destination);\n    source.start()\n  })\n```\n### Blob\n\n```js\nttsRecorder.start()\n  .then(tts =\u003e tts.blob())\n  .then(({tts, data}) =\u003e {\n    // `data` : `Blob`\n    tts.audioNode.src = URL.createObjectURL(blob);\n    tts.audioNode.title = tts.utterance.text;\n    tts.audioNode.onloadedmetadata = () =\u003e {\n      console.log(tts.audioNode.duration);\n      tts.audioNode.play();\n    }\n  })\n```\n\n### ReadableStream\n\n```js\nttsRecorder.start()\n  .then(tts =\u003e tts.readableStream())\n  .then(({tts, data}) =\u003e {\n    // `data` : `ReadableStream`\n    console.log(tts, data);\n    data.getReader().read().then(({value, done}) =\u003e {\n      tts.audioNode.src = URL.createObjectURL(value[0]);\n      tts.audioNode.title = tts.utterance.text;\n      tts.audioNode.onloadedmetadata = () =\u003e {\n        console.log(tts.audioNode.duration);\n        tts.audioNode.play();\n      }\n    })\n  })\n```\n\n### MediaSource\n\n```js\nttsRecorder.start()\n  .then(tts =\u003e tts.mediaSource())\n  .then(({tts, data}) =\u003e {\n    console.log(tts, data);\n    // `data` : `MediaSource`\n    tts.audioNode.srcObj = data;\n    tts.audioNode.title = tts.utterance.text;\n    tts.audioNode.onloadedmetadata = () =\u003e {\n      console.log(tts.audioNode.duration);\n      tts.audioNode.play();\n    }\n  })\n```\n\n### MediaStream\n\n```js\nlet ttsRecorder = new SpeechSynthesisRecorder({\n  text: \"The revolution will not be televised\", \n  utternanceOptions: {\n    voice: \"english-us espeak\",\n    lang: \"en-US\",\n    pitch: .75,\n    rate: 1\n  }, \n  dataType:\"mediaStream\"\n});\nttsRecorder.start()\n  .then(({tts, data}) =\u003e {\n    // `data` : `MediaStream`\n    // do stuff with active `MediaStream`\n  })\n  .catch(err =\u003e console.log(err))\n```\n\n## Demo\n[plnkr][plnkr]\n\n[plnkr]: https://plnkr.co/edit/PmpCSJ9GtVCXDhnOqn3D?p=preview\n[getUserMedia]: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia\n[MediaRecorder]: https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder\n[speak]: https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis/speak\n[ArrayBuffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer\n[AudioBuffer]: https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer\n[Blob]: https://developer.mozilla.org/en-US/docs/Web/API/Blob\n[MediaSource]: https://developer.mozilla.org/en-US/docs/Web/API/MediaSource\n[ReadableStream]: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream\n[MediaStream]: https://developer.mozilla.org/en-US/docs/Web/API/MediaStream\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguest271314%2Fspeechsynthesisrecorder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguest271314%2Fspeechsynthesisrecorder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguest271314%2Fspeechsynthesisrecorder/lists"}