
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
@speechify/api-sdk
Advanced tools
⚠️ DEPRECATED: This repository and its SDK are now deprecated. Please use the new official @speechify/api package instead.
The new package provides a more streamlined experience with better TypeScript support and improved API integration. For a quick start guide and migration instructions, please refer to our changelog.
This is the official Node.js SDK for the Speechify API.
Read the SDK full reference here.
Read the REST API documentation here.
npm install @speechify/api-sdk
import { Speechify } from "@speechify/api-sdk";
const speechify = new Speechify({
apiKey: "YOUR_API_KEY",
});
const text = "Hello, world!";
const response = await speechify.audioGenerate({
input: text,
voiceId: "george",
audioFormat: "mp3",
});
const audio = response.audioData;
someStorage.saveFile("audio.mp3", audio);
import { Speechify } from "@speechify/api-sdk";
const speechify = new Speechify({
apiKey: "YOUR_API_KEY",
});
webServer.post("/speechify-token", async (req, res) => {
const user = req.user;
if (!user) {
res.status(401).send("Unauthorized");
return;
}
const tokenResponse = await speechify.accessTokenIssue("audio:all");
res.json(tokenResponse);
});
import { Speechify } from "@speechify/api-sdk";
const speechify = new Speechify();
authSystem.on("login", async () => {
const res = await fetch("/speechify-token", {
method: "POST",
});
const tokenResponse = await res.json();
speechify.setAccessToken(tokenResponse.accessToken);
});
generateButton.addEventListener("click", async () => {
const text = "Hello, world!";
const response = await speechify.audioGenerate({
input: text,
voiceId: "george",
audioFormat: "mp3",
});
const audio = response.audioData;
const audioElement = new Audio();
audioElement.src = URL.createObjectURL(
new Blob([audio], { type: "audio/mpeg" }),
);
audioElement.play();
});
You can use the provided SpeechifyAccessTokenManager
class to have the access token fully managed, including the auto-refresh before it expires.
import { Speechify, SpeechifyAccessTokenManager } from "@speechify/api-sdk";
const speechify = new Speechify();
const getToken = async () => {
const res = await fetch("/speechify-token", {
method: "POST",
});
return res.json();
};
const tokenManager = new SpeechifyAccessTokenManager(speechify, getToken, {
isAuthenticated: authSystem.isAuthenticated,
});
authSystem.on("login", () => {
tokenManager.setIsAuthenticated(true);
});
authSystem.on("logout", () => {
tokenManager.setIsAuthenticated(false);
});
With this setup in place, you can use the speechify
client without worrying about the access token management.
FAQs
Official Speechify AI API SDK
The npm package @speechify/api-sdk receives a total of 1,754 weekly downloads. As such, @speechify/api-sdk popularity was classified as popular.
We found that @speechify/api-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers 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
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.