{"id":19778902,"url":"https://github.com/dialogflow/asr-server","last_synced_at":"2025-04-30T21:31:18.207Z","repository":{"id":82729597,"uuid":"54421884","full_name":"dialogflow/asr-server","owner":"dialogflow","description":"FastCGI support for Kaldi ASR","archived":false,"fork":false,"pushed_at":"2019-04-05T16:14:23.000Z","size":84,"stargazers_count":184,"open_issues_count":19,"forks_count":85,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-04-06T04:41:47.195Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dialogflow.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":"2016-03-21T20:53:17.000Z","updated_at":"2025-04-03T13:48:00.000Z","dependencies_parsed_at":"2023-04-30T06:05:37.116Z","dependency_job_id":null,"html_url":"https://github.com/dialogflow/asr-server","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/dialogflow%2Fasr-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fasr-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fasr-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fasr-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dialogflow","download_url":"https://codeload.github.com/dialogflow/asr-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251785406,"owners_count":21643475,"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":[],"created_at":"2024-11-12T05:32:35.247Z","updated_at":"2025-04-30T21:31:18.197Z","avatar_url":"https://github.com/dialogflow.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"About\n======\nFastCGI support for [Kaldi](http://kaldi-asr.org/doc/). It allows Kaldi based speech recognition to be used though Apache or Nginx (or any other that support FastCGI) HTTP servers. It also contains simple HTML-based client, that allows testing Kaldi speech recognitionfrom a web page.\n\nLicence\n-------\nApache 2.0\n\nInstallation guide\n==================\n\nSummary\n-------\n\nThis guide will help you to download and build your own simple ASR \nweb-service based on Kaldi ASR code.\n\nPreparing prerequisites\n-----------------------\n\n### Creating a working dir\n\nLet's create a directory where all data will be downloaded and built.\n\n\tmkdir ~/apiai\n\tcd ~/apiai\n\nYou are free to choose any other name and path you wish to, but will \nhave to keep in mind that your name differs from the name given in the \nguide.\n\nDue to server code is based on Kaldi almost all prerequisites matches \nto Kaldi ones. Besides that a FastCGI library is required to communicate \nwith HTTP server.\n\n### Getting Kaldi\n\nAs a first step you have to clone Kaldi source tree available at\n\u003chttps://github.com/kaldi-asr/kaldi\u003e:\n\n\tgit clone https://github.com/kaldi-asr/kaldi\n\nThis command will clone source tree to `kaldi` directory. \nTo configure and build Kaldi please refer to `kaldi/INSTALL` file.\nFor detailed information please look for Kaldi official instruction:\n\u003chttp://kaldi-asr.org/doc/install.html\u003e\n\n### Installing libraries\n\nThere are some extra libraries required. You may install them using \nsystem packet manager.\n\nIn openSuSE you may run:\n\n\t$ sudo zypper install FastCGI-devel\n\nIt you have Debian or Ubuntu:\n\t\n\t$ sudo apt-get install libfcgi-dev\n\nGetting the code\n--------------\n\nReturn to your working directory where you put Kaldi sources\n\n\t$ cd ~/apiai\n\nand then clone server source code\n\n\t$ git clone https://github.com/api-ai/asr-server asr-server\n\nIt is recommended to checkout code to the same directory where \nkaldi-apiai is located to allow `configure` tool to detect Kaldi \nlocation automatically.\n\nBuilding the app\n--------------\n\n\t$ cd asr-server\n\nBefore running a make process you have to configure build scripts \nby running a special utility:\n\n\t$ ./configure\n\nIt will check that all required libraries installed to your system and \nalso will look for Kaldi libraries in `../kaldi` folder. If you \nhave Kaldi installed somewhere else you may explicitly pass the \npath via --kaldi-root option:\n\n\t$ ./configure --kaldi-root=\u003cpath_to_kaldi\u003e\n\nIf configuration process has finished successfully you may begin \nthe building process by running make script:\n\n\t$ make\n\nGetting a recognition model\n------------------------\n\nWhen application build complete you need to download language specific \ndata. \n\nReturn to your working directory where you put Kaldi sources\n\n\t$ cd ~/apiai\n\nBuilded ASR application uses a Kaldi nnet3 models, which you can get\nby training a neural network with your personal data set or use a \npretrained network provided by us. Currently it is only English model available\nat \u003chttps://github.com/api-ai/api-ai-english-asr-model/releases/download/1.0/api.ai-kaldi-asr-model.zip\u003e. \n\n\t$ wget https://github.com/api-ai/api-ai-english-asr-model/releases/download/1.0/api.ai-kaldi-asr-model.zip\n\nUnzip the archive to `asr-server` directory.\n\n\t$ unzip api.ai-kaldi-asr-model.zip\n\nRunning the app\n--------------\n\nSet the model directory as a working dir:\n\n\t$ cd api.ai-kaldi-asr-model\n\nThere are several ways available to run application. The first one is \nto run it as a standalone app listening on socket defined with \n`--fcgi-socket` option:\n\n\t$ ../asr-server/fcgi-nnet3-decoder --fcgi-socket=:8000\n\nThis command runs application listening on any IP address and port 8000. \nYou are also free to define a path Unix socket, or explicit IP \naddress (in a A.B.C.D:PORT form).\n\nAs an alternative way you may use special spawn-fcgi utility:\n\n\t$ spawn-fcgi -n -p 8000 -- ../asr-server/fcgi-nnet3-decoder\n\nConfiguring HTTP service\n---------------------\n\nYou may use any web-server which have FastCGI support: Apache, Nginx, Lighttpd etc. \n\n### Installing Apache2\n\nopenSuSE:\n\n\t$ sudo zypper in apache2\n\t\nDebian and Ubuntu:\n\n\t$ sudo apt-get install apache2\n\t\n### Configuring Apache2\n\nEnable FastCGI proxy module with `a2enmod`:\n\t\n\t$ sudo a2enmod proxy_fcgi\n\t\nThen you have to add to Apache2 configuration file following line:\n\n\tProxyPass \"/asr\" \"fcgi://localhost:8000/\"\n\t\nIf your Apache configured to include all .conf files from /etc/apache2/conf.d folder you may \ncreate separate asr_proxy.conf file with following content:\n\n\tProxyPass \"/asr\" \"fcgi://localhost:8000/\"\n\tAlias /asr-html/ \"/home/username/apiai/asr-server/asr-html/\"\n\t\u003cDirectory \"/home/username/apiai/asr-server/asr-html\"\u003e\n\t\tOptions Indexes MultiViews\n\t\tAllowOverride None\n\t\tRequire all granted\n\t\u003c/Directory\u003e\n\t\nNow restart Apache:\n\t\n\t$ sudo /etc/init.d/apache2 restart\n\n### Installing Nginx\n\nYou can download latest sources from official website \u003chttp://nginx.org/\u003e and build Nginx \nwith yourself or use your system package manager.\n\nopenSuSE:\n\n\t$ sudo zypper install nginx\n\nDebian and Ubuntu:\n\n\t$ sudo apt-get install nginx\n\n### Configuring Nginx\n\nOpen nginx.conf and write down the following code:\n\n\thttp {\n\t\tserver {\n\t\t\tlocation /asr {\n\t\t\t\tfastcgi_pass 127.0.0.1:8000;\n\t\t\t\t# Disabling this option invokes immediate sending replies to client\n\t\t\t\tfastcgi_buffering off;\n\t\t\t\t# Disabling this option invokes immediate decoding incoming audio data\n\t\t\t\tfastcgi_request_buffering off;\n\t\t\t\tinclude      fastcgi_params;\n\t\t\t}\n\n\t\t\tlocation /asr-html {\n\t\t\t\troot /home/username/apiai/asr-server/;\n\t\t\t\tindex index.html;\n\t\t\t}\n\t\t}\n\t}\n\nThis will setup Nginx to pass all requests coming to url /asr directly \nto ASR service listening 8000 port via FastCGI gate. For detailed \ninformation please please refer to nginx documentation \n(e.g. \u003chttps://www.nginx.com/resources/wiki/start/topics/examples/fastcgiexample/\u003e)\n\nSpeech Recognition\n----------------\n\nServer accepts raw mono 16-bits 16 KHz PCM data. You can convert your audio \nusing any popular encoding utilities, for instance, you can use ffmpeg:\n\n\t$ ffmpeg -i audio.wav -f s16le -ar 16000 -ac 1 audio.raw\n\n### Recognition using web browser\n\nThere is a simple JS implementation that allows you to recognize speech using system mic.\nOpen in your browser:\n\n\thttp://localhost/asr-html/\n\nand follow the instructions on the page.\n\n### Recognition from command line using curl\n\nNow, let’s recognize `audio.raw` by calling web-service with `curl` \nutility:\n\n\t$ curl -H \"Content-Type: application/octet-stream\" --data-binary @audio.raw http://localhost/asr\n\nOn successfull recognition the command will return something like this:\n\n\t{\n\t\t\"status\":\"ok\",\n\t\t\"data\":[{\"confidence\":0.900359,\"text\":\"HELLO WORLD\"}]\n\t}\n\nOn error the return value will be like this:\n\n\t{\"status\":\"error\",\"data\":[{\"text\":\"Failed to decode\"}]}\n\n### Recognition request parameters\n\nThere are several parameters to tune up recognition process. All parameters are expected to be passed via query string as web-form fields enumeration (e.g. `?name1=value1\u0026name2=value2`).\n\n\u003ctable border=\"1\"\u003e\n\t\u003ctr\u003e\n\t\t\u003cth\u003eParameter\u003c/th\u003e\n\t\t\u003cth\u003eDescription\u003c/th\u003e\n\t\t\u003cth\u003eAcceptable values\u003c/th\u003e\n\t\t\u003cth\u003eDefault value\u003c/th\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003enbest\u003c/td\u003e\n\t\t\u003ctd\u003eSet the number of possible returned values\n\u003cpre\u003e\u003ccode\u003e{\n\t\"status\":\"ok\",\n\t\"data\":[\n\t\t{\"confidence\":0.900359,\"text\":\"HELLO WORLD\"},\n\t\t{\"confidence\":0.89012,\"text\":\"HELLO WORD\"}\n\t]\n}\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\t\t\u003ctd\u003e1-10\u003c/td\u003e\n\t\t\u003ctd\u003e1\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eendofspeech\u003c/td\u003e\n\t\t\u003ctd\u003eEnable or disable end-of-speech points during recognition. If endpoint\n\t\t\tdetected all then current result have returned and the rest data would \n\t\t\tbe skipped. Also in case of interrupted recognition 2 fields would be added\n\t\t\tto response: \"interrupted\" with value \"endofspeech\", and \"time\" with time point\n\t\t\tshowing the number of milliseconds have been processed.\n\n\u003cpre\u003e\u003ccode\u003e{\n\t\"status\":\"ok\",\n\t\"data\":[{\"confidence\":0.900359,\"text\":\"HELLO WORLD\"}],\n\t\"interrupted\":\"endofspeech\",\n\t\"time\":3800\n}\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\t\t\u003ctd\u003etrue or false\u003c/td\u003e\n\t\t\u003ctd\u003etrue\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003eintermediate\u003c/td\u003e\n\t\t\u003ctd\u003eSet time interval in milliseconds between intermediate results while \n\t\t\trecognition being in progress.\n\n\t\t\tThe result returned as an simple sequence of JSON documents.\n\t\t\tEach intermediate document have \"status\" field set to \"intermediate\",\n\t\t\tlast one will have \"status\" set to \"ok\".\n\u003cpre\u003e\u003ccode\u003e\n{\"status\":\"intermediate\",\"data\":[\n\t{\"confidence\":0.908981,\"text\":\"HELLO\"}\n]}\n{\"status\":\"intermediate\",\"data\":[\n\t{\"confidence\":0.903025,\"text\":\"HELLO WORLD\"}\n]}\n{\"status\":\"ok\",\"data\":[\n\t{\"confidence\":0.903025,\"text\":\"HELLO WORLD\"}\n]}\n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\t\t\u003ctd\u003e \u003e500\u003c/td\u003e\n\t\t\u003ctd\u003e0\u003c/td\u003e\n\t\u003c/tr\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003emultipart\u003c/td\u003e\n\t\t\u003ctd\u003eIf enabled the result would be returned as an \u003ca href=\"https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html\"\u003e\n\t\t\tHTTP multipart response\u003c/a\u003e with \"content-type\"\n\t\t\tset to \"multipart/x-mixed-replace\" and each response part\n\t\t\thas \"Content-Disposition\" header value equal to \"form-data\".\n\t\t\tIntermediate parts named as \"partial\" and a final part is named as \"result\".\n\u003cpre\u003e\u003ccode\u003e\n--ResponseBoundary\nContent-Disposition: form-data; name=\"partial\"\nContent-type: application/json\n\n{\"status\":\"intermediate\",\"data\":[\n\t{\"confidence\":0.908981,\"text\":\"HELLO\"}\n]}\n\n--ResponseBoundary\nContent-Disposition: form-data; name=\"partial\"\nContent-type: application/json\n\n{\"status\":\"intermediate\",\"data\":[\n\t{\"confidence\":0.903025,\"text\":\"HELLO WORLD\"}\n]}\n\n--ResponseBoundary\nContent-Disposition: form-data; name=\"result\"\nContent-type: application/json\n\n{\"status\":\"ok\",\"data\":[\n\t{\"confidence\":0.903025,\"text\":\"HELLO WORLD\"}\n]}\n\n--ResponseBoundary--\n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\t\t\u003ctd\u003etrue or false\u003c/td\u003e\n\t\t\u003ctd\u003efalse\u003c/td\u003e\n\t\u003c/tr\u003e\n\u003c/table\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdialogflow%2Fasr-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdialogflow%2Fasr-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdialogflow%2Fasr-server/lists"}