Spaces:
Running
Running
Ved Gupta
commited on
Commit
·
12d36c7
1
Parent(s):
3dea319
ROllback added
Browse files
app/core/models/Transcribe.py
CHANGED
@@ -34,12 +34,16 @@ class TranscribeController:
|
|
34 |
self.db = database
|
35 |
|
36 |
def create(self, user_id: UUID, text: str, duration: int):
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
34 |
self.db = database
|
35 |
|
36 |
def create(self, user_id: UUID, text: str, duration: int):
|
37 |
+
try:
|
38 |
+
self.user_id = user_id
|
39 |
+
self.text = text
|
40 |
+
self.audio_duration = duration
|
41 |
+
self.transcribe_data = TranscibeInDB(
|
42 |
+
user_id=self.user_id, text=self.text, audio_duration=self.audio_duration
|
43 |
+
)
|
44 |
+
self.db.add(self.transcribe_data)
|
45 |
+
self.db.commit()
|
46 |
+
self.db.refresh(self.transcribe_data)
|
47 |
+
except Exception as e:
|
48 |
+
self.db.rollback()
|
49 |
+
raise e
|