bluenevus commited on
Commit
ad0756f
·
verified ·
1 Parent(s): 514d9eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
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 (simplified as OpenAI doesn't provide speaker diarization)
211
- formatted_transcript = f"Speaker 1: {transcription}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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())