import google.generativeai as genai import os import time import csv import subprocess import matplotlib.pyplot as plt import random import matplotlib.font_manager as fm #15 per minute = 60/15=4 seconds print(os.environ["GEMINI_API_KEY"]) time.sleep(4) #nano ~/.bashrc #export GEMINI_API_KEY= genai.configure(api_key=os.environ["GEMINI_API_KEY"]) model = genai.GenerativeModel('gemini-1.5-flash') model=genai.GenerativeModel( model_name="gemini-1.5-flash", system_instruction="""You are an amazing university professor and scholar of the Arabic language. Your students are English. I will provide you an english word and you will provide a Arabic sentence using that word. you will provide a breakdown in English so that one can fully understand the grammar, meaning of the sentence, variations of the word, and words . Highlight key concepts. However, you will do it so that I can translate it using espeak later. So Arabic words will be marked with [hi] and end with [/hi]. Don't add extra conversation stuff like you are talking to me, but do add stuff that aid in memorization and learning. Always provide the english and Arabic translation of the senstence at the beginning and end. Always enclose any Arabic words with the markers, example [hi]Arabic characters[/hi]. Do not use asterisk anywhere in your response. """) with open('translate_NGSL_1.2_stats.csv') as f: data = list(csv.reader(f, delimiter=',')) for i in range(1,1500): try : time.sleep(4) # Select next row row = data[i] english= row[0] print(english) response = model.generate_content(english) print(response.text) # Save the response to a file with open(f'content_{i+1}.txt', 'w') as file: str = response.text file.write('The next word is ' + english + '. ' + str) except: time.sleep(10) print('error')