add heinous offences tool
Diff
heinous_offences/.gitignore | 2 ++
heinous_offences/import_csv.py | 24 ++++++++++++++++++++++++
test/.gitignore | 2 --
test/transcribe.py | 14 --------------
4 files changed, 26 insertions(+), 16 deletions(-)
@@ -1,0 +1,2 @@
*.json
*.csv
@@ -1,0 +1,24 @@
import tinydb
import csv
db = tinydb.TinyDB('db.json')
file = open('ipc.csv', 'r')
reader = csv.reader(file)
header_parsed = False
for row in reader:
if not header_parsed:
header_parsed = True
continue
record = {
'section': row[0],
'section_text': row[1],
'minimum_punishment': row[2],
'severity': row[3],
'comment': row[4]
}
db.insert(record)
file.close()
@@ -1,2 +1,0 @@
*.txt
*.mp3
@@ -1,14 +1,0 @@
import os
import whisper
def transcribe_audio(audio_file_path, model_path):
model = whisper.load_model(model_path)
result = model.transcribe(audio_file_path)
text_file_path = os.path.splitext(audio_file_path)[0] + ".txt"
with open(text_file_path, "w") as text_file:
text_file.write(result['text'])
audio_file_path = 'test.mp3'
if audio_file_path is not None:
transcribe_audio(audio_file_path, model_path='medium')