kabigon 0.8.1__py3-none-any.whl → 0.8.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kabigon/youtube.py +0 -2
- kabigon/ytdlp.py +51 -65
- {kabigon-0.8.1.dist-info → kabigon-0.8.2.dist-info}/METADATA +9 -4
- {kabigon-0.8.1.dist-info → kabigon-0.8.2.dist-info}/RECORD +7 -7
- {kabigon-0.8.1.dist-info → kabigon-0.8.2.dist-info}/WHEEL +0 -0
- {kabigon-0.8.1.dist-info → kabigon-0.8.2.dist-info}/entry_points.txt +0 -0
- {kabigon-0.8.1.dist-info → kabigon-0.8.2.dist-info}/licenses/LICENSE +0 -0
kabigon/youtube.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import aioytt
|
2
2
|
import aioytt.video_id
|
3
|
-
import timeout_decorator
|
4
3
|
from youtube_transcript_api import YouTubeTranscriptApi
|
5
4
|
|
6
5
|
from .loader import Loader
|
@@ -12,7 +11,6 @@ class YoutubeLoader(Loader):
|
|
12
11
|
def __init__(self, languages: list[str] | None = None) -> None:
|
13
12
|
self.languages = languages or DEFAULT_LANGUAGES
|
14
13
|
|
15
|
-
@timeout_decorator.timeout(20)
|
16
14
|
def load(self, url: str) -> str:
|
17
15
|
video_id = aioytt.video_id.parse_video_id(url)
|
18
16
|
|
kabigon/ytdlp.py
CHANGED
@@ -1,25 +1,21 @@
|
|
1
|
-
import functools
|
1
|
+
# import functools
|
2
2
|
import hashlib
|
3
3
|
import os
|
4
|
-
|
4
|
+
|
5
|
+
# import subprocess
|
5
6
|
import tempfile
|
6
7
|
from typing import Final
|
7
8
|
|
8
|
-
import numpy as np
|
9
|
-
import timeout_decorator
|
10
|
-
import whisper
|
9
|
+
# import numpy as np
|
11
10
|
import yt_dlp
|
12
11
|
from loguru import logger
|
13
12
|
|
14
13
|
from .loader import Loader
|
15
14
|
|
16
15
|
try:
|
17
|
-
import
|
18
|
-
|
19
|
-
_mlx_whisper_installed = True
|
16
|
+
import whisper
|
20
17
|
except ImportError:
|
21
|
-
|
22
|
-
|
18
|
+
logger.info("OpenAI Whisper not installed. Please install it with `pip install openai-whisper`.")
|
23
19
|
|
24
20
|
DEFAULT_FFMPEG_PATH: Final[str] = "ffmpeg"
|
25
21
|
|
@@ -65,68 +61,58 @@ def download_audio(url: str) -> str:
|
|
65
61
|
return filename + ".mp3"
|
66
62
|
|
67
63
|
|
68
|
-
def load_audio(file: str, sr: int = 16000):
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
@functools.cache
|
110
|
-
def _load_whisper_model() -> whisper.Whisper:
|
111
|
-
return whisper.load_model("tiny")
|
112
|
-
|
113
|
-
|
114
|
-
def _transcribe(audio: np.ndarray) -> dict:
|
115
|
-
if _mlx_whisper_installed:
|
116
|
-
return mlx_whisper.transcribe(audio, path_or_hf_repo="mlx-community/whisper-tiny")
|
117
|
-
|
118
|
-
model = _load_whisper_model()
|
119
|
-
return model.transcribe(audio)
|
64
|
+
# def load_audio(file: str, sr: int = 16000):
|
65
|
+
# """
|
66
|
+
# Open an audio file and read as mono waveform, resampling as necessary
|
67
|
+
|
68
|
+
# Parameters
|
69
|
+
# ----------
|
70
|
+
# file: str
|
71
|
+
# The audio file to open
|
72
|
+
|
73
|
+
# sr: int
|
74
|
+
# The sample rate to resample the audio if necessary
|
75
|
+
|
76
|
+
# Returns
|
77
|
+
# -------
|
78
|
+
# A NumPy array containing the audio waveform, in float32 dtype.
|
79
|
+
# """
|
80
|
+
# ffmpeg_path = get_ffmpeg_path()
|
81
|
+
|
82
|
+
# # This launches a subprocess to decode audio while down-mixing
|
83
|
+
# # and resampling as necessary. Requires the ffmpeg CLI in PATH.
|
84
|
+
# # fmt: off
|
85
|
+
# cmd = [
|
86
|
+
# ffmpeg_path,
|
87
|
+
# "-nostdin",
|
88
|
+
# "-threads", "0",
|
89
|
+
# "-i", file,
|
90
|
+
# "-f", "s16le",
|
91
|
+
# "-ac", "1",
|
92
|
+
# "-acodec", "pcm_s16le",
|
93
|
+
# "-ar", str(sr),
|
94
|
+
# "-"
|
95
|
+
# ]
|
96
|
+
# # fmt: on
|
97
|
+
# try:
|
98
|
+
# out = subprocess.run(cmd, capture_output=True, check=True).stdout
|
99
|
+
# except subprocess.CalledProcessError as e:
|
100
|
+
# raise RuntimeError(f"Failed to load audio: {e.stderr.decode()}") from e
|
101
|
+
|
102
|
+
# return np.frombuffer(out, np.int16).flatten().astype(np.float32) / 32768.0
|
120
103
|
|
121
104
|
|
122
105
|
class YtdlpLoader(Loader):
|
123
|
-
|
106
|
+
def __init__(self, model: str = "tiny") -> None:
|
107
|
+
self.model = whisper.load_model(model)
|
108
|
+
|
124
109
|
def load(self, url: str) -> str:
|
125
110
|
audio_file = download_audio(url)
|
126
|
-
audio = load_audio(audio_file)
|
111
|
+
# audio = load_audio(audio_file)
|
112
|
+
audio = whisper.load_audio(audio_file)
|
127
113
|
|
128
114
|
# Clean up the audio file
|
129
115
|
os.remove(audio_file)
|
130
116
|
|
131
|
-
result =
|
117
|
+
result = self.model.transcribe(audio)
|
132
118
|
return result.get("text", "")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: kabigon
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.2
|
4
4
|
Author-email: narumi <toucans-cutouts0f@icloud.com>
|
5
5
|
License-File: LICENSE
|
6
6
|
Requires-Python: >=3.10
|
@@ -9,14 +9,19 @@ Requires-Dist: firecrawl-py>=2.4.1
|
|
9
9
|
Requires-Dist: httpx>=0.28.1
|
10
10
|
Requires-Dist: loguru>=0.7.3
|
11
11
|
Requires-Dist: markdownify>=0.14.1
|
12
|
-
Requires-Dist:
|
13
|
-
Requires-Dist: playwright>=1.52.0
|
12
|
+
Requires-Dist: numpy>=2.2.5
|
14
13
|
Requires-Dist: pypdf>=5.3.0
|
15
14
|
Requires-Dist: rich>=13.9.4
|
16
|
-
Requires-Dist: timeout-decorator>=0.5.0
|
17
15
|
Requires-Dist: typer>=0.15.3
|
18
16
|
Requires-Dist: youtube-transcript-api>=0.6.3
|
19
17
|
Requires-Dist: yt-dlp>=2025.4.30
|
18
|
+
Provides-Extra: all
|
19
|
+
Requires-Dist: openai-whisper>=20240930; extra == 'all'
|
20
|
+
Requires-Dist: playwright>=1.52.0; extra == 'all'
|
21
|
+
Provides-Extra: playwright
|
22
|
+
Requires-Dist: playwright>=1.52.0; extra == 'playwright'
|
23
|
+
Provides-Extra: whisper
|
24
|
+
Requires-Dist: openai-whisper>=20240930; extra == 'whisper'
|
20
25
|
Description-Content-Type: text/markdown
|
21
26
|
|
22
27
|
# kabigon
|
@@ -11,10 +11,10 @@ kabigon/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
11
11
|
kabigon/reel.py,sha256=qOwWCvcp7xNKg0JDunq_Bsl8yqqMzrnAOI9k5mSqrOU,874
|
12
12
|
kabigon/twitter.py,sha256=aRqAiFxIwln6lteWdoF6SmvbzO62yBTQRzcB7UcVJwk,1046
|
13
13
|
kabigon/utils.py,sha256=eNTLtHLSB2erDac2HH3jWemgfr8Ou_ozwVb8h9BD-4g,922
|
14
|
-
kabigon/youtube.py,sha256=
|
15
|
-
kabigon/ytdlp.py,sha256=
|
16
|
-
kabigon-0.8.
|
17
|
-
kabigon-0.8.
|
18
|
-
kabigon-0.8.
|
19
|
-
kabigon-0.8.
|
20
|
-
kabigon-0.8.
|
14
|
+
kabigon/youtube.py,sha256=F9GpLa0iUy03wYU94RrrnrXa6ExqbG6CZpqx5bPENWE,1106
|
15
|
+
kabigon/ytdlp.py,sha256=oeFoE7nWZWaT0dR9nwt_SZh_FE0gJ6Gulh6QzGCB6xo,2956
|
16
|
+
kabigon-0.8.2.dist-info/METADATA,sha256=UEq0yUqP0dgzyqMhxiHgLvP0wT_nf0PlQLy8VkufrEg,1287
|
17
|
+
kabigon-0.8.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
18
|
+
kabigon-0.8.2.dist-info/entry_points.txt,sha256=O3FYAO9w-NQvlGMJrBvtrnGHSK2QkUnQBTa30YXRbVE,45
|
19
|
+
kabigon-0.8.2.dist-info/licenses/LICENSE,sha256=H2T3_RTgmcngMeC7p_SXT3GwBLkd2DaNgAZuxulcfiA,1066
|
20
|
+
kabigon-0.8.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|