bunyaminergen commited on
Commit
69b92cc
·
1 Parent(s): 2dfcbff
.data/example/de.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc0c96dc62f441d166851d34dcca00f06d01a3e09337b642aa47f22af99bf6e7
3
+ size 1879413
.data/example/fr.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e46a3242bc271f598361e5797785d9e2812689761a66083503dd566e060e5b8c
3
+ size 530067
.data/example/jp.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:72b4c14e5aa897f88f7cbf130e9f689db96a67d484e1a4f7115021adb99fa3d9
3
+ size 991480
.data/example/tr.mp3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa61aa4a8d948762d4a90b4e0337de03dc68e9d13a139710abb9699dad99ef92
3
+ size 1184360
app.py CHANGED
@@ -270,15 +270,15 @@ with gr.Blocks() as demo:
270
 
271
  gr.Examples(
272
  examples=[
273
- ["examples/tr.wav"],
274
  [".data/example/en.mp3"],
275
- ["examples/jp.wav"],
276
- ["examples/fr.wav"],
277
- ["examples/de.wav"],
278
  ],
279
  inputs=audio_input,
280
  outputs=[utterance_table, file_table, output_display],
281
- label="Example Audios"
282
  )
283
 
284
 
 
270
 
271
  gr.Examples(
272
  examples=[
273
+ [".data/example/tr.mp3"],
274
  [".data/example/en.mp3"],
275
+ [".data/example/jp.mp3"],
276
+ [".data/example/fr.mp3"],
277
+ [".data/example/de.mp3"],
278
  ],
279
  inputs=audio_input,
280
  outputs=[utterance_table, file_table, output_display],
281
+ label="Example Call Center Call"
282
  )
283
 
284
 
config/config.yaml CHANGED
@@ -13,7 +13,7 @@ models:
13
  huggingface_api_key: "${HUGGINGFACE_TOKEN}"
14
 
15
  openai:
16
- model_name: "gpt-4o" # Options: "gpt-4", "gpt-4o", etc.
17
  openai_api_key: "${OPENAI_API_KEY}"
18
 
19
  azure_openai:
 
13
  huggingface_api_key: "${HUGGINGFACE_TOKEN}"
14
 
15
  openai:
16
+ model_name: "gpt-4.5-preview-2025-02-27" # Options: "gpt-4", "gpt-4o", etc.
17
  openai_api_key: "${OPENAI_API_KEY}"
18
 
19
  azure_openai:
src/db/__init__.py DELETED
File without changes
src/db/manager.py DELETED
@@ -1,149 +0,0 @@
1
- # Standard library imports
2
- import sqlite3
3
- from typing import Annotated, List, Tuple, Optional
4
-
5
-
6
- class Database:
7
- """
8
- A class to interact with an SQLite database.
9
-
10
- This class provides methods to fetch data, insert data, and handle specific
11
- tasks like fetching or inserting topic IDs in a database.
12
-
13
- Parameters
14
- ----------
15
- db_path : str
16
- The path to the SQLite database file.
17
-
18
- Attributes
19
- ----------
20
- db_path : str
21
- The path to the SQLite database file.
22
- """
23
-
24
- def __init__(self, db_path: Annotated[str, "Path to the SQLite database"]):
25
- """
26
- Initializes the Database class with the provided database path.
27
-
28
- Parameters
29
- ----------
30
- db_path : str
31
- The path to the SQLite database file.
32
- """
33
- self.db_path = db_path
34
-
35
- def fetch(
36
- self,
37
- sql_file_path: Annotated[str, "Path to the SQL file"]
38
- ) -> Annotated[List[Tuple], "Results fetched from the query"]:
39
- """
40
- Executes a SELECT query from an SQL file and fetches the results.
41
-
42
- Parameters
43
- ----------
44
- sql_file_path : str
45
- Path to the SQL file containing the SELECT query.
46
-
47
- Returns
48
- -------
49
- List[Tuple]
50
- A list of tuples representing rows returned by the query.
51
-
52
- Examples
53
- --------
54
- >>> db = Database("example.db")
55
- >>> result = db.fetch("select_query.sql")
56
- >>> print(results)
57
- [(1, 'data1'), (2, 'data2')]
58
- """
59
- with open(sql_file_path, encoding='utf-8') as f:
60
- query = f.read()
61
-
62
- conn = sqlite3.connect(self.db_path)
63
- cursor = conn.cursor()
64
- cursor.execute(query)
65
- results = cursor.fetchall()
66
- conn.close()
67
-
68
- return results
69
-
70
- def insert(
71
- self,
72
- sql_file_path: Annotated[str, "Path to the SQL file"],
73
- params: Optional[Annotated[Tuple, "Query parameters"]] = None
74
- ) -> Annotated[int, "ID of the last inserted row"]:
75
- """
76
- Executes an INSERT query from an SQL file and returns the last row ID.
77
-
78
- Parameters
79
- ----------
80
- sql_file_path : str
81
- Path to the SQL file containing the INSERT query.
82
- params : tuple, optional
83
- Parameters for the query. Defaults to None.
84
-
85
- Returns
86
- -------
87
- int
88
- The ID of the last inserted row.
89
-
90
- Examples
91
- --------
92
- >>> db = Database("example.db")
93
- >>> last_id_ = db.insert("insert_query.sql", ("value1", "value2"))
94
- >>> print(last_id)
95
- 3
96
- """
97
- with open(sql_file_path, encoding='utf-8') as f:
98
- query = f.read()
99
-
100
- conn = sqlite3.connect(self.db_path)
101
- cursor = conn.cursor()
102
- if params is not None:
103
- cursor.execute(query, params)
104
- else:
105
- cursor.execute(query)
106
- conn.commit()
107
- last_id = cursor.lastrowid
108
- conn.close()
109
- return last_id
110
-
111
- def get_or_insert_topic_id(
112
- self,
113
- detected_topic: Annotated[str, "Topic to detect or insert"],
114
- topics: Annotated[List[Tuple], "Existing topics with IDs"],
115
- db_topic_insert_path: Annotated[str, "Path to the SQL file for inserting topics"]
116
- ) -> Annotated[int, "Topic ID"]:
117
- """
118
- Fetches an existing topic ID or inserts a new one and returns its ID.
119
-
120
- Parameters
121
- ----------
122
- detected_topic : str
123
- The topic to be detected or inserted.
124
- topics : List[Tuple[int, str]]
125
- A list of existing topics as (id, name) tuples.
126
- db_topic_insert_path : str
127
- Path to the SQL file for inserting a new topic.
128
-
129
- Returns
130
- -------
131
- int
132
- The ID of the detected or newly inserted topic.
133
-
134
- Examples
135
- --------
136
- >>> db = Database("example.db")
137
- >>> topics_ = [(1, 'Python'), (2, 'SQL')]
138
- >>> topic_id_ = db.get_or_insert_topic_id("AI", topics, "insert_topic.sql")
139
- >>> print(topic_id)
140
- 3
141
- """
142
- detected_topic_lower = detected_topic.lower()
143
- topic_map = {t[1].lower(): t[0] for t in topics}
144
-
145
- if detected_topic_lower in topic_map:
146
- return topic_map[detected_topic_lower]
147
- else:
148
- topic_id = self.insert(db_topic_insert_path, (detected_topic,))
149
- return topic_id
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/db/sql/AudioPropertiesInsert.sql DELETED
@@ -1,34 +0,0 @@
1
- INSERT INTO File (Name,
2
- TopicID,
3
- Extension,
4
- Path,
5
- Rate,
6
- MinFreq,
7
- MaxFreq,
8
- BitDepth,
9
- Channels,
10
- Duration,
11
- RMSLoudness,
12
- ZeroCrossingRate,
13
- SpectralCentroid,
14
- EQ_20_250_Hz,
15
- EQ_250_2000_Hz,
16
- EQ_2000_6000_Hz,
17
- EQ_6000_20000_Hz,
18
- MFCC_1,
19
- MFCC_2,
20
- MFCC_3,
21
- MFCC_4,
22
- MFCC_5,
23
- MFCC_6,
24
- MFCC_7,
25
- MFCC_8,
26
- MFCC_9,
27
- MFCC_10,
28
- MFCC_11,
29
- MFCC_12,
30
- MFCC_13,
31
- Summary,
32
- Conflict,
33
- Silence)
34
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/db/sql/Schema.sql DELETED
@@ -1,62 +0,0 @@
1
- CREATE TABLE Topic
2
- (
3
- ID INTEGER PRIMARY KEY AUTOINCREMENT,
4
- Name TEXT NOT NULL UNIQUE CHECK (length(Name) <= 500)
5
- );
6
-
7
- INSERT INTO Topic (Name)
8
- VALUES ('Unknown');
9
-
10
- CREATE TABLE File
11
- (
12
- ID INTEGER PRIMARY KEY AUTOINCREMENT,
13
- Name TEXT NOT NULL,
14
- TopicID INTEGER,
15
- Extension TEXT,
16
- Path TEXT,
17
- Rate INTEGER,
18
- MinFreq REAL,
19
- MaxFreq REAL,
20
- BitDepth INTEGER,
21
- Channels INTEGER,
22
- Duration REAL,
23
- RMSLoudness REAL,
24
- ZeroCrossingRate REAL,
25
- SpectralCentroid REAL,
26
- EQ_20_250_Hz REAL,
27
- EQ_250_2000_Hz REAL,
28
- EQ_2000_6000_Hz REAL,
29
- EQ_6000_20000_Hz REAL,
30
- MFCC_1 REAL,
31
- MFCC_2 REAL,
32
- MFCC_3 REAL,
33
- MFCC_4 REAL,
34
- MFCC_5 REAL,
35
- MFCC_6 REAL,
36
- MFCC_7 REAL,
37
- MFCC_8 REAL,
38
- MFCC_9 REAL,
39
- MFCC_10 REAL,
40
- MFCC_11 REAL,
41
- MFCC_12 REAL,
42
- MFCC_13 REAL,
43
- Summary TEXT NOT NULL,
44
- Conflict INTEGER NOT NULL CHECK (Conflict IN (0, 1)),
45
- Silence REAL NOT NULL,
46
-
47
- FOREIGN KEY (TopicID) REFERENCES Topic (ID)
48
- );
49
-
50
- CREATE TABLE Utterance
51
- (
52
- ID INTEGER PRIMARY KEY AUTOINCREMENT,
53
- FileID INTEGER NOT NULL,
54
- Speaker TEXT CHECK (Speaker IN ('Customer', 'CSR')) NOT NULL,
55
- Sequence INTEGER NOT NULL,
56
- StartTime REAL NOT NULL,
57
- EndTime REAL NOT NULL,
58
- Content TEXT NOT NULL,
59
- Sentiment TEXT CHECK (Sentiment IN ('Neutral', 'Positive', 'Negative')) NOT NULL,
60
- Profane INTEGER NOT NULL CHECK (Profane IN (0, 1)),
61
- FOREIGN KEY (FileID) REFERENCES File (ID)
62
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/db/sql/TopicFetch.sql DELETED
@@ -1,2 +0,0 @@
1
- SELECT ID, Name
2
- FROM Topic;
 
 
 
src/db/sql/TopicInsert.sql DELETED
@@ -1,2 +0,0 @@
1
- INSERT INTO Topic (Name)
2
- VALUES (?)
 
 
 
src/db/sql/UtteranceInsert.sql DELETED
@@ -1,9 +0,0 @@
1
- INSERT INTO Utterance (FileID,
2
- Speaker,
3
- Sequence,
4
- StartTime,
5
- EndTime,
6
- Content,
7
- Sentiment,
8
- Profane)
9
- VALUES (?, ?, ?, ?, ?, ?, ?, ?);