jkap

CEO of posting

butch jewish dyke
part of @staff, cohost user #1
married to @kadybat

This user can say it
osu stats


🐘 mastodon
xoxo.zone/@jkap
πŸ–ΌοΈ icon credit
twitter.com/osmoru
🐦 twitter
not anymore lol
🎬 letterboxd
letterboxd.com/yrfriendjkap/

tef
@tef

i saw the command line thing to generate the tiktok voice but i did not have the assortment of command line tools available, so i rewrote it in python3

import urllib.request
import urllib.parse
import json
import base64
import sys

def tiktok(text):
    url = "https://api16-normal-useast5.us.tiktokv.com/media/api/text/speech/invoke/"
    data = { 'text_speaker': 'en_us_002', 'req_text': text, }
    full_url = '{}?{}'.format(url, urllib.parse.urlencode(data))

    req = urllib.request.Request(url=full_url, method="POST")
    with urllib.request.urlopen(req) as fh:
        data = fh.read().decode('utf-8')
        blob = json.loads(data)

    raw_voice = base64.b64decode(blob['data']['v_str'])
    return raw_voice

text = sys.stdin.readlines()
mp3 = tiktok("\n".join(text))

with open(sys.argv[1], 'wb') as fh:
    print(text)
    fh.write(mp3)

you run it with pbpaste | python tiktok.py filename_for_output.mp3


You must log in to comment.

in reply to @tef's post: