Dev.to WebDev 🛠 Dev 👁 0 📖 6 min read

Integrating AI Voice with Notion and Productivity Tools

Why Add Voice to Your Notion‑Powered Workflow? If you’ve spent any time automating your notes, tasks, or knowledge base in Notion, you already know how powerful a text‑first workflow can be. But imagine being able to t

Why Add Voice to Your Notion‑Powered Workflow?

If you’ve spent any time automating your notes, tasks, or knowledge base in Notion, you already know how powerful a text‑first workflow can be. But imagine being able to talk to your workspace—ask it to read a project brief aloud, dictate a meeting summary, or generate a quick audio reminder for a to‑do list. Voice AI bridges the gap between your brain and your digital notebook, letting you stay hands‑free while you stay productive.

In this article we’ll walk through:

  1. Picking a high‑quality text‑to‑speech (TTS) service (hint: we’ll use ElevenLabs).
  2. Setting up a simple API wrapper in Python.
  3. Hooking the generated audio into Notion via its public API.
  4. A quick Node.js example for those who prefer JavaScript.

By the end you’ll have a reusable pattern for turning any piece of Notion content into natural‑sounding speech, and you’ll be ready to experiment with voice cloning for a truly personalized assistant.

Choosing a TTS Engine – Enter ElevenLabs

When it comes to realistic, low‑latency speech synthesis, ElevenLabs stands out. Their neural models produce expressive voices that sound far closer to a human speaker than the classic rule‑based engines. Plus, they expose a clean REST API that works great with both Python’s requests library and Node’s fetch/axios.

Pro tip: Sign up through the affiliate link below to get a generous free credit that’s perfect for prototyping:

ElevenLabs

Prerequisites

  • A Notion integration token with at least read permission on the pages you want to voice‑over. Create one in the Notion developer portal and share the relevant pages with the integration.
  • An ElevenLabs API key (available from your dashboard after sign‑up).
  • Python 3.8+ or Node 18+ installed locally.
  • pip install requests (Python) or npm i node-fetch (Node) if you’re using the JavaScript example.

1. Fetching Notion Content

Below is a minimal Python function that pulls the plain text from a Notion page using the official API. It extracts the title and any paragraph blocks, concatenating them into a single string ready for synthesis.

import requests

NOTION_TOKEN = "secret_notion_token"
PAGE_ID = "your-page-id"

def get_page_text(page_id: str) -> str:
    url = f"https://api.notion.com/v1/blocks/{page_id}/children"
    headers = {
        "Authorization": f"Bearer {NOTION_TOKEN}",
        "Notion-Version": "2022-06-28"
    }
    response = requests.get(url, headers=headers)
    response.raise_for_status()
    blocks = response.json()["results"]

    text_parts = []
    for block in blocks:
        if block["type"] == "paragraph":
            paragraph = block["paragraph"]["rich_text"]
            text_parts.append("".join(rt["plain_text"] for rt in paragraph))
        elif block["type"] == "heading_1":
            heading = block["heading_1"]["rich_text"]
            text_parts.append("\n".join(rt["plain_text"] for rt in heading))

    return "\n".join(text_parts)

page_text = get_page_text(PAGE_ID)
print(page_text[:200])  # sanity check

Tip: If you need more block types (bulleted lists, toggles, etc.) just extend the if ladder. The Notion API returns a consistent schema for every block type.

2. Sending Text to ElevenLabs

ElevenLabs expects a POST to /v1/text-to-speech/{voice_id} with JSON payload containing the text. You can also specify model_id for speed‑optimized or high‑quality models. Here’s the Python wrapper:

ELEVENLABS_API_KEY = "your-elevenlabs-api-key"
VOICE_ID = "21m00Tcm4TlvDq8ikWAM"   # default "Rachel" voice; replace with your cloned voice ID

def synthesize_speech(text: str, output_path: str = "output.mp3"):
    url = f"https://api.elevenlabs.io/v1/text-to-speech/{VOICE_ID}"
    headers = {
        "xi-api-key": ELEVENLABS_API_KEY,
        "Content-Type": "application/json"
    }
    payload = {
        "text": text,
        "model_id": "eleven_monolingual_v1",
        "voice_settings": {
            "stability": 0.75,
            "similarity_boost": 0.85
        }
    }

    response = requests.post(url, json=payload, headers=headers)
    response.raise_for_status()

    with open(output_path, "wb") as f:
        f.write(response.content)
    print(f"Audio saved to {output_path}")

# Example usage
synthesize_speech(page_text, "meeting_summary.mp3")

That’s it—your Notion page is now an MP3 file that you can play back on any device.

3. Adding the Audio Back to Notion (Optional)

If you want the audio file to live inside Notion, you can upload it to an external storage (e.g., AWS S3, Cloudinary) and then add a file block to the original page.

def add_audio_block(page_id: str, audio_url: str):
    url = f"https://api.notion.com/v1/blocks/{page_id}/children"
    headers = {
        "Authorization": f"Bearer {NOTION_TOKEN}",
        "Notion-Version": "2022-06-28",
        "Content-Type": "application/json"
    }
    payload = {
        "children": [
            {
                "type": "file",
                "file": {
                    "type": "external",
                    "external": {"url": audio_url}
                }
            }
        ]
    }
    resp = requests.patch(url, json=payload, headers=headers)
    resp.raise_for_status()
    print("Audio block added to Notion")

You’d first upload meeting_summary.mp3 somewhere public, grab the URL, then call add_audio_block(PAGE_ID, public_url).

4. JavaScript (Node) Alternative

For developers who live in the JavaScript ecosystem, the same flow can be expressed with node-fetch. Below is a concise script that pulls a page, calls ElevenLabs, and writes the MP3 to disk.

// npm i node-fetch@2
const fetch = require('node-fetch');
const fs = require('fs');

const NOTION_TOKEN = 'secret_notion_token';
const PAGE_ID = 'your-page-id';
const ELEVENLABS_KEY = 'your-elevenlabs-api-key';
const VOICE_ID = '21m00Tcm4TlvDq8ikWAM';

async function getPageText() {
  const res = await fetch(`https://api.notion.com/v1/blocks/${PAGE_ID}/children`, {
    headers: {
      Authorization: `Bearer ${NOTION_TOKEN}`,
      'Notion-Version': '2022-06-28',
    },
  });
  const data = await res.json();
  return data.results
    .filter(b => b.type === 'paragraph')
    .map(b => b.paragraph.rich_text.map(rt => rt.plain_text).join(''))
    .join('\n');
}

async function synthesize(text) {
  const res = await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${VOICE_ID}`, {
    method: 'POST',
    headers: {
      'xi-api-key': ELEVENLABS_KEY,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      text,
      model_id: 'eleven_monolingual_v1',
      voice_settings: { stability: 0.75, similarity_boost: 0.85 },
    }),
  });

  if (!res.ok) throw new Error(`ElevenLabs error: ${await res.text()}`);
  const buffer = await res.buffer();
  fs.writeFileSync('page_audio.mp3', buffer);
  console.log('Saved page_audio.mp3');
}

(async () => {
  const text = await getPageText();
  await synthesize(text);
})();

Run it with node notion-voice.js and you’ll have an page_audio.mp3 ready for playback.

5. Going Further – Voice Cloning

ElevenLabs also lets you clone your own voice (or a team member’s) by uploading a few minutes of clean audio. Once you have a voice_id, replace the default VOICE_ID in the snippets above and the output will sound like the source speaker. This is perfect for:

  • Personalized daily stand‑up briefings.
  • Branded audio notes that match your company’s tone.
  • Accessibility features for visually‑impaired teammates.

The cloning workflow is documented in ElevenLabs’ API reference; the call is essentially a POST /v1/voices/add with multipart/form‑data.

6. Practical Tips & Gotchas

Issue Fix
Audio is cut off Ensure the text length is below ElevenLabs’ 5 000‑character limit per request. Split long pages into chunks and concatenate the resulting MP3s.
Notion rate limits Cache page content locally if you’re generating audio for the same page repeatedly.
Voice latency Use the eleven_monolingual_v1 model for faster responses; the higher‑quality eleven_multilingual_v2 is slower but richer.
File size MP3s from ElevenLabs are ~30 KB per minute of speech. For longer recordings, consider streaming directly to a player rather than storing the whole file.

Wrap‑Up

Integrating AI voice into Notion doesn’t have to be a heavyweight project. With just a few lines of code you can:

  1. Pull any page’s text via the Notion API.
  2. Convert it to lifelike speech using ElevenLabs.
  3. (Optionally) push the audio back into your workspace for quick playback.

The pattern is language‑agnostic, so feel free to adapt the snippets to Go, Ruby, or even a serverless function that runs on a schedule.

Ready to give your Notion pages a voice? Grab your ElevenLabs API key through the affiliate link below, spin up the script, and start listening to your knowledge base.

Try ElevenLabs today and hear your notes come alive: https://try.elevenlabs.io/kr07zfuqn1bp

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.