{"id":30248319,"url":"https://github.com/atomiechen/funasr-client-ts","last_synced_at":"2026-01-20T16:53:40.140Z","repository":{"id":308762362,"uuid":"1032398114","full_name":"atomiechen/funasr-client-ts","owner":"atomiechen","description":"Really easy-to-use Typescript client for FunASR runtime server.","archived":false,"fork":false,"pushed_at":"2025-08-07T17:51:14.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-07T19:32:03.292Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/funasr-client","language":"TypeScript","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/atomiechen.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-05T08:49:33.000Z","updated_at":"2025-08-07T17:51:18.000Z","dependencies_parsed_at":"2025-08-07T19:32:08.024Z","dependency_job_id":"ff2ce6a4-df2e-4ec1-9347-9cea78c05f7c","html_url":"https://github.com/atomiechen/funasr-client-ts","commit_stats":null,"previous_names":["atomiechen/funasr-client-ts"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/atomiechen/funasr-client-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomiechen%2Ffunasr-client-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomiechen%2Ffunasr-client-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomiechen%2Ffunasr-client-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomiechen%2Ffunasr-client-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomiechen","download_url":"https://codeload.github.com/atomiechen/funasr-client-ts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomiechen%2Ffunasr-client-ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270539580,"owners_count":24603189,"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","status":"online","status_checked_at":"2025-08-15T02:00:12.559Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-08-15T07:39:43.924Z","updated_at":"2026-01-20T16:53:40.135Z","avatar_url":"https://github.com/atomiechen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FunASR-Client (TS/JS)\n\n[![NPM](https://img.shields.io/npm/v/funasr-client?logo=npm\u0026label=funasr-client)](https://www.npmjs.com/package/funasr-client)\n[![GitHub](https://img.shields.io/badge/github-gray?logo=github)](https://github.com/atomiechen/funasr-client-ts)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/atomiechen/funasr-client-ts)\n\n\nReally easy-to-use Typescript/JavaScript client for [FunASR][1] runtime service.\n\nTo deploy your own FunASR service, follow the [FunASR runtime guide][2], or use the improved [startup scripts][3].\nFor other client implementations in different languages, see [below](#different-client-implementations).\n\n\n## Features\n\n- 🔤 Auto decoding of messages with real timestamps (`FunASRMessageDecoded`)\n- 🎙️ Real-time audio recognition from a microphone (`MicASR`)\n\n\n## Installation\n\n### NPM (Browser/Node.js)\n\n```sh\nnpm install funasr-client\n```\n\n```ts\nimport { FunASRClient } from 'funasr-client';\n\n// import this if you want real-time microphone ASR\nimport { MicASR } from 'funasr-client/mic';\n```\n\n### ESM CDN (Browser)\n\nImport the ESM module directly from a CDN:\n\n```html\n\u003cscript type=\"importmap\"\u003e\n  {\n    \"imports\": {\n      \"funasr-client\": \"https://esm.sh/funasr-client@latest\",\n      \"funasr-client/mic\": \"https://esm.sh/funasr-client@latest/mic\"\n    }\n  }\n\u003c/script\u003e\n\u003cscript type=\"module\"\u003e\n  import { FunASRClient } from 'funasr-client';\n  import { MicASR } from 'funasr-client/mic';\n\u003c/script\u003e\n```\n\n### IIFE CDN (Browser)\n\nAll features are also available in the IIFE bundle `dist/iife/index.global.js`, which can be directly included in web pages.\nTools are exposed in the global `funasr` object.\n\nImport the IIFE module directly from a CDN:\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/funasr-client@latest/dist/iife/index.global.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  // funasr object is available globally\n  console.log(funasr.FunASRClient);\n  console.log(funasr.MicASR);\n\u003c/script\u003e\n```\n\n## Usage\n\n### FunASRClient\n\nThe *only* required option is the URL of the FunASR server.\n\n```ts\nconst client = new FunASRClient({\n  // (Required) URL of the FunASR server\n  url: \"ws://localhost:8000/ws\",\n\n  // Whether to decode the message before passing it to the `onMessage` callback.\n  // Disable auto-decoding if you want to handle original message objects\n  decode: true,\n\n  // callback to handle incoming messages (FunASRMessageDecoded or FunASRMessage)\n  onMessage: (msg) =\u003e {\n    console.log(\"Received message:\", msg);\n  },\n\n  // callback to handle state changes\n  onStateChange: (state) =\u003e { \n    console.log(\"State changed:\", state);\n  },\n\n  // the start timestamp (ms) for the audio recording\n  startTime: Date.now(),\n\n  // initial configuration for the first message\n  config: {\n    mode: \"2pass\",\n    wav_name: \"test.wav\",\n    wav_format: \"pcm\",\n    chunk_size: [5, 10, 5],\n    audio_fs: 16000,\n    hotwords: { \"hello\": 20, \"world\": 30 },\n    itn: true,\n    svs_lang: \"auto\",\n    svs_itn: true,\n  }\n});\n\n// (async) Connect to the server and send the initial configuration.\nclient.connect();\n\n// Set the start timestamp for the audio recording.\nclient.setStartTime(timestamp);\n\n// Send a message to the server.\nclient.send(data);\n\n// (async) Send the final message to the server, wait for the final result and then close the connection. An optional timeout can be provided.\nclient.close();\n```\n\n\n### MicASR\n\nThe `MicASR` class provides a convenient way to perform real-time audio recognition from a microphone.\nIt takes the same options as `FunASRClient` except for the `decode` option, which is always `true` for `MicASR`.\n\n```ts\nconst mic_asr = new MicASR({\n  url: 'ws://your-funasr-server-url'\n});\n\n// (async) Start the real-time ASR process by connecting to the FunASR server and starting the audio recorder.\nmic_asr.start()\n\n// (async) Stop the real-time ASR process by stopping the audio recorder and closing the FunASR client connection.\nmic_asr.stop()\n```\n\n\n## Different Client Implementations\n\n- [Python](https://github.com/atomiechen/FunASR-Client)\n- [TS/JS](https://github.com/atomiechen/funasr-client-ts)\n\n\n## References\n\n- FunASR webSocket protocol ([English](https://github.com/modelscope/FunASR/blob/main/runtime/docs/websocket_protocol.md) | [简体中文](https://github.com/modelscope/FunASR/blob/main/runtime/docs/websocket_protocol_zh.md))\n- FunASR runtime service ([English](https://github.com/modelscope/FunASR/blob/main/runtime/readme.md) | [简体中文](https://github.com/modelscope/FunASR/blob/main/runtime/readme_cn.md))\n- [Handy startup scripts][3] for FunASR runtime service\n\n\n[1]: https://github.com/modelscope/FunASR\n[2]: https://github.com/modelscope/FunASR/blob/main/runtime/readme.md\n[3]: https://gist.github.com/atomiechen/2deaf80dba21b4434ab21d6bf656fbca\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomiechen%2Ffunasr-client-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomiechen%2Ffunasr-client-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomiechen%2Ffunasr-client-ts/lists"}