abhishekjoel commited on
Commit
9063eef
·
verified ·
1 Parent(s): 0c42ba5

Delete utils.py

Browse files
Files changed (1) hide show
  1. utils.py +0 -41
utils.py DELETED
@@ -1,41 +0,0 @@
1
- import os
2
- from pydub import AudioSegment
3
- import openai
4
- import tempfile
5
-
6
- def split_audio(file_path, chunk_length=10*60*1000):
7
- audio = AudioSegment.from_file(file_path)
8
- chunks = []
9
- for start in range(0, len(audio), chunk_length):
10
- chunk = audio[start:start + chunk_length]
11
- chunk_file = f"chunk_{start // chunk_length}.mp3"
12
- chunk.export(chunk_file, format="mp3")
13
- chunks.append(chunk_file)
14
- return chunks
15
-
16
- def transcribe_audio(chunks):
17
- transcriptions = []
18
- timestamps = []
19
- for idx, chunk in enumerate(chunks):
20
- with open(chunk, "rb") as audio_file:
21
- # Transcribe using ChatGPT (Whisper functionality through chat)
22
- response = openai.ChatCompletion.create(
23
- model="gpt-4",
24
- messages=[
25
- {"role": "user", "content": f"Transcribe the following audio chunk: {chunk}"}
26
- ]
27
- )
28
- transcriptions.append(response['choices'][0]['message']['content'])
29
- timestamps.append(f"Chunk {idx} - {idx * 10} min to {(idx + 1) * 10} min")
30
- return transcriptions, timestamps
31
-
32
- def generate_lesson_plan(transcriptions):
33
- combined_transcript = " ".join(transcriptions)
34
- response = openai.ChatCompletion.create(
35
- model="gpt-4",
36
- messages=[
37
- {"role": "user", "content": f"Generate a detailed lesson plan based on the following transcript:\n\n{combined_transcript}"}
38
- ]
39
- )
40
- lesson_plan = response['choices'][0]['message']['content']
41
- return lesson_plan