-
Notifications
You must be signed in to change notification settings - Fork 0
/
tr_weekly.py
57 lines (43 loc) · 1.41 KB
/
tr_weekly.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import json
import whisper
import openai
import sys
from scribe import send_notes
from dotenv import load_dotenv
load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")
def main():
if len(sys.argv) < 2:
print("Usage: python tr_weekly.py <video_name.mp4>")
return
meeting = sys.argv[1]
transcript = transcribe(meeting)
res = summarize(transcript)
with open('result.txt', 'w') as file:
file.write(res)
send_notes(res)
# Load medium english only model and transcribe
def transcribe(recording):
model = whisper.load_model("medium.en")
result = model.transcribe(recording)
return result["text"]
def summarize(transcript):
# Grab system prompt from system.txt
with open('context/system.txt') as f:
system_prompt = f.read()
# Grab sample i/o; Disabled for now since response has mixed results
f = open('context/sample.json')
sample_data = json.load(f)
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo-16k",
messages=[
{"role": "system", "content": system_prompt},
# {"role": "user", "content": sample_data['input']},
# {"role": "assistant", "content": sample_data['output']},
{"role": "user", "content": transcript}
]
)
return response['choices'][0]['message']['content']
if __name__ == "__main__":
main()