Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -133,22 +133,18 @@ def transcribe_audio_chunked(audio_path):
|
|
| 133 |
chunk_data = audio_data[start_idx:end_idx]
|
| 134 |
|
| 135 |
print(f"Processing chunk {i+1}/{num_chunks}...")
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
combined_text = " ".join(all_transcriptions)
|
| 149 |
-
|
| 150 |
-
if not combined_text:
|
| 151 |
-
return None, "❌ Transcription returned empty text"
|
| 152 |
|
| 153 |
# Rewrite combined text for clarity
|
| 154 |
rewrite_prompt = f"""Rewrite the following transcribed text with proper grammar, punctuation, and clarity.
|
|
|
|
| 133 |
chunk_data = audio_data[start_idx:end_idx]
|
| 134 |
|
| 135 |
print(f"Processing chunk {i+1}/{num_chunks}...")
|
| 136 |
+
# Transcribe chunk
|
| 137 |
+
transcription = client.audio.transcriptions.create(
|
| 138 |
+
file=(f"chunk_{i}.mp3", chunk_data),
|
| 139 |
+
model=TRANSCRIPTION_MODEL,
|
| 140 |
+
temperature=0.0,
|
| 141 |
+
response_format="verbose_json"
|
| 142 |
+
) # <-- closing parenthesis added
|
| 143 |
+
|
| 144 |
+
chunk_text = transcription.text.strip()
|
| 145 |
+
if chunk_text:
|
| 146 |
+
all_transcriptions.append(chunk_text)
|
| 147 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
# Rewrite combined text for clarity
|
| 150 |
rewrite_prompt = f"""Rewrite the following transcribed text with proper grammar, punctuation, and clarity.
|