Skip to content

Commit

Permalink
better language managing and better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
talosross committed Jan 14, 2024
1 parent 8f819b7 commit c82b4e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId = "com.talosross.summaryyou"
minSdk = 24
targetSdk = 34
versionCode = 2024011216
versionName = "1.1.3"
versionCode = 2024011417
versionName = "1.1.4"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/python/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,17 @@ def get_video_transcript(video_id: str) -> str:
Fetch the transcript of the provided YouTube video
"""
try:
transcript = YouTubeTranscriptApi.get_transcript(video_id, languages=['af', 'ak', 'sq', 'am', 'as', 'ay', 'az', 'bn', 'eu', 'be', 'bho', 'bs', 'bg', 'my', 'ca', 'ceb', 'co', 'hr', 'cs', 'da', 'dv', 'eo', 'et', 'ee', 'fil', 'fi', 'gl', 'lg', 'ka', 'el', 'gn', 'gu', 'ht', 'ha', 'haw', 'iw', 'hmn', 'hu', 'is', 'ig', 'id', 'ga', 'it', 'jv', 'kn', 'kk', 'km', 'rw', 'ko', 'kri', 'ku', 'ky', 'lo', 'la', 'lv', 'ln', 'lt', 'lb', 'mk', 'mg', 'ms', 'ml', 'mt', 'mi', 'mr', 'mn', 'ne', 'nso', 'no', 'ny', 'or', 'om', 'ps', 'fa', 'pl', 'pt', 'pa', 'qu', 'ro', 'ru', 'sm', 'sa', 'gd', 'sr', 'sn', 'sd', 'si', 'sk', 'sl', 'so', 'st', 'es', 'su', 'sw', 'sv', 'tg', 'ta', 'tt', 'ti', 'ts', 'tr', 'tk', 'uk', 'ur', 'ug', 'uz', 'vi', 'cy', 'fy', 'xh', 'yi', 'yo', 'zu', 'de', 'en', 'en-US', 'en-GB', 'de-AT'])
# Get the transcript languages
transcript_list = YouTubeTranscriptApi.list_transcripts(video_id)
language = [transcript.language_code for transcript in transcript_list]
# Get the transcript
transcript = YouTubeTranscriptApi.get_transcript(video_id, languages=[language[0]])
except TranscriptsDisabled:
# The video doesn't have a transcript
return None

text = " ".join([line["text"] for line in transcript])
return text or "Fehler"
return text


def generate_summary(text: str, key: str, length: int, article: bool, language: str) -> str:
"""
Expand Down

0 comments on commit c82b4e5

Please sign in to comment.