Tkap1

Untitled

Jan 26th, 2023
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.67 KB | None | 0 0
  1. else:
  2.     api = voices[voice]["api"]
  3.     voice_id = voices[voice]["id"]
  4.     if api == "kappa":
  5.         r = requests.get("https://api.streamelements.com/kappa/v2/speech?voice=%s&text=%s" % (voice_id, msg))
  6.         if r.status_code == 200:
  7.             frame_rate_index = utils.clamp(frame_rate_index, 0, len(g.rates) - 1)
  8.             frame_rate = g.rates[frame_rate_index]
  9.             sound = AudioSegment.from_file(io.BytesIO(r.content), format="mp3")
  10.             sound = sound.set_frame_rate(44100)
  11.             sound.frame_rate = frame_rate
  12.             sound = utils.match_target_amplitude(sound, -15)
  13.  
  14. elif api == "tiktok":
  15.     while True:
  16.         new_msg = msg[0 : 200]
  17.         msg = msg[200:]
  18.         if len(new_msg) <= 0:
  19.             break
  20.         headers = {
  21.             'User-Agent': 'com.zhiliaoapp.musically/2022600030 (Linux; U; Android 7.1.2; es_ES; SM-G988N; Build/NRD90M;tt-ok/3.12.13.1)',
  22.             'Cookie': f'sessionid={secret.tiktok_session_id}'
  23.         }
  24.         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"
  25.         r = requests.post(url, headers = headers)
  26.         j = r.json()
  27.         if j["status_code"] == 0:
  28.             sound_data = base64.b64decode(j["data"]["v_str"])
  29.             frame_rate_index = utils.clamp(frame_rate_index, 0, len(g.rates) - 1)
  30.             frame_rate = g.rates[frame_rate_index]
  31.             temp_sound = AudioSegment.from_file(io.BytesIO(sound_data), format="mp3")
  32.             temp_sound = temp_sound.set_frame_rate(44100)
  33.             temp_sound.frame_rate = frame_rate
  34.             temp_sound = utils.match_target_amplitude(temp_sound, -15)
  35.             if not sound:
  36.                 sound = temp_sound
  37.             else:
  38.                 sound += temp_sound
  39.         else:
  40.             utils.send_chat_message("@%s TikTok's API didn't like that message for some reason, scammed Jebaited" % user)
  41.  
Add Comment
Please, Sign In to add comment