SociallyIneptWeeb / LanguageLeapAI

Your Personal Multilingual AI Translator
MIT License
849 stars 168 forks source link

Added Katakana support for english to english voicevox #55

Closed CattoYT closed 1 year ago

CattoYT commented 1 year ago

Tbh no idea if this actually works, but i tested it with another voicevox project. Seems to work somewhat

SociallyIneptWeeb commented 1 year ago

Sorry, but I tested it out and it sounds absolutely horrible and normal English speakers probably won't even understand it

hoangvu12 commented 1 year ago

Sorry, but I tested it out and it sounds absolutely horrible and normal English speakers probably won't even understand it

The reason why it sounds horrible because the converter is not accurate, I actually tried this using a converter website, then scrape the converted text from it. It sounds pretty good to me.

Here is the code for anyone interested.

def translate_to_kana(text):
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 OPR/96.0.0.0',
    }

    target_url = f'https://www.sljfaq.org/cgi/e2k.cgi?word={urllib.parse.quote_plus(text)}'

    r = requests.get(target_url, headers=headers)

    if r.status_code != 200:
        print('Unable to reach Kana translate page')
        return

    soup = BeautifulSoup(r.text, 'html.parser')
    katakana_str = soup.find('td', {'id': 'katakana-string'}).text

    return katakana_str.replace('・', '').strip()
CattoYT commented 1 year ago

Sorry, but I tested it out and it sounds absolutely horrible and normal English speakers probably won't even understand it

The reason why it sounds horrible because the converter is not accurate, I actually tried this using a converter website, then scrape the converted text from it. It sounds pretty good to me.

Here is the code for anyone interested.


def translate_to_kana(text):

    headers = {

        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 OPR/96.0.0.0',

    }

    target_url = f'https://www.sljfaq.org/cgi/e2k.cgi?word={urllib.parse.quote_plus(text)}'

    r = requests.get(target_url, headers=headers)

    if r.status_code != 200:

        print('Unable to reach Kana translate page')

        return

    soup = BeautifulSoup(r.text, 'html.parser')

    katakana_str = soup.find('td', {'id': 'katakana-string'}).text

    return katakana_str.replace('・', '').strip()

I'll check this out when I get home, I don't know if it will work because I think the main problem is with voicevox being annoying.

MaxAkito commented 1 year ago

Sorry, but I tested it out and it sounds absolutely horrible and normal English speakers probably won't even understand it

The reason why it sounds horrible because the converter is not accurate, I actually tried this using a converter website, then scrape the converted text from it. It sounds pretty good to me.

Here is the code for anyone interested.

def translate_to_kana(text):
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 OPR/96.0.0.0',
    }

    target_url = f'https://www.sljfaq.org/cgi/e2k.cgi?word={urllib.parse.quote_plus(text)}'

    r = requests.get(target_url, headers=headers)

    if r.status_code != 200:
        print('Unable to reach Kana translate page')
        return

    soup = BeautifulSoup(r.text, 'html.parser')
    katakana_str = soup.find('td', {'id': 'katakana-string'}).text

    return katakana_str.replace('・', '').strip()

I tried this and it works quite well, not making a fork but for all those looking into this same thing, this works much better.