DEV Community

Dilek Karasoy for Picovoice

Posted on

Podcast Transcription Software with Express.js

We've had several tutorials with Leopard Speech-to-Text. Leopard offers fully on-device audio transcription. Today we'll build podcast transcription software using Leopard Speech-to-Text downloading new items from the RSS feed directly.

1. Backend Set up with Express.js
The backend setup will be straightforward. A single endpoint for transcription!

const express = require('express');

const app = express();
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));

app.get('/', function (req, res) {
});'/rss-transcribe', async (req, res) => {
  console.log("RSS feed = " + req.body.rss)

module.exports = app;
Enter fullscreen mode Exit fullscreen mode

The test page is designed to allows entering a podcast RSS feed URL manually which will be sent to the /rss-transcribe backend for processing.
2. Parsing the RSS Feed
For parsing, use this great RSS parser from Robert Brennan. It takes the URL and provides a JSON representation of the feed:
const Parser = require('rss-parser');'/rss-transcribe', async (req, res) => {
  console.log("Parsing RSS feed " + req.body.rss)
  let parser = new Parser();
  let feed = await parser.parseURL(req.body.rss)
  console.log("Parse complete.")
Enter fullscreen mode Exit fullscreen mode

3. Fetching the Audio
After having the JSON of the RSS, you can find where the podcast audio link was located in the object:

const fs = require('fs');
const path = require('path');
const axios = require('axios');'/rss-transcribe', async (req, res) => {

  // .. parse feed

  const podcastAudioUrl = feed.items[0].enclosure.url
  console.log("Fetching file from " + podcastAudioUrl)
  let dlResponse = await axios.get(podcastAudioUrl, { responseType: "arraybuffer" })
  console.log("File obtained.")

  console.log("Writing data to local file...")
  const fileName = `${Math.random().toString(36).substr(2, 5)}.mp3`
  console.log("File write complete")

Enter fullscreen mode Exit fullscreen mode

4. Transcribing the Podcast
Once you have the audio file, it's time to feed it into Leopard Speech-to-Text. Grab your AccessKey from the Picovoice Console for free if you haven't done yet. Replace the placeholder with your AccessKey and run the code below:

const { Leopard } = require('@picovoice/leopard-node')'/rss-transcribe', async (req, res) => {
  // .. parse feed

  // .. get audio file

  console.log("Transcribing audio...")
  const leo = new Leopard("${YOUR ACCESS KEY HERE}")
  const transcript = leo.processFile(fileName)
  console.log("Transcription complete")

Enter fullscreen mode Exit fullscreen mode

Now, you can have the transcription being sent in the response.
What's next?
You can take it from here and enrich your solutions. Options are:

  1. You can write to a text file in the browser for download
  2. Add automation with a solution like Zapier
  3. Build front end with a search bar and a new endpoint for queries to make transcriptions searchable.

Original Medium Article
Tutorial Source Code
Picovoice Leopard
Picovoice Console

Top comments (0)