Skip to content

Instantly share code, notes, and snippets.

@itslukej
Created December 18, 2025 10:40
Show Gist options
  • Select an option

  • Save itslukej/d2ccb02d441ddd574edf567a0eafe4b3 to your computer and use it in GitHub Desktop.

Select an option

Save itslukej/d2ccb02d441ddd574edf567a0eafe4b3 to your computer and use it in GitHub Desktop.
Ah, nigga, don't hate me 'cause I'm beautiful, nigga. Maybe if you got rid of that old yee-yee ass haircut you got you'd get some bitches on your dick. Oh, better yet, maybe Tanisha'll call your dog-ass if she ever stop fuckin' with that brain surgeon or lawyer she fucking with. Nigga...
#!/usr/bin/env bun
import { PollyClient } from "@aws-sdk/client-polly";
import { fromCognitoIdentityPool } from "@aws-sdk/credential-provider-cognito-identity";
import { CognitoIdentityClient } from "@aws-sdk/client-cognito-identity";
import { getSynthesizeSpeechUrl } from "@aws-sdk/polly-request-presigner";
const REGION = "us-west-2";
const IDENTITY_POOL_ID = "us-west-2:42521701-f77a-4555-8b1c-e160ad0210da";
const polly = new PollyClient({
region: REGION,
credentials: fromCognitoIdentityPool({
client: new CognitoIdentityClient({ region: REGION }),
identityPoolId: IDENTITY_POOL_ID,
}),
});
async function say(text: string, voiceId: string, outFile: string) {
const params = {
OutputFormat: "mp3",
SampleRate: "16000",
TextType: "text",
Text: text,
VoiceId: voiceId,
Engine: "standard",
};
// Generate presigned URL like ipa-reader.com does
const url = await getSynthesizeSpeechUrl({
client: polly,
params: params as any,
});
// Fetch the audio from the presigned URL
const response = await fetch(url as string, {
"headers": {
"accept": "*/*",
"accept-language": "en-GB,en-US;q=0.9,en;q=0.8",
"priority": "i",
"range": "bytes=0-",
"sec-ch-ua": "\"Google Chrome\";v=\"143\", \"Chromium\";v=\"143\", \"Not A(Brand\";v=\"24\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"macOS\"",
"sec-fetch-dest": "audio",
"sec-fetch-mode": "no-cors",
"sec-fetch-site": "cross-site",
"sec-fetch-storage-access": "active",
"Referer": "https://ipa-reader.com/"
},
"body": null,
"method": "GET"
});
if (!response.ok) {
throw new Error(`Failed to fetch audio: ${response.status} ${response.statusText}`);
}
const audioData = await response.arrayBuffer();
await Bun.write(outFile, new Uint8Array(audioData));
console.log(`Saved -> ${outFile}`);
}
const [mode, ...args] = process.argv.slice(2);
if (mode === "say") {
const text = args[0];
const voice = args[1] ?? "Joanna";
const out = args[2] ?? "tts.mp3";
if (!text) {
console.error('Usage: bun index.ts say "hello world" Joey out.mp3');
process.exit(1);
}
await say(text, voice, out);
} else {
console.error(
"Usage:\n" +
' bun index.ts say "hello world" Joey out.mp3'
);
process.exit(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment