Skip to content

Commit

Permalink
add LANGUAGE environment to process videos using different languages …
Browse files Browse the repository at this point in the history
…than en
  • Loading branch information
Stell0 committed Jun 22, 2024
1 parent ae500e2 commit 79371c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,7 @@ https://www.youtube.com/@lexfridman
https://www.youtube.com/@hubermanlab
```

`LANGUAGE`: transcription language to use. Default "en"

then wait ⏱️ (cron is launched every hour and take videos published during the previous hour)

9 changes: 5 additions & 4 deletions src/ytsummary.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from langchain_community.document_loaders import YoutubeLoader
from langchain.chains.summarize import load_summarize_chain
from langchain_openai import ChatOpenAI
import os

def get_summary(url):
loader = YoutubeLoader.from_youtube_url(url)
loader = YoutubeLoader.from_youtube_url(url, language=os.getenv("LANGUAGE", "en"))
documents = loader.load()
llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo")

Expand All @@ -24,7 +25,7 @@ def get_summary(url):
return summary['output_text']

def get_summary2(url):
loader = YoutubeLoader.from_youtube_url(url)
loader = YoutubeLoader.from_youtube_url(url, language=os.getenv("LANGUAGE", "en"))
documents = loader.load()
llm = ChatOpenAI(temperature=0, model_name="gpt-4o")

Expand All @@ -43,7 +44,7 @@ def get_summary2(url):
return "\n".join([s['output_text'] for s in summary])

def get_summary3(url):
loader = YoutubeLoader.from_youtube_url(url)
loader = YoutubeLoader.from_youtube_url(url, language=os.getenv("LANGUAGE", "en"))
documents = loader.load()
llm = ChatOpenAI(temperature=0, model_name="gpt-4o")

Expand All @@ -66,7 +67,7 @@ def get_summary3(url):
Identify: Recognize all distinct concepts mentioned in the text.
For each concept, Reword and Rephrase the concept if necessary to ensure clarity and conciseness.
Output the summary of each concept and the conclusions and points of view of the discussion about it without any title in plain text.
Ensure that the output is comprehensive and captures every idea presented in the text.
Ensure that the output is comprehensive and captures every idea presented in the text. Use same language as the text.
Text:
{text}
Expand Down

0 comments on commit 79371c0

Please sign in to comment.