{"id":16344652,"url":"https://github.com/malob/article-to-audio-cloud-function","last_synced_at":"2025-10-05T22:59:20.755Z","repository":{"id":78636593,"uuid":"133290875","full_name":"malob/article-to-audio-cloud-function","owner":"malob","description":"Google Cloud Function that takes a url, converts the article at that url to audio using Cloud Text-To-Speech, then stores it in a Cloud Storage bucket.","archived":false,"fork":false,"pushed_at":"2018-05-16T15:47:54.000Z","size":32,"stargazers_count":23,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T10:52:00.380Z","etag":null,"topics":["cloud-function","google-cloud","nodejs","podcast","podcast-generator","text-to-speech"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/malob.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-05-14T01:45:41.000Z","updated_at":"2025-03-21T11:46:16.000Z","dependencies_parsed_at":"2023-04-22T01:48:25.837Z","dependency_job_id":null,"html_url":"https://github.com/malob/article-to-audio-cloud-function","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/malob/article-to-audio-cloud-function","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malob%2Farticle-to-audio-cloud-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malob%2Farticle-to-audio-cloud-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malob%2Farticle-to-audio-cloud-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malob%2Farticle-to-audio-cloud-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/malob","download_url":"https://codeload.github.com/malob/article-to-audio-cloud-function/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malob%2Farticle-to-audio-cloud-function/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278532353,"owners_count":26002346,"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-10-05T02:00:06.059Z","response_time":54,"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":["cloud-function","google-cloud","nodejs","podcast","podcast-generator","text-to-speech"],"created_at":"2024-10-11T00:28:52.731Z","updated_at":"2025-10-05T22:59:20.691Z","avatar_url":"https://github.com/malob.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Article to Audio Google Cloud Function\n\nThis is a [Google Cloud Function](https://cloud.google.com/functions/) I hacked together that takes a url to an article on the web, and generates an audio file of it using Google's new [Cloud Text-To-Speech](https://cloud.google.com/text-to-speech/) API which has been updated with access to DeepMind's [WaveNet](https://deepmind.com/blog/wavenet-generative-model-raw-audio/) voices.\n\nI created it as part of a project to generate a personal podcast of articles I want to consume. To get the full thing working see my [other repository](https://github.com/malob/generate-podcast-rss-cloud-function) with the Cloud Function that generates the Podcast RSS.\n\n## Sketch of how it works\n  * The function accepts a POST request with json in the body.\n    * E.g. `{\"url\": \"http://example.com/somearticle\"}`\n  * It then uses the free [Mercury Web Parser](https://mercury.postlight.com/web-parser/) API to get the body of the article and some metadata.\n  * Since the body is returned as HTML it then converts it to plain text. I also add some of the metadata at the top of the article, since I wanted this in the audio.\n  * Then it slits up the body into chunks of no larger then 5,000 characters, since that's the limit on what the TTS API can handle per request.\n  * From there is then sends each chunk of text to Google's TTS API which returns the audio encoded as MP3, and writes them to a temporary location.\n  * Since having multiple files for parts of the article is annoying, it then uses FFMPEG to concatenate the audio chunks into one file.\n  * Finally, it stores the audio file as and object in a Google Cloud Storage bucket, along with some of the metadata.\n\n## Configuration details\nTo get this working you need a Google Cloud Project with a Cloud Storage bucket setup, and the Cloud Text-To-Speech API enabled.\n\nYou'll then need to create a new Cloud Function (see configuration details below), and replace the `undefined` global constants in the code, `gcpProjectID`, `gcpBucketName`, and `mercuryApiKey`, with the appropriate values.\n\n### Cloud Function configuration\n  * Trigger type: HTTP trigger\n  * Memory allocated: 256 MB\n  * Timeout: 240s\n    * I had to extend this from default of 60s.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalob%2Farticle-to-audio-cloud-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmalob%2Farticle-to-audio-cloud-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalob%2Farticle-to-audio-cloud-function/lists"}