Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else:
- api = voices[voice]["api"]
- voice_id = voices[voice]["id"]
- if api == "kappa":
- r = requests.get("https://api.streamelements.com/kappa/v2/speech?voice=%s&text=%s" % (voice_id, msg))
- if r.status_code == 200:
- frame_rate_index = utils.clamp(frame_rate_index, 0, len(g.rates) - 1)
- frame_rate = g.rates[frame_rate_index]
- sound = AudioSegment.from_file(io.BytesIO(r.content), format="mp3")
- sound = sound.set_frame_rate(44100)
- sound.frame_rate = frame_rate
- sound = utils.match_target_amplitude(sound, -15)
- elif api == "tiktok":
- while True:
- new_msg = msg[0 : 200]
- msg = msg[200:]
- if len(new_msg) <= 0:
- break
- headers = {
- 'User-Agent': 'com.zhiliaoapp.musically/2022600030 (Linux; U; Android 7.1.2; es_ES; SM-G988N; Build/NRD90M;tt-ok/3.12.13.1)',
- 'Cookie': f'sessionid={secret.tiktok_session_id}'
- }
- url = f"https://api22-normal-c-useast1a.tiktokv.com/media/api/text/speech/invoke/?text_speaker={voice_id}&req_text={new_msg}&speaker_map_type=0&aid=1233"
- r = requests.post(url, headers = headers)
- j = r.json()
- if j["status_code"] == 0:
- sound_data = base64.b64decode(j["data"]["v_str"])
- frame_rate_index = utils.clamp(frame_rate_index, 0, len(g.rates) - 1)
- frame_rate = g.rates[frame_rate_index]
- temp_sound = AudioSegment.from_file(io.BytesIO(sound_data), format="mp3")
- temp_sound = temp_sound.set_frame_rate(44100)
- temp_sound.frame_rate = frame_rate
- temp_sound = utils.match_target_amplitude(temp_sound, -15)
- if not sound:
- sound = temp_sound
- else:
- sound += temp_sound
- else:
- utils.send_chat_message("@%s TikTok's API didn't like that message for some reason, scammed Jebaited" % user)
Add Comment
Please, Sign In to add comment