{"id":24161612,"url":"https://github.com/zcaceres/capio-api","last_synced_at":"2025-08-21T00:05:09.624Z","repository":{"id":87954580,"uuid":"95691582","full_name":"zcaceres/capio-api","owner":"zcaceres","description":":microphone: Easy Audio Transcription with Capio's Speech Recognition API","archived":false,"fork":false,"pushed_at":"2017-07-07T20:12:32.000Z","size":12550,"stargazers_count":3,"open_issues_count":7,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T02:51:13.727Z","etag":null,"topics":[],"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/zcaceres.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,"zenodo":null}},"created_at":"2017-06-28T16:51:11.000Z","updated_at":"2021-08-26T17:48:39.000Z","dependencies_parsed_at":"2023-05-22T02:45:07.011Z","dependency_job_id":null,"html_url":"https://github.com/zcaceres/capio-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zcaceres/capio-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcaceres%2Fcapio-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcaceres%2Fcapio-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcaceres%2Fcapio-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcaceres%2Fcapio-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zcaceres","download_url":"https://codeload.github.com/zcaceres/capio-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcaceres%2Fcapio-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271405572,"owners_count":24753798,"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-20T02:00:09.606Z","response_time":69,"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-01-12T17:17:30.238Z","updated_at":"2025-08-21T00:05:09.606Z","avatar_url":"https://github.com/zcaceres.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Stories in Ready](https://badge.waffle.io/zcaceres/capio-api.png?label=ready\u0026title=Ready)](https://waffle.io/zcaceres/capio-api?utm_source=badge)\n# Easy Transcription with Capio's Speech Recognition API\n\u003e Zach Caceres\n\n## Overview\nThis program provides a simple RESTful API (/transcript) to create and retrieve transcripts of audio files using the Capio.ai Speech Recognition API.\n\n* Audio files are sent to the server and forwarded to Capio\n* Server polls Capio until transcription is complete\n* Transcripts are saved in a PostgreSQL database by transcriptId (assigned by Capio)\n* You can access any transcription by transcript-id after it's processed by Capio\n\n### Stack\nBuilt with *NodeJS* and:\n- *Express* for routing\n- *PostgreSQL/pg/Sequelize* for DB/persisting transcriptions\n- *Supertest/Mocha* for testing\n\n## How To Use\nYou'll need [PostgreSQL](https://www.postgresql.org/download/) installed. On OSX, I prefer the minimalist [Postgresapp](https://postgresapp.com/) and [Postico](https://eggerapps.at/postico/)\n\n1. By default, this program looks for a database named 'capio-api'. You can either make an empty one with this name, or change the database name in CONFIG.js. \n2. ```npm install``` dependencies using package.json\n3. Add your PostGres username and password to the CONFIG.js file\n4. Add your API key to the CONFIG.js file\n5. You may need to set FORCE_DB_SYNC to true during your first run\n6. ```npm start``` will launch your server\n\n**To Create a Transcription:**\n\nSend a POST request with an audio file to: http://localhost:8080/transcript\n\nYour POST request needs the following parameters:\n```js\n{\n  media: 'your_file_here',\n  apiKey: 'your_api_key_here',\n  async: true\n}\n```\nA successful POST request will populate your database with JSON transcripts stored by transcriptIds. Here's how that looks in Postico:\n![postico](./meta/postico.png)\n\n**To Retrieve a Transcription:**\n\nSend a GET request to /transcript with the transcription ID: http://localhost:8080/transcript/:transcriptionId\n\n## Easy Testing with [Postman](https://www.getpostman.com/apps)\nThis repo includes four sample audio files and an incorrect file for easy testing. They are labeled according to the length of the audio.\n\n* medium.wav\n* short.mp3\n* long.mp3\n* invalid-mimetype.jpg\n\nFor easy testing, consider using Postman like the following example:\n![postman](./meta/Postman-request.png)\n\nYou should receive a response like this:\n![postman](./meta/Postman-response.png)\n\n## Unit Tests\nTo run tests, ```npm test``` from the directory that contains package.json\n\n## Linter/Style\nWritten with ESLint and a no semi-colon extension of [this config](https://www.npmjs.com/package/eslint-config-fullstack)\n\n## Challenges and Opportunities for Improvement\nI've left *TODOs* throughout the codebase to show things that I could have done better and opportunities to improve this code in  the future.\n\nHere are a few:\n\n*Testing:*\n- Finish the test suite with enough time to do complete coverage. Specifically, I must test Sequelize models more closely and check responses in detail from Capio and PostGres not just their status code.\n- Testing revealed a design flaw in how I handled the response from Capio. I should have sent the user some indication that the request was still processing. Then, after the transcript came back, I could send them the text.\n- capioManager and validation needs testing\n\n*Validation and Cleanup:*\n- Validation uses a hacky approach to ensure only audio files are sent to the server. Should check encoding rather than content header.\n- No file cleanup is done after audio upload. This is not scalable at all. I should have used Node streams for processing.\n\n*Error Handling:*\n- There are many edge cases and potential areas for error that are not yet well-handled\n- In the event of an error or timeout while pinging Capio api, this program should retry the transcription several times before moving on\n- Users could send binary files using x-www-form-urlencoded. These are not handled at all but could make it easier for developers to ping the API without encoding as multipart form data\n\n*Other:*\n- Transcript seems to occasionally cut off first or last words in each 'result' block. I'm not yet sure why.\n- The 'long.mp3' media sample has never successfully returned a transcript. I dont yet know why.\n- Refactoring to promisify response logic after POST request. Currently, the Express response is passed down through too many files and functions. This makes the flow hard to understand.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzcaceres%2Fcapio-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzcaceres%2Fcapio-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzcaceres%2Fcapio-api/lists"}