A Node.js skill/library for AI agents to search PDFs/images, download and validate files, convert PDFs to Markdown, and generate speech locally with Supertone Supertonic ONNX models.
npx skills add gafapa/skill-toolsOr clone manually:
git clone https://github.com/gafapa/skill-tools.git
cd skill-tools
npm installsearchPDFs(query, limit): PDF search via Bing HTML scraping (no API key)searchImages(query, limit): Google Images viagoogle-img-scrap(no API key)downloadFile(url, outputDir, expectedType): streaming download + MIME validation + extension fixconvertPdfToMarkdown(pdfPath, options): PDF to structured Markdown (unpdf/ PDF.js)generateSpeech(text, outputPath, options): local TTS with ONNX Runtime + automatic model download
import {
searchPDFs,
searchImages,
downloadFile,
convertPdfToMarkdown,
generateSpeech,
} from './index.js';
import fs from 'node:fs/promises';const pdfs = await searchPDFs('machine learning tutorial', 5);
const images = await searchImages('space wallpaper', 3);downloadFile() expects the destination directory to exist:
await fs.mkdir('./downloads', { recursive: true });
const savedPath = await downloadFile(pdfs[0].url, './downloads', 'pdf');const markdown = await convertPdfToMarkdown(savedPath, {
detectHeadings: true,
joinParagraphs: true,
normaliseBullets: true,
fixBrokenUrls: true,
includeMetadata: false,
});On first run, the library downloads the required Supertonic 2 assets from Hugging Face into:
./models/supertonic-2/onnx/(multiple ONNX files + JSON metadata)./models/supertonic-2/voice_styles/(selected voice style JSON)
await generateSpeech('Hello world!', './audio.wav', {
voice: 'F1', // F1-F5 or M1-M5, or a local .json voice-style path
lang: 'en', // en | ko | es | pt | fr
speed: 1.0,
steps: 20,
});await fs.mkdir('./downloads', { recursive: true });
const [first] = await searchPDFs('javascript guide', 3);
const pdfPath = await downloadFile(first.url, './downloads', 'pdf');
const markdown = await convertPdfToMarkdown(pdfPath, { includeMetadata: true });
await fs.writeFile(pdfPath.replace('.pdf', '.md'), markdown);
await generateSpeech(markdown.slice(0, 400), './summary.wav', {
voice: 'F1',
lang: 'en',
steps: 5,
});Fast unit tests (default):
npm testIntegration tests are separated:
npm run test:integration:search # set RUN_NETWORK_TESTS=1 to actually run
npm run test:integration:tts # set RUN_TTS_INTEGRATION=1 to actually runPowerShell examples:
$env:RUN_NETWORK_TESTS='1'; npm run test:integration:search
$env:RUN_TTS_INTEGRATION='1'; npm run test:integration:tts- Search functions return
[]on recoverable failures. - Download / PDF conversion / TTS return
nullon recoverable failures. - TTS inference runs locally after the one-time Supertonic 2 asset download.
MIT