Update app.py
Browse files
app.py
CHANGED
|
@@ -207,8 +207,24 @@ def process_media(file_path, is_url=False):
|
|
| 207 |
# Transcribe chunks
|
| 208 |
transcription = transcribe_audio_chunks(chunks)
|
| 209 |
|
| 210 |
-
# Diarization
|
| 211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
transcription_text = formatted_transcript
|
| 214 |
generated_file = io.BytesIO(transcription_text.encode())
|
|
|
|
| 207 |
# Transcribe chunks
|
| 208 |
transcription = transcribe_audio_chunks(chunks)
|
| 209 |
|
| 210 |
+
# Diarization using OpenAI
|
| 211 |
+
diarization_prompt = f"""
|
| 212 |
+
The following is a transcription of a conversation. Please identify different speakers and label them as Speaker 1, Speaker 2, etc. Format the output as a series of speaker labels followed by their dialogue. Here's the transcription:
|
| 213 |
+
|
| 214 |
+
{transcription}
|
| 215 |
+
|
| 216 |
+
Please analyze the content and speaking styles to differentiate between speakers. Consider changes in topic, speaking patterns, and any contextual clues that might indicate a change in speaker.
|
| 217 |
+
"""
|
| 218 |
+
|
| 219 |
+
diarization_response = openai.ChatCompletion.create(
|
| 220 |
+
model="gpt-3.5-turbo",
|
| 221 |
+
messages=[
|
| 222 |
+
{"role": "system", "content": "You are an AI assistant skilled in analyzing conversations and identifying different speakers."},
|
| 223 |
+
{"role": "user", "content": diarization_prompt}
|
| 224 |
+
]
|
| 225 |
+
)
|
| 226 |
+
|
| 227 |
+
formatted_transcript = diarization_response['choices'][0]['message']['content']
|
| 228 |
|
| 229 |
transcription_text = formatted_transcript
|
| 230 |
generated_file = io.BytesIO(transcription_text.encode())
|