{"id":15141919,"url":"https://github.com/eddyverbruggen/nativescript-speech-recognition","last_synced_at":"2025-10-23T18:30:58.401Z","repository":{"id":46294817,"uuid":"81744206","full_name":"EddyVerbruggen/nativescript-speech-recognition","owner":"EddyVerbruggen","description":":speech_balloon: Speech to text, using the awesome engines readily available on the device.","archived":false,"fork":false,"pushed_at":"2021-11-01T12:42:58.000Z","size":2272,"stargazers_count":91,"open_issues_count":16,"forks_count":23,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-30T20:29:57.994Z","etag":null,"topics":["nativescript","nativescript-plugin","siri","speech-recognition","speech-to-text","voice-recognition"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EddyVerbruggen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-12T17:40:59.000Z","updated_at":"2024-11-30T19:32:57.000Z","dependencies_parsed_at":"2022-09-16T03:40:27.185Z","dependency_job_id":null,"html_url":"https://github.com/EddyVerbruggen/nativescript-speech-recognition","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-speech-recognition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-speech-recognition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-speech-recognition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EddyVerbruggen%2Fnativescript-speech-recognition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EddyVerbruggen","download_url":"https://codeload.github.com/EddyVerbruggen/nativescript-speech-recognition/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237869284,"owners_count":19379295,"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":["nativescript","nativescript-plugin","siri","speech-recognition","speech-to-text","voice-recognition"],"created_at":"2024-09-26T09:20:32.694Z","updated_at":"2025-10-23T18:30:52.704Z","avatar_url":"https://github.com/EddyVerbruggen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NativeScript Speech Recognition\n\n[![Build Status][build-status]][build-url]\n[![NPM version][npm-image]][npm-url]\n[![Downloads][downloads-image]][npm-url]\n[![Twitter Follow][twitter-image]][twitter-url]\n\n[build-status]:https://travis-ci.org/EddyVerbruggen/nativescript-speech-recognition.svg?branch=master\n[build-url]:https://travis-ci.org/EddyVerbruggen/nativescript-speech-recognition\n[npm-image]:http://img.shields.io/npm/v/nativescript-speech-recognition.svg\n[npm-url]:https://npmjs.org/package/nativescript-speech-recognition\n[downloads-image]:http://img.shields.io/npm/dm/nativescript-speech-recognition.svg\n[twitter-image]:https://img.shields.io/twitter/follow/eddyverbruggen.svg?style=social\u0026label=Follow%20me\n[twitter-url]:https://twitter.com/eddyverbruggen\n\nThis is the plugin [demo](https://github.com/EddyVerbruggen/nativescript-speech-recognition/tree/master/demo) in action..\n\n| ..while recognizing Dutch 🇳🇱 | .. after recognizing American-English 🇺🇸 |\n| --- | --- |\n| \u003cimg src=\"https://github.com/EddyVerbruggen/nativescript-speech-recognition/raw/master/screenshots/ios-nl.jpg\" width=\"375px\" /\u003e | \u003cimg src=\"https://github.com/EddyVerbruggen/nativescript-speech-recognition/raw/master/screenshots/ios-en.jpg\" width=\"375px\" /\u003e |\n\n## Installation\nFrom the command prompt go to your app's root folder and execute:\n\n### NativeScript 7+:\n```bash\nns plugin add nativescript-speech-recognition\n```\n\n### NativeScript \u003c 7:\n```\ntns plugin add nativescript-speech-recognition@1.5.0\n```\n\n## Testing\nYou'll need to test this on a real device as a Simulator/Emulator doesn't have speech recognition capabilities.\n\n## API\n\n### `available`\n\nDepending on the OS version a speech engine may not be available.\n\n#### JavaScript\n```js\n// require the plugin\nvar SpeechRecognition = require(\"nativescript-speech-recognition\").SpeechRecognition;\n\n// instantiate the plugin\nvar speechRecognition = new SpeechRecognition();\n\nspeechRecognition.available().then(\n  function(available) {\n    console.log(available ? \"YES!\" : \"NO\");\n  }\n);\n```\n\n#### TypeScript\n```typescript\n// import the plugin\nimport { SpeechRecognition } from \"nativescript-speech-recognition\";\n\nclass SomeClass {\n  private speechRecognition = new SpeechRecognition();\n  \n  public checkAvailability(): void {\n    this.speechRecognition.available().then(\n      (available: boolean) =\u003e console.log(available ? \"YES!\" : \"NO\"),\n      (err: string) =\u003e console.log(err)\n    );\n  }\n}\n```\n\n### `requestPermission`\nYou can either let `startListening` handle permissions when needed, but if you want to have more control\nover when the permission popups are shown, you can use this function:\n\n```typescript\nthis.speechRecognition.requestPermission().then((granted: boolean) =\u003e {\n  console.log(\"Granted? \" + granted);\n});\n```\n\n### `startListening`\n\nOn iOS this will trigger two prompts:\n\nThe first prompt requests to allow Apple to analyze the voice input. The user will see a consent screen which you can extend with your own message by adding a fragment like this to `app/App_Resources/iOS/Info.plist`:\n\n```xml\n\u003ckey\u003eNSSpeechRecognitionUsageDescription\u003c/key\u003e\n\u003cstring\u003eMy custom recognition usage description. Overriding the default empty one in the plugin.\u003c/string\u003e\n```\n\nThe second prompt requests access to the microphone:\n\n```xml\n\u003ckey\u003eNSMicrophoneUsageDescription\u003c/key\u003e\n\u003cstring\u003eMy custom microphone usage description. Overriding the default empty one in the plugin.\u003c/string\u003e\n```\n\n#### TypeScript\n```typescript\n// import the options\nimport { SpeechRecognitionTranscription } from \"nativescript-speech-recognition\";\n\nthis.speechRecognition.startListening(\n  {\n    // optional, uses the device locale by default\n    locale: \"en-US\",\n    // set to true to get results back continuously\n    returnPartialResults: true,\n    // this callback will be invoked repeatedly during recognition\n    onResult: (transcription: SpeechRecognitionTranscription) =\u003e {\n      console.log(`User said: ${transcription.text}`);\n      console.log(`User finished?: ${transcription.finished}`);\n    },\n    onError: (error: string | number) =\u003e {\n      // because of the way iOS and Android differ, this is either:\n      // - iOS: A 'string', describing the issue. \n      // - Android: A 'number', referencing an 'ERROR_*' constant from https://developer.android.com/reference/android/speech/SpeechRecognizer.\n      //            If that code is either 6 or 7 you may want to restart listening.\n    }\n  }\n).then(\n  (started: boolean) =\u003e { console.log(`started listening`) },\n  (errorMessage: string) =\u003e { console.log(`Error: ${errorMessage}`); }\n).catch((error: string | number) =\u003e {\n  // same as the 'onError' handler, but this may not return if the error occurs after listening has successfully started (because that resolves the promise,\n  // hence the' onError' handler was created.\n});\n```\n\n##### Angular tip\nIf you're using this plugin in Angular, then note that the `onResult` callback is not part of Angular's lifecycle.\nSo either update the UI in [an `ngZone` as shown here](https://github.com/EddyVerbruggen/nativescript-pluginshowcase/blob/28f65ef98716ad7c4698071b9c394cceb2d9748f/app/speech/speech.component.ts#L154),\nor use [`ChangeDetectorRef` as shown here](https://blog.paulhalliday.io/2017/06/24/nativescript-speech-recognition/).\n\n### `stopListening`\n\n#### TypeScript\n```typescript\nthis.speechRecognition.stopListening().then(\n  () =\u003e { console.log(`stopped listening`) },\n  (errorMessage: string) =\u003e { console.log(`Stop error: ${errorMessage}`); }\n);\n```\n\n## Demo app (Angular)\nThis plugin is part of the [plugin showcase app](https://github.com/EddyVerbruggen/nativescript-pluginshowcase/tree/master/app/speech) I built using Angular.\n\n### Angular video tutorial\nRather watch a video? Check out [this tutorial on YouTube](https://www.youtube.com/watch?v=C5i_EYjfuTE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddyverbruggen%2Fnativescript-speech-recognition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feddyverbruggen%2Fnativescript-speech-recognition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddyverbruggen%2Fnativescript-speech-recognition/lists"}