feat(audio_prompts): add default audio prompts for narrator

feat(audio_prompts): add en_narrator_deep audio prompt for narrator
feat(audio_prompts): add en_narrator_light_bg audio prompt for narrator
fix(video.py): fix indentation and add prompt for generating thumbnail
fix(montage.py): fix indentation and add prompt for generating thumbnail
fix(montage.py): fix image download for wikimage slides

fix(speak.py): remove unused import statement
fix(speak.py): remove unused variable 'fakenames'
feat(speak.py): add function 'remove_blank_moments' to remove silent parts from audio file
feat(speak.py): add function 'optimize_string_groups' to optimize string groups for audio generation
fix(speak.py): fix comment indentation in 'generate_voice' function
fix(speak.py): remove unused imports in 'generate_voice' function
fix(speak.py): remove unused variable 'reduced_noise' in 'generate_voice' function
fix(speak.py): remove unused import statements in 'generate_voice' function
fix(speak.py): remove unused import statement for 'logging' module
fix(speak.py): remove unused print statements in 'main' function
fix(speak.py): remove unused import statement for 'logging' module
fix(speak.py): remove unused print statements in 'main' function
fix(speak.py):

fix(wiki_downloader.py): fix Google search URL to include correct query parameter
fix(wiki_downloader.py): reduce sleep time after page load to 1 second
fix(wiki_downloader.py): increase sleep time after image click to 5 seconds
This commit is contained in:
Paillat
2023-07-02 11:17:10 +02:00
parent f1de2ad596
commit f7835f6604
13 changed files with 206 additions and 114 deletions

View File

@@ -41,7 +41,10 @@ VALID_PRIVACY_STATUSES = ('public', 'private', 'unlisted')
async def get_authenticated_service(credentialsPath="", force_refresh=False):
CLIENT_SECRETS_FILE = ""
try:
CLIENT_SECRETS_FILE=os.path.join(credentialsPath, "client_secret.json")
if os.path.exists(os.path.join(credentialsPath, "client_secret.json")):
CLIENT_SECRETS_FILE=os.path.join(credentialsPath, "client_secret.json")
else:
raise FileNotFoundError("No client_secret.json file found in the specified path !")
except:
listdir = os.listdir(credentialsPath)
for file in listdir:
@@ -146,25 +149,16 @@ async def upload_video(path, title, description, category, keywords, privacyStat
'keywords': keywords,
'privacyStatus': privacyStatus
}
refresh = False
while True:
try:
youtube = await get_authenticated_service(credentials_path, force_refresh=refresh)
videoid = await initialize_upload(youtube, options)
await upload_thumbnail(videoid, path + "/miniature.png", credentials_path, youtube)
return videoid
except HttpError as e:
print('An HTTP error %d occurred:\n%s' % (e.resp.status, e.content))
#escape the loop
break
except:
#refresh the token
if not refresh:
refresh = True
else:
#escape the loop
break
youtube = await get_authenticated_service(credentials_path, force_refresh=False)
print("Uploading video...")
try:
videoid = await initialize_upload(youtube, options)
except:
youtube = await get_authenticated_service(credentials_path, force_refresh=True)
videoid = await initialize_upload(youtube, options)
thumb_path = os.path.abspath(os.path.join(path, "thumbnail.jpg"))
await upload_thumbnail(videoid, thumb_path, credentials_path, youtube)
return videoid
async def upload_thumbnail(video_id, file, credentials_path="", youtube=None):

View File

@@ -13,7 +13,7 @@ def download_image(query, download_path):
driver = uc.Chrome(options=options)
try:
driver.get(f"https://www.google.com/search?site=&tbm=isch&source=hp&biw=1873&bih=990&tbs=isz:l&q=site:wikipedia.org+{query.replace(' ', '+')}")
driver.get(f"https://www.google.com/search?site=&tbm=isch&source=hp&biw=1873&bih=99&q=site:wikipedia.org+{query.replace(' ', '+')}")
time.sleep(2)
tos = driver.find_elements(By.CLASS_NAME, "VfPpkd-vQzf8d")
@@ -21,11 +21,10 @@ def download_image(query, download_path):
if to.text.lower() == "tout refuser":
to.click()
break
time.sleep(10)
time.sleep(1)
image = driver.find_element(By.CLASS_NAME, "rg_i")
image.click()
time.sleep(2)
time.sleep(5)
image = driver.find_element(By.CLASS_NAME, "r48jcc").get_attribute("src") or ""
image_content = None