Git Product home page Git Product logo

article-to-audio-cloud-function's Introduction

Article to Audio Google Cloud Function

This is a Google Cloud Function 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 API which has been updated with access to DeepMind's WaveNet voices.

I 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 with the Cloud Function that generates the Podcast RSS.

Sketch of how it works

  • The function accepts a POST request with json in the body.
    • E.g. {"url": "http://example.com/somearticle"}
  • It then uses the free Mercury Web Parser API to get the body of the article and some metadata.
  • 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.
  • 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.
  • 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.
  • Since having multiple files for parts of the article is annoying, it then uses FFMPEG to concatenate the audio chunks into one file.
  • Finally, it stores the audio file as and object in a Google Cloud Storage bucket, along with some of the metadata.

Configuration details

To get this working you need a Google Cloud Project with a Cloud Storage bucket setup, and the Cloud Text-To-Speech API enabled.

You'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.

Cloud Function configuration

  • Trigger type: HTTP trigger
  • Memory allocated: 256 MB
  • Timeout: 240s
    • I had to extend this from default of 60s.

article-to-audio-cloud-function's People

Contributors

malob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

article-to-audio-cloud-function's Issues

License missing

Sweet project! Could you kindly consider adding a license? The same goes for the feed generation repo. Might have some use for some of this stuff :) I'm sure this is meant to be open source and all but I'd appreciate the extra clarity. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.