Skip to content

Commit

Permalink
Adding improved options to resize subtitles (#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus authored Dec 29, 2024
1 parent a1a81c1 commit 6037287
Show file tree
Hide file tree
Showing 24 changed files with 801 additions and 311 deletions.
72 changes: 69 additions & 3 deletions buzz/db/dao/transcription_dao.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import uuid
from datetime import datetime
from uuid import UUID

Expand Down Expand Up @@ -31,7 +32,8 @@ def create_transcription(self, task: FileTranscriptionTask):
time_queued,
url,
whisper_model_size,
hugging_face_model_id
hugging_face_model_id,
word_level_timings
) VALUES (
:id,
:export_formats,
Expand All @@ -45,9 +47,10 @@ def create_transcription(self, task: FileTranscriptionTask):
:time_queued,
:url,
:whisper_model_size,
:hugging_face_model_id
:hugging_face_model_id,
:word_level_timings
)
"""
"""
)
query.bindValue(":id", str(task.uid))
query.bindValue(
Expand Down Expand Up @@ -82,9 +85,72 @@ def create_transcription(self, task: FileTranscriptionTask):
if task.transcription_options.model.hugging_face_model_id
else None,
)
query.bindValue(
":word_level_timings",
task.transcription_options.word_level_timings
)
if not query.exec():
raise Exception(query.lastError().text())

def copy_transcription(self, id: UUID) -> UUID:
query = self._create_query()
query.prepare("SELECT * FROM transcription WHERE id = :id")
query.bindValue(":id", str(id))
if not query.exec():
raise Exception(query.lastError().text())
if not query.next():
raise Exception("Transcription not found")

transcription_data = {field.name: query.value(field.name) for field in
self.entity.__dataclass_fields__.values()}

new_id = uuid.uuid4()
transcription_data["id"] = str(new_id)
transcription_data["time_queued"] = datetime.now().isoformat()
transcription_data["status"] = FileTranscriptionTask.Status.QUEUED.value

query.prepare(
"""
INSERT INTO transcription (
id,
export_formats,
file,
output_folder,
language,
model_type,
source,
status,
task,
time_queued,
url,
whisper_model_size,
hugging_face_model_id,
word_level_timings
) VALUES (
:id,
:export_formats,
:file,
:output_folder,
:language,
:model_type,
:source,
:status,
:task,
:time_queued,
:url,
:whisper_model_size,
:hugging_face_model_id,
:word_level_timings
)
"""
)
for key, value in transcription_data.items():
query.bindValue(f":{key}", value)
if not query.exec():
raise Exception(query.lastError().text())

return new_id

def update_transcription_as_started(self, id: UUID):
query = self._create_query()
query.prepare(
Expand Down
1 change: 1 addition & 0 deletions buzz/db/entity/transcription.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Transcription(Entity):
model_type: str = ModelType.WHISPER.value
whisper_model_size: str | None = None
hugging_face_model_id: str | None = None
word_level_timings: str | None = None
language: str | None = None
id: str = field(default_factory=lambda: str(uuid.uuid4()))
error_message: str | None = None
Expand Down
3 changes: 3 additions & 0 deletions buzz/db/service/transcription_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def __init__(
def create_transcription(self, task):
self.transcription_dao.create_transcription(task)

def copy_transcription(self, id: UUID) -> UUID:
return self.transcription_dao.copy_transcription(id)

def update_transcription_as_started(self, id: UUID):
self.transcription_dao.update_transcription_as_started(id)

Expand Down
63 changes: 41 additions & 22 deletions buzz/locale/ca_ES/LC_MESSAGES/buzz.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: buzz\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-23 22:16+0200\n"
"POT-Creation-Date: 2024-12-28 22:29+0200\n"
"PO-Revision-Date: 2023-02-15 05:01+0000\n"
"Last-Translator: Jordi Mas i Hernàndez <[email protected]>\n"
"Language-Team: Catalan <[email protected]>\n"
Expand All @@ -28,17 +28,15 @@ msgstr ""
#: buzz/widgets/preferences_dialog/preferences_dialog.py:69
#: buzz/widgets/preferences_dialog/models_preferences_widget.py:245
#: buzz/widgets/transcriber/advanced_settings_dialog.py:97
#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:295
#: buzz/widgets/main_window.py:239
#: buzz/widgets/main_window.py:244
msgid "Ok"
msgstr ""

#: buzz/widgets/import_url_dialog.py:29
#: buzz/widgets/preferences_dialog/preferences_dialog.py:70
#: buzz/widgets/preferences_dialog/models_preferences_widget.py:246
#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:296
#: buzz/widgets/model_download_progress_dialog.py:29
#: buzz/widgets/main_window.py:240
#: buzz/widgets/main_window.py:245
#, fuzzy
msgid "Cancel"
msgstr "Cancel·lat"
Expand Down Expand Up @@ -218,7 +216,7 @@ msgid "Download failed"
msgstr "Baixat"

#: buzz/widgets/preferences_dialog/models_preferences_widget.py:269
#: buzz/widgets/main_window.py:296 buzz/model_loader.py:503
#: buzz/widgets/main_window.py:301 buzz/model_loader.py:503
msgid "Error"
msgstr "Error"

Expand Down Expand Up @@ -321,25 +319,25 @@ msgstr ""
msgid "Advanced..."
msgstr ""

#: buzz/widgets/main_window_toolbar.py:41
#: buzz/widgets/main_window_toolbar.py:43
#, fuzzy
msgid "New File Transcription"
msgstr "Transcripció nova"

#: buzz/widgets/main_window_toolbar.py:48
#: buzz/widgets/main_window_toolbar.py:50
#, fuzzy
msgid "New URL Transcription"
msgstr "Transcripció nova"

#: buzz/widgets/main_window_toolbar.py:55
#: buzz/widgets/main_window_toolbar.py:57
msgid "Open Transcript"
msgstr "Obre una transcripció"

#: buzz/widgets/main_window_toolbar.py:61 buzz/settings/shortcut.py:27
#: buzz/widgets/main_window_toolbar.py:63 buzz/settings/shortcut.py:27
msgid "Cancel Transcription"
msgstr "Cancel·la la transcripció"

#: buzz/widgets/main_window_toolbar.py:69 buzz/widgets/main_window.py:228
#: buzz/widgets/main_window_toolbar.py:71 buzz/widgets/main_window.py:233
#: buzz/settings/shortcut.py:26
msgid "Clear History"
msgstr "Neteja l'historial"
Expand Down Expand Up @@ -458,33 +456,54 @@ msgstr ""
msgid "Timestamps"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:156
#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:158
msgid "Export"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:170
#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:172
#: buzz/transcriber/transcriber.py:24
msgid "Translate"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:180
#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:182
#: buzz/widgets/transcription_viewer/transcription_resizer_widget.py:90
msgid "Resize"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:279
#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:281
msgid "API Key Required"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:280
#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:282
msgid "Please enter OpenAI API Key in preferences"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:297
#: buzz/widgets/transcription_viewer/transcription_resizer_widget.py:72
msgid "Resize Options"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_resizer_widget.py:83
msgid "Desired subtitle length"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:298
msgid "Enter target characters per subtitle:"
#: buzz/widgets/transcription_viewer/transcription_resizer_widget.py:108
msgid "Merge Options"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_resizer_widget.py:119
msgid "Merge by gap"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_resizer_widget.py:127
msgid "Split by punctuation"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_resizer_widget.py:135
msgid "Split by max length"
msgstr ""

#: buzz/widgets/transcription_viewer/transcription_resizer_widget.py:147
msgid "Merge"
msgstr ""

#: buzz/widgets/transcription_viewer/export_transcription_menu.py:78
Expand Down Expand Up @@ -549,19 +568,19 @@ msgstr "Ajuda"
msgid "File"
msgstr "Fitxer"

#: buzz/widgets/main_window.py:232
#: buzz/widgets/main_window.py:237
msgid ""
"Are you sure you want to delete the selected transcription(s)? This action "
"cannot be undone."
msgstr ""
"Esteu segur que voleu suprimir les transcripcions seleccionades? Aquesta "
"acció no es pot desfer."

#: buzz/widgets/main_window.py:260
#: buzz/widgets/main_window.py:265
msgid "Select audio file"
msgstr "Selecciona un fitxer d'àudio"

#: buzz/widgets/main_window.py:296
#: buzz/widgets/main_window.py:301
msgid "Unable to save OpenAI API key to keyring"
msgstr ""

Expand Down
Loading

0 comments on commit 6037287

Please sign in to comment.