npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shofipwk/tiktok-tts

v1.1.16

Published

Use TikTok TTS from node.js

Downloads

4

Readme

tiktok-tts

This package provides a simple way to generate text-to-speech audio files from TikTok's text-to-speech (TTS) API in Node.js.

example workflow downloads

Installation

npm i tiktok-tts

Usage

Basic example

const { config, createAudioFromText } = require('tiktok-tts')

config('Your TikTok sessionid here');
createAudioFromText('Text to be spoken goes here');

Custom filename example

const { config, createAudioFromText } = require('tiktok-tts')

config('Your TikTok sessionid here');
createAudioFromText('Text to be spoken goes here', 'myAudio');

Generated audio file will be saved as myAudio.mp3

Custom path example

const { config, createAudioFromText } = require('tiktok-tts')

config('Your TikTok sessionid here');
createAudioFromText('Text to be spoken goes here', './myDirectory/myAudio');

Generated audio file will be saved as myAudio.mp3 inside the myDirectory directory.

⚠️ Please keep in mind that myDirectory needs to be an existing directory.

Custom voice example

const { config, createAudioFromText } = require('tiktok-tts')

config('Your TikTok sessionid here');
createAudioFromText('Text to be spoken goes here', 'myAudio', 'en_us_stormtrooper');

Using await with the createAudioFromText() function

const { config, createAudioFromText } = require('tiktok-tts')

config('Your TikTok sessionid here');

async function yourFunction(){
    await createAudioFromText('Text that will be spoken');
    console.log("Audio file generated!");
}

yourFunction();

Get TikTok Session id 🍪

  • Install Cookie Editor extension for your browser.
  • Log in to TikTok Web
  • While on TikTok web, open the extension and look for sessionid
  • Copy the sessionid value. (It should be an alphanumeric value)

Available functions

config(tiktokSessionId, customBaseUrl)

| Parameter | Description | Default |type | | ------------- |:------------- | ------------------ |-----| | tiktokSessionId| Your TikTok sessionid | null | String| | customBaseUrl| Custom TikTok API url optional | - | String|

  • By default https://api16-normal-c-useast1a.tiktokv.com/media/api/text/speech/invoke will be used if no customBaseUrl is specified.
  • https://api16-normal-c-useast1a.tiktokv.com/media/api/text/speech/invoke

  • https://api16-core-c-useast1a.tiktokv.com/media/api/text/speech/invoke

  • https://api16-normal-useast5.us.tiktokv.com/media/api/text/speech/invoke

  • https://api16-core.tiktokv.com/media/api/text/speech/invoke

  • https://api16-core-useast5.us.tiktokv.com/media/api/text/speech/invoke

  • https://api19-core-c-useast1a.tiktokv.com/media/api/text/speech/invoke

  • https://api-core.tiktokv.com/media/api/text/speech/invoke

  • https://api-normal.tiktokv.com/media/api/text/speech/invoke

  • https://api19-normal-c-useast1a.tiktokv.com/media/api/text/speech/invoke

  • https://api16-core-c-alisg.tiktokv.com/media/api/text/speech/invoke

  • https://api16-normal-c-alisg.tiktokv.com/media/api/text/speech/invoke

  • https://api22-core-c-alisg.tiktokv.com/media/api/text/speech/invoke

  • https://api16-normal-c-useast2a.tiktokv.com/media/api/text/speech/invoke

createAudioFromText(text, fileName, speaker)

| Parameter | Description | Default | type | | ------------- |:-------------| -----| -----| | text | Text to be converted to audio | null | String| | fileName | filename/path for the generated audio file optional | audio | String| | speaker | TikTok speaker code optional | en_us_001 | String|

Speaker Codes

The following speaker codes are supported:

| Language | Speaker | Speaker Code | |------------- |-------------------------|---------------------------------| | English | Game On | en_male_jomboy | | | Jessie | en_us_002 | | | Warm | es_mx_002 | | | Wacky | en_male_funny | | | Scream | en_us_ghostface | | | Empathetic | en_female_samc | | | Serious | en_male_cody | | | Beauty Guru | en_female_makeup | | | Bestie | en_female_richgirl | | | Trickster | en_male_grinch | | | Joey | en_us_006 | | | Story Teller | en_male_narration | | | Mr. GoodGuy | en_male_deadpool | | | Narrator | en_uk_001 | | | Male English UK | en_uk_003 | | | Metro | en_au_001 | | | Alfred | en_male_jarvis | | | ashmagic | en_male_ashmagic | | | olantekkers | en_male_olantekkers | | | Lord Cringe | en_male_ukneighbor | | | Mr. Meticulous | en_male_ukbutler | | | Debutante | en_female_shenna | | | Varsity | en_female_pansino | | | Marty | en_male_trevor | | | Pop Lullaby | en_female_f08_twinkle | | | Classic Electric | en_male_m03_classical | | | Bae | en_female_betty | | | Cupid | en_male_cupid | | | Granny | en_female_grandma | | | Cozy | en_male_m2_xhxs_m03_christmas | | | Author | en_male_santa_narration | | | Caroler | en_male_sing_deep_jingle | | | Santa | en_male_santa_effect | | | NYE 2023 | en_female_ht_f08_newyear | | | Magician | en_male_wizard | | | Opera | en_female_ht_f08_halloween | | | Euphoric | en_female_ht_f08_glorious | | | Hypetrain | en_male_sing_funny_it_goes_up | | | Melodrama | en_female_ht_f08_wonderful_world| | | Quirky Time | en_male_m2_xhxs_m03_silly | | | Peaceful | en_female_emotional | | | Toon Beat | en_male_m03_sunshine_soon | | | Open Mic | en_female_f08_warmy_breeze | | | Jingle | en_male_m03_lobby | | | Thanksgiving | en_male_sing_funny_thanksgiving | | | Cottagecore | en_female_f08_salut_damour | | | Professor | en_us_007 | | | Scientist | en_us_009 | | | Confidence | en_us_010 | | | Smooth | en_au_002 | | Disney | Ghost Face | en_us_ghostface | | | Chewbacca | en_us_chewbacca | | | C3PO | en_us_c3po | | | Stitch | en_us_stitch | | | Stormtrooper | en_us_stormtrooper | | | Rocket | en_us_rocket | | | Madame Leota | en_female_madam_leota | | | Ghost Host | en_male_ghosthost | | | Pirate | en_male_pirate | | French | French - Male 1 | fr_001 | | | French - Male 2 | fr_002 | | Spanish | Spanish (Spain) - Male | es_002 | | | Spanish MX - Male | es_mx_002 | | Portuguese | Portuguese BR - Female 1 | br_001 | | | Portuguese BR - Female 2 | br_003 | | | Portuguese BR - Female 3 | br_004 | | | Portuguese BR - Male | br_005 | | | Ivete Sangalo | bp_female_ivete | | | Ludmilla | bp_female_ludmilla | | | Lhays Macedo | pt_female_lhays | | | Laizza | pt_female_laizza | | | Galvão Bueno | pt_male_bueno | | German | German - Female | de_001 | | | German - Male | de_002 | | Indonesian | Indonesian - Female | id_001 | | Japanese | Japanese - Female 1 | jp_001 | | | Japanese - Female 2 | jp_003 | | | Japanese - Female 3 | jp_005 | | | Japanese - Male | jp_006 | | | りーさ | jp_female_fujicochan | | | 世羅鈴 | jp_female_hasegawariona | | | Morio’s Kitchen | jp_male_keiichinakano | | | 夏絵ココ | jp_female_oomaeaika | | | 低音ボイス | jp_male_yujinchigusa | | | 四郎 | jp_female_shirou | | | 玉川寿紀 | jp_male_tamawakazuki | | | 庄司果織 | jp_female_kaorishoji | | | 八木沙季 | jp_female_yagishaki | | | ヒカキン | jp_male_hikakin | | | 丸山礼 | jp_female_rei | | | 修一朗 | jp_male_shuichiro | | | マツダ家の日常 | jp_male_matsudake | | | まちこりーた | jp_female_machikoriiita | | | モジャオ | jp_male_matsuo | | | モリスケ | jp_male_osada | | Korean | Korean - Male 1 | kr_002 | | | Korean - Female | kr_003 | | | Korean - Male 2 | kr_004 | | Vietnamese | Female | BV074_streaming | | | Male | BV075_streaming | | Other | Alto | en_female_f08_salut_damour | | | Tenor | en_male_m03_lobby | | | Sunshine Soon | en_male_m03_sunshine_soon | | | Warmy Breeze | en_female_f08_warmy_breeze | | | Glorious | en_female_ht_f08_glorious | | | It Goes Up | en_male_sing_funny_it_goes_up | | | Chipmunk | en_male_m2_xhxs_m03_silly | | | Dramatic | en_female_ht_f08_wonderful_world |