-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbCreateAdditional.py
79 lines (58 loc) · 1.96 KB
/
dbCreateAdditional.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import asyncio
import sqlite3 as sl
import pathlib
import os
import configparser
from random import randrange
import uuid
# TODO document how to set up the needed folders and paths in configuration.txt
# TODO document how to use recreateDb
# TODO indices
configParser = configparser.RawConfigParser()
configFilePath = r'configuration.txt'
configParser.read(configFilePath)
datasetPathVideo = configParser.get('COMMON', 'datasetPathVideo')
recreateDb = int(configParser.get('dbCreateAndPopulate', 'recreateDb'))
datasetPathDatabase = configParser.get('COMMON', 'datasetPathDatabase') + '/datasetAdditional.db'
if(recreateDb != 0):
filename = uuid.uuid4().hex
try:
os.rename(datasetPathDatabase,configParser.get('COMMON', 'datasetPathDatabase') + '/' + str(uuid.uuid4().hex))
except:
pass
con = sl.connect(datasetPathDatabase)
if(recreateDb != 0):
con.execute("""
CREATE TABLE AUDIO (
ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
VIDEO_ID INTEGER NOT NULL,
AUDIO_LENGTH INTEGER,
SPEAKER_EMB BLOB,
LANG TEXT,
AUDIO_EMB BLOB,
AUDIO_EMB2 BLOB,
WAV_TO_VEC BLOB,
PYANNOTE_TITANET BLOB,
AUDIO_FEATURES BLOB
);
""")
con.execute("""
CREATE INDEX AUDIO_VIDEO_ID_IDX ON AUDIO (VIDEO_ID);
""")
con.execute("""
CREATE INDEX AUDIO_AUDIO_LENGTH_IDX ON AUDIO (AUDIO_LENGTH);
""")
con.execute("""
CREATE TABLE AUDIO_TRANSFORMER (
ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
VIDEO_ID INTEGER NOT NULL,
AUDIO_LENGTH INTEGER,
AUDIO_FEATURES BLOB
);
""")
con.execute("""
CREATE INDEX AUDIO_TRANSFORMER_VIDEO_ID_IDX ON AUDIO_TRANSFORMER (VIDEO_ID);
""")
con.execute("""
CREATE INDEX AUDIO_TRANSFORMER_AUDIO_LENGTH_IDX ON AUDIO_TRANSFORMER (AUDIO_LENGTH);
""")