Closed samuelrhis closed 1 year ago
I get the same error on TikTok as well. Switch to another TTS provider like StreamLabs Polly. TikTok never worked for me. I wish it did. Almost everyone else gets the same error. I'm hoping they'll fix it one day.
This should be called to the admin's attention. TikTok TTS does not work. Everyone who's tried gets an aid error.
i changed the tiktok_sessionid and it worked!
What do you mean you changed it? Like you logged out and logged bcak in again? Usually the session ID is static?
On Mon, Jun 12, 2023 at 8:35 AM Samuel Rhis @.***> wrote:
i changed the tiktok_sessionid and it worked!
— Reply to this email directly, view it on GitHub https://github.com/elebumm/RedditVideoMakerBot/issues/1699#issuecomment-1587358166, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ435SXY2HLC2HWP4IRT5LXK4LJDANCNFSM6AAAAAAZCQID7Q . You are receiving this because you commented.Message ID: @.***>
what worked for me was going to "my profile" and copying the sessionid from there. Idk if it changes anything, but copying it from the home page didn't work for me. So try this
what worked for me was going to "my profile" and copying the sessionid from there. Idk if it changes anything, but copying it from the home page didn't work for me. So try this
I tried that. I even tried using another TikTok account. Same issue. Same exact error you're getting.
this is because something is wrong with your sessionid, for get it u need to use the a cookie editor and copy the value of "sessionid" i was getting this error too and made this and worked
this is because something is wrong with your sessionid, for get it u need to use the a cookie editor and copy the value of "sessionid" i was getting this error too and made this and worked
I'm coping the SAME EXACT session ID from my cookies. And I grab it from the sessionid cookie in the cookie editor. There's nothing wrong with my sesison ID because it's the same session I am logged in with.
Im having the exact same issue switching to eleven labs and using that for TTS seems to have fixed it, still cant get tiktok to work
This issue is stale because it has been open 7 days with no activity. Remove stale label or comment, or this will be closed in 10 days.
Same issue for me. Bot working fine with other TTS but not tiktok.
I made a modified version of TTS/TikTok.py , here's my code. It works. I would do a Pull Request, but I have done so many modifications and I can't just do a pull request for one file. So here is my new TikTok.py file that works with TikTok TTS.
# documentation for tiktok api: https://github.com/oscie57/tiktok-voice/wiki
import base64
import random
import time
from typing import Optional, Final
import simplejson
import requests
from utils import settings
__all__ = ["TikTok", "TikTokTTSException"]
disney_voices: Final[tuple] = (
"en_us_ghostface", # Ghost Face
"en_us_chewbacca", # Chewbacca
"en_us_c3po", # C3PO
"en_us_stitch", # Stitch
"en_us_stormtrooper", # Stormtrooper
"en_us_rocket", # Rocket
"en_female_madam_leota", # Madame Leota
"en_male_ghosthost", # Ghost Host
"en_male_pirate", # pirate
)
eng_voices: Final[tuple] = (
"en_au_001", # English AU - Female
"en_au_002", # English AU - Male
"en_uk_001", # English UK - Male 1
"en_uk_003", # English UK - Male 2
"en_us_001", # English US - Female (Int. 1)
"en_us_002", # English US - Female (Int. 2)
"en_us_006", # English US - Male 1
"en_us_007", # English US - Male 2
"en_us_009", # English US - Male 3
"en_us_010", # English US - Male 4
"en_male_narration", # Narrator
"en_female_emotional", # Peaceful
"en_male_cody", # Serious
)
non_eng_voices: Final[tuple] = (
# Western European voices
"fr_001", # French - Male 1
"fr_002", # French - Male 2
"de_001", # German - Female
"de_002", # German - Male
"es_002", # Spanish - Male
"it_male_m18", # Italian - Male
# South american voices
"es_mx_002", # Spanish MX - Male
"br_001", # Portuguese BR - Female 1
"br_003", # Portuguese BR - Female 2
"br_004", # Portuguese BR - Female 3
"br_005", # Portuguese BR - Male
# asian voices
"id_001", # Indonesian - Female
"jp_001", # Japanese - Female 1
"jp_003", # Japanese - Female 2
"jp_005", # Japanese - Female 3
"jp_006", # Japanese - Male
"kr_002", # Korean - Male 1
"kr_003", # Korean - Female
"kr_004", # Korean - Male 2
)
vocals: Final[tuple] = (
"en_female_f08_salut_damour", # Alto
"en_male_m03_lobby", # Tenor
"en_male_m03_sunshine_soon", # Sunshine Soon
"en_female_f08_warmy_breeze", # Warmy Breeze
"en_female_ht_f08_glorious", # Glorious
"en_male_sing_funny_it_goes_up", # It Goes Up
"en_male_m2_xhxs_m03_silly", # Chipmunk
"en_female_ht_f08_wonderful_world", # Dramatic
)
class TikTok:
"""TikTok Text-to-Speech Wrapper"""
def __init__(self):
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={settings.config['settings']['tts']['tiktok_sessionid']}",
}
self.URI_BASE = (
"https://tiktok-tts.weilnet.workers.dev/api/generation"
)
self.max_chars = 200
self._session = requests.Session()
# set the headers to the session, so we don't have to do it for every request
self._session.headers = headers
def run(self, text: str, filepath: str, random_voice: bool = False):
if random_voice:
voice = self.random_voice()
else:
# if tiktok_voice is not set in the config file, then use a random voice
voice = settings.config["settings"]["tts"].get("tiktok_voice", None)
# get the audio from the TikTok API
data = self.get_voices(voice=voice, text=text)
# check if there was an error in the request
status_code = data["error"]
# decode data from base64 to binary
try:
raw_voices = data["data"]
except:
print(
"The TikTok TTS returned an invalid response. Please try again later, and report this bug."
)
raise TikTokTTSException(0, "Invalid response")
decoded_voices = base64.b64decode(raw_voices)
# write voices to specified filepath
with open(filepath, "wb") as out:
out.write(decoded_voices)
def get_voices(self, text: str, voice: Optional[str] = None) -> dict:
"""If voice is not passed, the API will try to use the most fitting voice"""
# sanitize text
text = text.replace("+", "plus").replace("&", "and").replace("r/", "")
# prepare url request
params = {"text": text,"voice": voice}
if voice is not None:
params["voice"] = voice
# send request
try:
response = self._session.post(self.URI_BASE, json=params)
except ConnectionError:
time.sleep(random.randrange(1, 7))
response = self._session.post(self.URI_BASE, json=params)
return response.json()
@staticmethod
def random_voice() -> str:
return random.choice(eng_voices)
class TikTokTTSException(Exception):
def __init__(self, status_code, message):
self.status_code = status_code
self.message = message
super().__init__(self.message)
def __str__(self):
return f"Code: {self.status_code}, Message: {self.message}"
This issue is stale because it has been open 7 days with no activity. Remove stale label or comment, or this will be closed in 10 days.
Issue closed due to being stale. Please reopen if issue persists in latest version.
I got this issue again, but this helped me fix it. I think it shouldn't be marked as "completed"
I made a modified version of TTS/TikTok.py , here's my code. It works. I would do a Pull Request, but I have done so many modifications and I can't just do a pull request for one file. So here is my new TikTok.py file that works with TikTok TTS.
# documentation for tiktok api: https://github.com/oscie57/tiktok-voice/wiki import base64 import random import time from typing import Optional, Final import simplejson import requests from utils import settings __all__ = ["TikTok", "TikTokTTSException"] disney_voices: Final[tuple] = ( "en_us_ghostface", # Ghost Face "en_us_chewbacca", # Chewbacca "en_us_c3po", # C3PO "en_us_stitch", # Stitch "en_us_stormtrooper", # Stormtrooper "en_us_rocket", # Rocket "en_female_madam_leota", # Madame Leota "en_male_ghosthost", # Ghost Host "en_male_pirate", # pirate ) eng_voices: Final[tuple] = ( "en_au_001", # English AU - Female "en_au_002", # English AU - Male "en_uk_001", # English UK - Male 1 "en_uk_003", # English UK - Male 2 "en_us_001", # English US - Female (Int. 1) "en_us_002", # English US - Female (Int. 2) "en_us_006", # English US - Male 1 "en_us_007", # English US - Male 2 "en_us_009", # English US - Male 3 "en_us_010", # English US - Male 4 "en_male_narration", # Narrator "en_female_emotional", # Peaceful "en_male_cody", # Serious ) non_eng_voices: Final[tuple] = ( # Western European voices "fr_001", # French - Male 1 "fr_002", # French - Male 2 "de_001", # German - Female "de_002", # German - Male "es_002", # Spanish - Male "it_male_m18", # Italian - Male # South american voices "es_mx_002", # Spanish MX - Male "br_001", # Portuguese BR - Female 1 "br_003", # Portuguese BR - Female 2 "br_004", # Portuguese BR - Female 3 "br_005", # Portuguese BR - Male # asian voices "id_001", # Indonesian - Female "jp_001", # Japanese - Female 1 "jp_003", # Japanese - Female 2 "jp_005", # Japanese - Female 3 "jp_006", # Japanese - Male "kr_002", # Korean - Male 1 "kr_003", # Korean - Female "kr_004", # Korean - Male 2 ) vocals: Final[tuple] = ( "en_female_f08_salut_damour", # Alto "en_male_m03_lobby", # Tenor "en_male_m03_sunshine_soon", # Sunshine Soon "en_female_f08_warmy_breeze", # Warmy Breeze "en_female_ht_f08_glorious", # Glorious "en_male_sing_funny_it_goes_up", # It Goes Up "en_male_m2_xhxs_m03_silly", # Chipmunk "en_female_ht_f08_wonderful_world", # Dramatic ) class TikTok: """TikTok Text-to-Speech Wrapper""" def __init__(self): 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={settings.config['settings']['tts']['tiktok_sessionid']}", } self.URI_BASE = ( "https://tiktok-tts.weilnet.workers.dev/api/generation" ) self.max_chars = 200 self._session = requests.Session() # set the headers to the session, so we don't have to do it for every request self._session.headers = headers def run(self, text: str, filepath: str, random_voice: bool = False): if random_voice: voice = self.random_voice() else: # if tiktok_voice is not set in the config file, then use a random voice voice = settings.config["settings"]["tts"].get("tiktok_voice", None) # get the audio from the TikTok API data = self.get_voices(voice=voice, text=text) # check if there was an error in the request status_code = data["error"] # decode data from base64 to binary try: raw_voices = data["data"] except: print( "The TikTok TTS returned an invalid response. Please try again later, and report this bug." ) raise TikTokTTSException(0, "Invalid response") decoded_voices = base64.b64decode(raw_voices) # write voices to specified filepath with open(filepath, "wb") as out: out.write(decoded_voices) def get_voices(self, text: str, voice: Optional[str] = None) -> dict: """If voice is not passed, the API will try to use the most fitting voice""" # sanitize text text = text.replace("+", "plus").replace("&", "and").replace("r/", "") # prepare url request params = {"text": text,"voice": voice} if voice is not None: params["voice"] = voice # send request try: response = self._session.post(self.URI_BASE, json=params) except ConnectionError: time.sleep(random.randrange(1, 7)) response = self._session.post(self.URI_BASE, json=params) return response.json() @staticmethod def random_voice() -> str: return random.choice(eng_voices) class TikTokTTSException(Exception): def __init__(self, status_code, message): self.status_code = status_code self.message = message super().__init__(self.message) def __str__(self): return f"Code: {self.status_code}, Message: {self.message}"
I got this issue again, but this helped me fix it. I think it shouldn't be marked as "completed"
I made a modified version of TTS/TikTok.py , here's my code. It works. I would do a Pull Request, but I have done so many modifications and I can't just do a pull request for one file. So here is my new TikTok.py file that works with TikTok TTS.
# documentation for tiktok api: https://github.com/oscie57/tiktok-voice/wiki import base64 import random import time from typing import Optional, Final import simplejson import requests from utils import settings __all__ = ["TikTok", "TikTokTTSException"] disney_voices: Final[tuple] = ( "en_us_ghostface", # Ghost Face "en_us_chewbacca", # Chewbacca "en_us_c3po", # C3PO "en_us_stitch", # Stitch "en_us_stormtrooper", # Stormtrooper "en_us_rocket", # Rocket "en_female_madam_leota", # Madame Leota "en_male_ghosthost", # Ghost Host "en_male_pirate", # pirate ) eng_voices: Final[tuple] = ( "en_au_001", # English AU - Female "en_au_002", # English AU - Male "en_uk_001", # English UK - Male 1 "en_uk_003", # English UK - Male 2 "en_us_001", # English US - Female (Int. 1) "en_us_002", # English US - Female (Int. 2) "en_us_006", # English US - Male 1 "en_us_007", # English US - Male 2 "en_us_009", # English US - Male 3 "en_us_010", # English US - Male 4 "en_male_narration", # Narrator "en_female_emotional", # Peaceful "en_male_cody", # Serious ) non_eng_voices: Final[tuple] = ( # Western European voices "fr_001", # French - Male 1 "fr_002", # French - Male 2 "de_001", # German - Female "de_002", # German - Male "es_002", # Spanish - Male "it_male_m18", # Italian - Male # South american voices "es_mx_002", # Spanish MX - Male "br_001", # Portuguese BR - Female 1 "br_003", # Portuguese BR - Female 2 "br_004", # Portuguese BR - Female 3 "br_005", # Portuguese BR - Male # asian voices "id_001", # Indonesian - Female "jp_001", # Japanese - Female 1 "jp_003", # Japanese - Female 2 "jp_005", # Japanese - Female 3 "jp_006", # Japanese - Male "kr_002", # Korean - Male 1 "kr_003", # Korean - Female "kr_004", # Korean - Male 2 ) vocals: Final[tuple] = ( "en_female_f08_salut_damour", # Alto "en_male_m03_lobby", # Tenor "en_male_m03_sunshine_soon", # Sunshine Soon "en_female_f08_warmy_breeze", # Warmy Breeze "en_female_ht_f08_glorious", # Glorious "en_male_sing_funny_it_goes_up", # It Goes Up "en_male_m2_xhxs_m03_silly", # Chipmunk "en_female_ht_f08_wonderful_world", # Dramatic ) class TikTok: """TikTok Text-to-Speech Wrapper""" def __init__(self): 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={settings.config['settings']['tts']['tiktok_sessionid']}", } self.URI_BASE = ( "https://tiktok-tts.weilnet.workers.dev/api/generation" ) self.max_chars = 200 self._session = requests.Session() # set the headers to the session, so we don't have to do it for every request self._session.headers = headers def run(self, text: str, filepath: str, random_voice: bool = False): if random_voice: voice = self.random_voice() else: # if tiktok_voice is not set in the config file, then use a random voice voice = settings.config["settings"]["tts"].get("tiktok_voice", None) # get the audio from the TikTok API data = self.get_voices(voice=voice, text=text) # check if there was an error in the request status_code = data["error"] # decode data from base64 to binary try: raw_voices = data["data"] except: print( "The TikTok TTS returned an invalid response. Please try again later, and report this bug." ) raise TikTokTTSException(0, "Invalid response") decoded_voices = base64.b64decode(raw_voices) # write voices to specified filepath with open(filepath, "wb") as out: out.write(decoded_voices) def get_voices(self, text: str, voice: Optional[str] = None) -> dict: """If voice is not passed, the API will try to use the most fitting voice""" # sanitize text text = text.replace("+", "plus").replace("&", "and").replace("r/", "") # prepare url request params = {"text": text,"voice": voice} if voice is not None: params["voice"] = voice # send request try: response = self._session.post(self.URI_BASE, json=params) except ConnectionError: time.sleep(random.randrange(1, 7)) response = self._session.post(self.URI_BASE, json=params) return response.json() @staticmethod def random_voice() -> str: return random.choice(eng_voices) class TikTokTTSException(Exception): def __init__(self, status_code, message): self.status_code = status_code self.message = message super().__init__(self.message) def __str__(self): return f"Code: {self.status_code}, Message: {self.message}"
replying to this since i got a simplejson error not found error//-----> ----->pip install simplejson then go to the code and replace the import statement import json as simplejson even with the dependency still being present i had to use the as statement for it to be found
Describe the bug
hello, could someone help me with this error?
Reproduction Steps
python3 main.py
Expected behavior
I exptected the video to be produced but it didnt
Screenshots
System Information
Operating System : [e.g. Windows 11] Python version : [e.g. Python 3.6] App version / Branch : [e.g. latest, V2.0, master, develop]
Checklist
Additional Context
No response