-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: introducing experimental async summary generation.
- feat: legacy mode - feat: language mode for prompt - feat: time elapse counter - prompt: change of prompt structure
- Loading branch information
Showing
7 changed files
with
165 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
docx==0.2.4 | ||
langchain==0.0.112 | ||
langchain==0.0.123 | ||
langdetect==1.0.9 | ||
numpy==1.24.2 | ||
openai==0.27.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
from pytube import YouTube | ||
import xml.etree.ElementTree as ET | ||
import asyncio | ||
|
||
async def coroutine1(): | ||
await asyncio.sleep(2) | ||
return {"id": 1, "content": "result 1"} | ||
|
||
async def coroutine2(): | ||
await asyncio.sleep(1) | ||
return {"id": 2, "content": "result 2"} | ||
|
||
async def main(): | ||
tasks = [coroutine1(), coroutine2()] | ||
completed_count = 0 | ||
results = [] | ||
|
||
for coro in asyncio.as_completed(tasks): | ||
result = await coro | ||
results.append(result) | ||
completed_count += 1 | ||
print(f"Coroutine {result['id']} completed ({completed_count}/{len(tasks)}).") | ||
|
||
print("All coroutines completed.") | ||
print("Results:", sorted(results, key=lambda x: x['id'])) | ||
|
||
asyncio.run(main()) | ||
|
||
|
||
|
||
|
||
|
||
|
||
def extract_xml_caption(xml: str) -> str: | ||
"""Extracts the text content from the <s> elements of an XML string.""" | ||
root = ET.fromstring(xml) | ||
text_content = '' | ||
for child in root.iter('s'): | ||
text_content += child.text | ||
return text_content.strip() | ||
|
||
|
||
def get_transcript(url: str, lang_code: str = 'a.en') -> str: | ||
"""Extracts the transcript from a YouTube video.""" | ||
yt = YouTube(url) | ||
caption = yt.captions[lang_code] | ||
xml_caption = caption.xml_captions | ||
return extract_xml_caption(xml_caption) |