Update app.py
Browse files
app.py
CHANGED
|
@@ -82,6 +82,13 @@ def split_audio_if_needed(path):
|
|
| 82 |
return files
|
| 83 |
|
| 84 |
def transcribe_core(path, model):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
chunks = split_audio_if_needed(path)
|
| 86 |
txts = []
|
| 87 |
for f in chunks:
|
|
@@ -97,6 +104,7 @@ def transcribe_core(path, model):
|
|
| 97 |
summ = res.choices[0].message.content.strip()
|
| 98 |
return full, summ
|
| 99 |
|
|
|
|
| 100 |
# ========================
|
| 101 |
# 💬 主流程
|
| 102 |
# ========================
|
|
|
|
| 82 |
return files
|
| 83 |
|
| 84 |
def transcribe_core(path, model):
|
| 85 |
+
# 處理 iPhone LINE 語音(mp4 audio-only)
|
| 86 |
+
if path.lower().endswith(".mp4"):
|
| 87 |
+
audio = AudioSegment.from_file(path, format="mp4")
|
| 88 |
+
tmp_path = path.replace(".mp4", ".wav")
|
| 89 |
+
audio.export(tmp_path, format="wav")
|
| 90 |
+
path = tmp_path
|
| 91 |
+
|
| 92 |
chunks = split_audio_if_needed(path)
|
| 93 |
txts = []
|
| 94 |
for f in chunks:
|
|
|
|
| 104 |
summ = res.choices[0].message.content.strip()
|
| 105 |
return full, summ
|
| 106 |
|
| 107 |
+
|
| 108 |
# ========================
|
| 109 |
# 💬 主流程
|
| 110 |
# ========================
|