
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@jackdbd/eleventy-plugin-text-to-speech
Advanced tools
Eleventy plugin that uses text-to-speech to generate audio assets for your website, then injects audio players in your HTML
Eleventy plugin that uses text-to-speech to generate audio assets for your website, then injects audio players in your HTML.
To synthesize text into speech you can use:
To host the generated audio assets you can use:
:warning: The Cloud Text-to-Speech API has a limit of 5000 characters.
See also:
npm install --save-dev @jackdbd/eleventy-plugin-text-to-speech
Before you can begin using the Text-to-Speech API, you must enable it. You can enable the API with the following command:
gcloud services enable texttospeech.googleapis.com
This plugin uses the official Node.js client library for the Text-to-Speech API. In order to authenticate to any Google Cloud API you will need some kind of credentials. At the moment this plugin supports only authentication via a service account JSON key.
First, create a service account that can use the Text-to-Speech API. You can also reuse an existing service account if you want. This service account should have the necessary IAM permissions to create/delete objects in a Cloud Storage bucket. You can grant the service account the Storage Object Admin predefined IAM role.
gcloud iam service-accounts create sa-text-to-speech-user \
--display-name "Text-to-Speech user SA"
Second, download the JSON key of this service account and store it somewhere safe. Do not track this file in git.
Create a Cloud Storage bucket in your desired location. Enable uniform bucket-level access and use the nearline
storage class.
gsutil mb \
-p $GCP_PROJECT_ID \
-l $CLOUD_STORAGE_LOCATION \
-c nearline \
-b on \
gs://bkt-eleventy-plugin-text-to-speech-audio-files
If you want, you can check that uniform bucket-level access is enabled using this command:
gsutil uniformbucketlevelaccess get \
gs://bkt-eleventy-plugin-text-to-speech-audio-files
Make the bucket's objects publicly available for read access (otherwise people will not be able to listen/download the audio files):
gsutil iam ch allUsers:objectViewer \
gs://bkt-eleventy-plugin-text-to-speech-audio-files
Let's say that you are hosting your Eleventy website on Cloudflare Pages. Your current deployment is at the URL indicated by the environment variable CF_PAGES_URL
.
If you want to self-host the audio assets that this plugin generates and use all default options, you can register the plugin with this code:
import { textToSpeechPlugin } from '@jackdbd/eleventy-plugin-text-to-speech'
export default function (eleventyConfig) {
// some eleventy configuration...
eleventyConfig.addPlugin(textToSpeechPlugin, {
// TODO: add config with process.env.CF_PAGES_URL here
})
// some more eleventy configuration...
}
If you want to host the audio assets on a Cloud Storage bucket and configure the rules for the audio matches, you could register the plugin using something like this:
import { textToSpeechPlugin } from '@jackdbd/eleventy-plugin-text-to-speech'
export default function (eleventyConfig) {
// some eleventy configuration...
eleventyConfig.addPlugin(textToSpeechPlugin, {
// TODO: add config with Cloud Storage bucket here
})
// some more eleventy configuration...
}
If you want to host the generated audio assets on multiple hosts, register this plugin multiple times. Here are a few examples:
Have a look at the Eleventy configuration of the demo-site in this monorepo.
Key | Default | Description |
---|---|---|
collectionName | audio-items | Name of the 11ty collection defined by this plugin |
rules | Rules that determine which texts to convert into speech (1 to ∞ elements) | |
transformName | inject-audio-tags-into-html | Name of the 11ty transform defined by this plugin |
Key | Default | Description |
---|---|---|
audioInnerHTML | Function that returns some HTML from the list of hrefs where the generated audio assets are hosted. | |
cssSelectors | [] | CSS selectors to find matches in a HTML document |
hosting | Client that provides hosting capabilities | |
regex | /^((?!404).)*.html$/ | RegExp to find matches in the output path |
synthesis | Client that provides Text-to-Speech capabilities | |
xPathExpressions | [] | XPath expressions to find matches in a HTML document |
This plugin uses the debug library for logging. You can control what's logged using the DEBUG
environment variable. For example, if you set your environment variables in a .envrc
file, you could do:
# print all logging statements
export DEBUG=11ty-plugin:TTS:*
# print just the logging statements from the dom module
export DEBUG=11ty-plugin:TTS:dom
# print all logging statements, except the ones from the dom module
export DEBUG=11ty-plugin:TTS:*,-11ty-plugin:TTS:dom
I had the idea of this plugin while reading the code of the homonym eleventy-plugin-text-to-speech by Larry Hudson. Larry's plugin uses the Microsoft Azure Speech SDK.
FAQs
Eleventy plugin that uses text-to-speech to generate audio assets for your website, then injects audio players in your HTML.
The npm package @jackdbd/eleventy-plugin-text-to-speech receives a total of 0 weekly downloads. As such, @jackdbd/eleventy-plugin-text-to-speech popularity was classified as not popular.
We found that @jackdbd/eleventy-plugin-text-to-speech demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.