Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -116,19 +116,22 @@ def save_cookies(file):
|
|
116 |
return None
|
117 |
|
118 |
# β
YouTube pipeline
|
119 |
-
def
|
120 |
try:
|
121 |
if not WHISPER_AVAILABLE:
|
122 |
return "β Whisper is not installed. Run: pip install openai-whisper", ""
|
123 |
-
if
|
124 |
-
return "β
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
if
|
129 |
-
|
|
|
|
|
|
|
130 |
|
131 |
-
transcript = transcribe_audio(
|
132 |
if transcript.startswith("β"):
|
133 |
return transcript, ""
|
134 |
|
@@ -140,6 +143,7 @@ def run_pipeline(url, cookies_file):
|
|
140 |
print(tb)
|
141 |
return f"β Unhandled Error:\n{tb}", ""
|
142 |
|
|
|
143 |
# β
Audio file upload pipeline
|
144 |
def run_pipeline_audio(audio_file):
|
145 |
try:
|
|
|
116 |
return None
|
117 |
|
118 |
# β
YouTube pipeline
|
119 |
+
def run_pipeline_audio(audio_file):
|
120 |
try:
|
121 |
if not WHISPER_AVAILABLE:
|
122 |
return "β Whisper is not installed. Run: pip install openai-whisper", ""
|
123 |
+
if audio_file is None:
|
124 |
+
return "β No audio file uploaded", ""
|
125 |
|
126 |
+
# Handle both file-like and NamedString (path string)
|
127 |
+
temp_audio_path = tempfile.mktemp(suffix=os.path.splitext(str(audio_file))[-1])
|
128 |
+
if hasattr(audio_file, "read"):
|
129 |
+
with open(temp_audio_path, "wb") as f:
|
130 |
+
f.write(audio_file.read())
|
131 |
+
else:
|
132 |
+
shutil.copy(str(audio_file), temp_audio_path)
|
133 |
|
134 |
+
transcript = transcribe_audio(temp_audio_path)
|
135 |
if transcript.startswith("β"):
|
136 |
return transcript, ""
|
137 |
|
|
|
143 |
print(tb)
|
144 |
return f"β Unhandled Error:\n{tb}", ""
|
145 |
|
146 |
+
|
147 |
# β
Audio file upload pipeline
|
148 |
def run_pipeline_audio(audio_file):
|
149 |
try:
|