Keyword, Audio to Blog - WIP

This commit is contained in:
AjaySi
2024-04-09 12:30:04 +05:30
parent 8a2ef6ef26
commit d968e06a9d
4 changed files with 15 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
# AI Blog Creation and Management Toolkit
# AI Blog Content Generation Toolkit - Alwrity
![](https://github.com/AJaySi/AI-Blog-Writer/blob/main/workspace/keyword_blog.gif)
## Introduction

View File

@@ -49,7 +49,11 @@ def speech_to_text(video_url, output_path='.'):
logger.info(f"Downloading audio for: {yt.title}")
global progress_bar
progress_bar = tqdm(total=1.0, unit='iB', unit_scale=True, desc=yt.title)
audio_file = audio_stream.download(output_path)
try:
audio_file = audio_stream.download(output_path)
except Exception as err:
logger.error(f"Failed to download audio file: {audio_file}")
progress_bar.close()
logger.info(f"Audio downloaded: {yt.title} to {output_path}")
# Audio filepath from local directory.
@@ -78,7 +82,7 @@ def speech_to_text(video_url, output_path='.'):
file=open(audio_file, "rb"),
response_format="text"
)
logger.info(f"\nYouTube video transcription:\n\n{transcript}\n")
logger.info(f"\nYouTube video transcription:\n{yt.title}\n{transcript}\n")
return transcript, yt.title
except Exception as e:
@@ -90,9 +94,14 @@ def speech_to_text(video_url, output_path='.'):
sys.exit("Video processing failure.")
finally:
if os.path.exists(audio_file):
try:
if os.path.exists(audio_file):
os.remove(audio_file)
logger.info("Temporary audio file removed.")
except PermissionError:
logger.error(f"Permission error: Cannot remove '{audio_file}'. Please make sure you have the necessary permissions.")
except Exception as e:
logger.error(f"An error occurred removing audio file: {e}")
def long_video(temp_file_name):

View File

@@ -32,7 +32,7 @@ def llm_text_gen(prompt):
# Check if API key is provided for the given gpt_provider
get_api_key(gpt_provider)
logger.info(f"Model: {model}, Temp: {temperature}, MaxTokens: {max_tokens}, TopP: {top_p}, N: {n}, FrequencyPenalty: {fp}")
logger.info(f"Temp: {temperature}, MaxTokens: {max_tokens}, TopP: {top_p}, N: {n}, FrequencyPenalty: {fp}")
# Perform text generation using the specified LLM parameters and prompt
if 'google' in gpt_provider.lower():
try:

View File

@@ -23,3 +23,4 @@ wordcloud
nltk
prompt_toolkit
ipython
html2image