{"id":22448140,"url":"https://github.com/msub2/sepia-speechrecognition-polyfill","last_synced_at":"2025-08-01T21:32:51.286Z","repository":{"id":133553825,"uuid":"574239398","full_name":"msub2/sepia-speechrecognition-polyfill","owner":"msub2","description":"A polyfill for SpeechRecognition built to function with a SEPIA STT server.","archived":false,"fork":false,"pushed_at":"2023-06-15T21:31:31.000Z","size":162,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-01T21:37:15.521Z","etag":null,"topics":["polyfill","sepia","speech-recognition","speech-to-text","stt","webspeech","webspeech-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msub2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-04T20:59:52.000Z","updated_at":"2023-11-20T06:57:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"548d7d28-ec3f-4fc7-a11f-26f15171e440","html_url":"https://github.com/msub2/sepia-speechrecognition-polyfill","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msub2%2Fsepia-speechrecognition-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msub2%2Fsepia-speechrecognition-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msub2%2Fsepia-speechrecognition-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msub2%2Fsepia-speechrecognition-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msub2","download_url":"https://codeload.github.com/msub2/sepia-speechrecognition-polyfill/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228408696,"owners_count":17915234,"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":["polyfill","sepia","speech-recognition","speech-to-text","stt","webspeech","webspeech-api"],"created_at":"2024-12-06T04:21:23.567Z","updated_at":"2024-12-06T04:21:24.116Z","avatar_url":"https://github.com/msub2.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SEPIA SpeechRecognition Polyfill\n\nAn implementation of the SpeechRecognition portion of the [Web Speech API](https://wicg.github.io/speech-api/) built to function with a [SEPIA STT server](https://github.com/SEPIA-Framework/sepia-stt-server). This polyfill allows for developers to have consistent cross-platform\nsupport for speech recognition, including on platforms that do not have access to the Web Speech API natively.\n\nThis polyfill attempts to conform to the existing specification draft as close as possible. Any deviations will be noted below.\n\n## Setup\n\n### Installation\n\nFor use with Node or NPM:\n\n```bash\nnpm i sepia-speechrecognition-polyfill\n```\n\nYou can also load it from a CDN link:\n\n```text\nhttps://cdn.jsdelivr.net/npm/sepia-speechrecognition-polyfill@1.0.0\nhttps://unpkg.com/sepia-speechrecognition-polyfill@1.0.0\n```\n\n### Building Locally\n\n```bash\ngit clone https://github.com/msub2/sepia-speechrecognition-polyfill\ncd sepia-speechrecognition-polyfill\nnpm i\nnpm run build\n```\n\n## Usage\n\nThis polyfill requires you to connect to a SEPIA STT server. For more detailed instructions on how to set up a SEPIA STT server, you can refer to the setup instructions on the main repo [here](https://github.com/SEPIA-Framework/sepia-stt-server#quick-start-with-docker).\n\n### API\n\nThe polyfill exports a function, `sepiaSpeechRecognitionInit()`, and a class, `SepiaSpeechRecognitionConfig`.\n\n`sepiaSpeechRecognitionInit` takes in a `SepiaSpeechRecognitionConfig` as a parameter and returns the polyfilled SpeechRecognition class.\n\n`SepiaSpeechRecognitionConfig` contains properties for configuring your connection to the SEPIA STT server, which are as follows:\n\n|Property|Description|Default Value|\n|-|-|-|\n|`serverUrl`|The URL for the SEPIA STT server.|`\"http://localhost:20741\"`|\n|`clientId`|The client ID to authenticate as with the SEPIA STT server.|`\"any\"`|\n|`accessToken`|The access token used to authenticate with the SEPIA STT server. **On a default server installation, which is set to use a common access token, this is set to `test1234`.** If the server is set to use individual tokens instead, this should be set to the corresponding token for the clientId.|`\"test1234\"`|\n|`task`|Allows for selecting a task-specific model without knowing its exact name.|`\"\"`|\n|`model`|The name of the ASR model to use on the server. This does not need to be set if language is already set.|`\"\"`|\n|`optimizeFinalResult`|If set to true, will optimize final results by converting numbers and ordinals expressed as words into integers (i.e. one -\u003e 1, third -\u003e 3rd, etc).|`true`|\n|`engineOptions`|Allows you to set options for features that may only be available in certain engines used by the server. An example would be Vosk's speaker detection, which is not available in Coqui.|`{}`|\n\n### Example\n\nThe following is an example of how to utilize the polyfill to support speech recognition across any browser:\n\n```js\nimport { sepiaSpeechRecognitionInit, SepiaSpeechRecognitionConfig } from './sepia-speechrecognition-polyfill.min.js';\n\nconst config = new SepiaSpeechRecognitionConfig();\n// Set configuration options specific to your SEPIA STT server\n\nconst SpeechRecognition = window.webkitSpeechRecognition || sepiaSpeechRecognitionInit(config);\nconst speechTest = new SpeechRecognition();\nspeechTest.onerror = (e) =\u003e console.log(e.error, e.message);\nspeechTest.onresult = (e) =\u003e console.log(`${e.results[0][0].transcript} ${e.results[0].isFinal}`);\nspeechTest.interimResults = true;\nspeechTest.continuous = true;\n\nconst micButton = document.getElementById(\"micButton\");\nlet toggled = false;\nmicButton.addEventListener('pointerup', () =\u003e {\n  if (!toggled) speechTest.start()\n  else speechTest.stop();\n  toggled = !toggled;\n});\n```\n\n## Unimplemented Features\n\n- The error codes `aborted`, `audio-capture`, and `bad-grammar` are not currently used by the polyfill.\n- Grammars are not currently implemented. See [this issue](https://github.com/msub2/sepia-speechrecognition-polyfill/issues/1) for a more in-depth discussion about implementing grammars.\n\n## Behavior Differences\n\n- From my testing, this polyfill actually behaves closer to spec than Chromium's implementation in regards to how `continuous` works.\n  - On Chrome, once the first final transcript is received, recognition seems to stop, and it only returns that last transcript no matter how much you say after that. The polyfill continuously returns finalized transcripts after a set period of no speech from the user.\n- The polyfill will attempt to infer the `lang` property based on the document language or `navigator.language`. Chromium does not.\n- Chromium censors curse words/swears. The polyfill does not :)\n\n## Acknowledgements\n\nVery special thanks goes out to [Florian Quirin](https://github.com/fquirin), maintainer of [SEPIA](https://github.com/SEPIA-Framework), for creating so much of the code that this polyfill relies on.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsub2%2Fsepia-speechrecognition-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsub2%2Fsepia-speechrecognition-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsub2%2Fsepia-speechrecognition-polyfill/lists"}