
def amine():
    import pandas as pd
    import pathlib
    print('wait..\n')
    import requests

    url = 'https://raw.githubusercontent.com/Opensourcefordatascience/Data-sets/master/difficile.csv'
    # r = requests.get(url, allow_redirects=True)

    # open('data.csv', 'wb').write(r.content)

    df = pd.read_csv(url)
    # df = pd.read_csv(str(pathlib.Path(__file__).parent.resolve())+'/data/data.csv')
    return df

def haytem():
    return print('zahya a sat\n')

def translate_audio(text='a',lang='en'):
    from googletrans import Translator

    lg=False
    df = support()

    for i in range(0,len(df['languages'])):
        if lang.upper() == df['languages'][i].upper():
            lang=df['code'][i]
            lg=True

    translator = Translator()
    if lang in list(df['code']) or lg==True:
        translator = Translator()
        if text=='a':
            text=input(("Values to translate:"))
        translation = translator.translate(text, dest=lang)
        langg='Anglais'
        for i in range(0,len(df['code'])):
            if translator.detect(text).lang.upper() == df['code'][i].upper():
                langg=df['languages'][i]
        
    # print(translation.text)
    print(translator.detect(text).lang)
    print(translation.text)
    print(langg)

    from gtts import gTTS
    import os
    mytext = translation.text
    # language = 'ru'
    try:
        myobj = gTTS(text=mytext, lang=lang, slow=False)
        myobj.save("welcome.mp3")
        from IPython.display import Audio
        return Audio('welcome.mp3', autoplay=True)
    except:
        print('language not supported for audio.')
        return False


def translate(text='a',lang='en'):
    from googletrans import Translator
    lg=False
    df = support()
    for i in range(0,len(df['languages'])):
        if lang.upper() == df['languages'][i].upper():
            lang=df['code'][i]
            lg=True
    if lang in list(df['code']) or lg==True:
        translator = Translator()
        if text=='a':
            text=input(("Values to translate:"))
        translation = translator.translate(text, dest=lang)
        langg='Anglais'
        for i in range(0,len(df['code'])):
            if translator.detect(text).lang.upper() == df['code'][i].upper():
                langg=df['languages'][i]
        
        # print(translator.detect(text).lang)
        # print(translation.text)
        # print(langg)
        return translation.text,langg
        print(translator.detect(text).lang)
        print(translation.text)
    else:
        print('invalid destination language if you want to check the languages supported please use the method : lang() returned dataframe contain all languages and her codes.')
        return df

def subtract_numbers(num1, num2):
    return num1 - num2

def support():
    import pandas as pd
    languages = ["Afrikaans","Albanais","Amharique","Arabe","Arménien","Azéri","Basque","Biélorusse","Bengali","Bosnien","Bulgare","Catalan","Cebuano","Chinois (simplifié)","Chinois (traditionnel)","Corse","Croate","Tchèque","Danois","Néerlandais","Anglais","Espéranto","Estonien","Finnois","Français","Frison","Galicien","Géorgien","Allemand","Grec","Gujarati","Créole haïtien","Haoussa","Hawaïen","Hébreu","Hindi","Hmong","Hongrois","Islandais","Igbo","Indonésien","Irlandais","Italien","Japonais","Javanais","Kannada","Kazakh","Khmer","Kinyarwanda","Coréen","Kurde","Kirghyz","Laotien","Latin","Letton","Lituanien","Luxembourgeois","Macédonien","Malgache","Malais","Malayâlam","Maltais","Maori","Marathi","Mongol","Birman","Népalais","Norvégien","Nyanja (Chichewa)","Odia (Oriya)","Pachtô","Perse","Polonais","Portugais (Portugal, Brésil)","Panjabi","Roumain","Russe","Samoan","Gaélique (Écosse)","Serbe","Sesotho","Shona","Sindhî","Singhalais","Slovaque","Slovène","Somali","Spanish","Soundanais","Swahili","Suédois","Tagalog (philippin)","Tadjik","Tamoul","Tatar","Télougou","Thaï","Turc","Turkmène","Ukrainien","Urdu","Ouïghour","Ouzbek","Vietnamien","Gallois","Xhosa","Yiddish","Yoruba","Zulu"]
    lng=['af', 'sq', 'am', 'ar', 'hy', 'az', 'eu', 'be', 'bn', 'bs', 'bg', 'ca', 'ceb', 'zh-CN', 'zh-TW', 'co', 'hr', 'cs', 'da', 'nl', 'en', 'eo', 'et', 'fi', 'fr', 'fy', 'gl', 'ka', 'de', 'el', 'gu', 'ht', 'ha', 'haw', 'he', 'hi', 'hmn', 'hu', 'is', 'ig', 'id', 'ga', 'it', 'ja', 'jv', 'kn', 'kk', 'km', 'rw', 'ko', 'ku', 'ky', 'lo', 'la', 'lv', 'lt', 'lb', 'mk', 'mg', 'ms', 'ml', 'mt', 'mi', 'mr', 'mn', 'my', 'ne', 'no', 'ny', 'or', 'ps', 'fa', 'pl', 'pt', 'pa', 'ro', 'ru', 'sm', 'gd', 'sr', 'st', 'sn', 'sd', 'si', 'sk', 'sl', 'so', 'es', 'su', 'sw', 'sv', 'tl', 'tg', 'ta', 'tt', 'te', 'th', 'tr','tk', 'uk', 'ur', 'ug', 'uz', 'vi', 'cy', 'xh', 'yi', 'yo', 'zu']
    d = {'languages': languages, 'code': lng}
    df = pd.DataFrame(data=d)
    return df

def multiply_numbers(num1, num2):
    return num1 * num2

def divise_numbers(num1, num2):
    return num1 / num2

# print(amine())

# translate_audio(lang='en')