chompionsawelo commited on
Commit
59e1d08
Β·
1 Parent(s): 80086c5

Huge changes

Browse files
.gitignore CHANGED
@@ -1 +1 @@
1
- __pycache__
 
1
+ __pycache__
.vscode/PythonImportHelper-v2-Completion.json ADDED
@@ -0,0 +1,1115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "label": "*",
4
+ "importPath": "ui.ui_component",
5
+ "description": "ui.ui_component",
6
+ "isExtraImport": true,
7
+ "detail": "ui.ui_component",
8
+ "documentation": {}
9
+ },
10
+ {
11
+ "label": "*",
12
+ "importPath": "ui.ui_component",
13
+ "description": "ui.ui_component",
14
+ "isExtraImport": true,
15
+ "detail": "ui.ui_component",
16
+ "documentation": {}
17
+ },
18
+ {
19
+ "label": "*",
20
+ "importPath": "ui.ui_component",
21
+ "description": "ui.ui_component",
22
+ "isExtraImport": true,
23
+ "detail": "ui.ui_component",
24
+ "documentation": {}
25
+ },
26
+ {
27
+ "label": "current_ui_lang",
28
+ "importPath": "ui.ui_component",
29
+ "description": "ui.ui_component",
30
+ "isExtraImport": true,
31
+ "detail": "ui.ui_component",
32
+ "documentation": {}
33
+ },
34
+ {
35
+ "label": "*",
36
+ "importPath": "ui.ui_component",
37
+ "description": "ui.ui_component",
38
+ "isExtraImport": true,
39
+ "detail": "ui.ui_component",
40
+ "documentation": {}
41
+ },
42
+ {
43
+ "label": "*",
44
+ "importPath": "ui.ui_component",
45
+ "description": "ui.ui_component",
46
+ "isExtraImport": true,
47
+ "detail": "ui.ui_component",
48
+ "documentation": {}
49
+ },
50
+ {
51
+ "label": "*",
52
+ "importPath": "ui.ui_component",
53
+ "description": "ui.ui_component",
54
+ "isExtraImport": true,
55
+ "detail": "ui.ui_component",
56
+ "documentation": {}
57
+ },
58
+ {
59
+ "label": "*",
60
+ "importPath": "tool.file_name",
61
+ "description": "tool.file_name",
62
+ "isExtraImport": true,
63
+ "detail": "tool.file_name",
64
+ "documentation": {}
65
+ },
66
+ {
67
+ "label": "*",
68
+ "importPath": "tool.file_name",
69
+ "description": "tool.file_name",
70
+ "isExtraImport": true,
71
+ "detail": "tool.file_name",
72
+ "documentation": {}
73
+ },
74
+ {
75
+ "label": "*",
76
+ "importPath": "tool.file_name",
77
+ "description": "tool.file_name",
78
+ "isExtraImport": true,
79
+ "detail": "tool.file_name",
80
+ "documentation": {}
81
+ },
82
+ {
83
+ "label": "*",
84
+ "importPath": "tool.file_name",
85
+ "description": "tool.file_name",
86
+ "isExtraImport": true,
87
+ "detail": "tool.file_name",
88
+ "documentation": {}
89
+ },
90
+ {
91
+ "label": "*",
92
+ "importPath": "tool.file_name",
93
+ "description": "tool.file_name",
94
+ "isExtraImport": true,
95
+ "detail": "tool.file_name",
96
+ "documentation": {}
97
+ },
98
+ {
99
+ "label": "*",
100
+ "importPath": "tool.file_name",
101
+ "description": "tool.file_name",
102
+ "isExtraImport": true,
103
+ "detail": "tool.file_name",
104
+ "documentation": {}
105
+ },
106
+ {
107
+ "label": "*",
108
+ "importPath": "tool.file_name",
109
+ "description": "tool.file_name",
110
+ "isExtraImport": true,
111
+ "detail": "tool.file_name",
112
+ "documentation": {}
113
+ },
114
+ {
115
+ "label": "AudioSegment",
116
+ "importPath": "pydub",
117
+ "description": "pydub",
118
+ "isExtraImport": true,
119
+ "detail": "pydub",
120
+ "documentation": {}
121
+ },
122
+ {
123
+ "label": "AudioSegment",
124
+ "importPath": "pydub",
125
+ "description": "pydub",
126
+ "isExtraImport": true,
127
+ "detail": "pydub",
128
+ "documentation": {}
129
+ },
130
+ {
131
+ "label": "load_groups_json",
132
+ "importPath": "tool.json_tool",
133
+ "description": "tool.json_tool",
134
+ "isExtraImport": true,
135
+ "detail": "tool.json_tool",
136
+ "documentation": {}
137
+ },
138
+ {
139
+ "label": "load_groups_json",
140
+ "importPath": "tool.json_tool",
141
+ "description": "tool.json_tool",
142
+ "isExtraImport": true,
143
+ "detail": "tool.json_tool",
144
+ "documentation": {}
145
+ },
146
+ {
147
+ "label": "os",
148
+ "kind": 6,
149
+ "isExtraImport": true,
150
+ "importPath": "os",
151
+ "description": "os",
152
+ "detail": "os",
153
+ "documentation": {}
154
+ },
155
+ {
156
+ "label": "gradio",
157
+ "kind": 6,
158
+ "isExtraImport": true,
159
+ "importPath": "gradio",
160
+ "description": "gradio",
161
+ "detail": "gradio",
162
+ "documentation": {}
163
+ },
164
+ {
165
+ "label": "tool.text_file_tool",
166
+ "kind": 6,
167
+ "isExtraImport": true,
168
+ "importPath": "tool.text_file_tool",
169
+ "description": "tool.text_file_tool",
170
+ "detail": "tool.text_file_tool",
171
+ "documentation": {}
172
+ },
173
+ {
174
+ "label": "Pipeline",
175
+ "importPath": "pyannote.audio",
176
+ "description": "pyannote.audio",
177
+ "isExtraImport": true,
178
+ "detail": "pyannote.audio",
179
+ "documentation": {}
180
+ },
181
+ {
182
+ "label": "torch",
183
+ "kind": 6,
184
+ "isExtraImport": true,
185
+ "importPath": "torch",
186
+ "description": "torch",
187
+ "detail": "torch",
188
+ "documentation": {}
189
+ },
190
+ {
191
+ "label": "json",
192
+ "kind": 6,
193
+ "isExtraImport": true,
194
+ "importPath": "json",
195
+ "description": "json",
196
+ "detail": "json",
197
+ "documentation": {}
198
+ },
199
+ {
200
+ "label": "gc",
201
+ "kind": 6,
202
+ "isExtraImport": true,
203
+ "importPath": "gc",
204
+ "description": "gc",
205
+ "detail": "gc",
206
+ "documentation": {}
207
+ },
208
+ {
209
+ "label": "start_diarization",
210
+ "importPath": "main.diarization",
211
+ "description": "main.diarization",
212
+ "isExtraImport": true,
213
+ "detail": "main.diarization",
214
+ "documentation": {}
215
+ },
216
+ {
217
+ "label": "start_transcribe",
218
+ "importPath": "main.transcribe",
219
+ "description": "main.transcribe",
220
+ "isExtraImport": true,
221
+ "detail": "main.transcribe",
222
+ "documentation": {}
223
+ },
224
+ {
225
+ "label": "*",
226
+ "importPath": "tool.ffmpeg_tool",
227
+ "description": "tool.ffmpeg_tool",
228
+ "isExtraImport": true,
229
+ "detail": "tool.ffmpeg_tool",
230
+ "documentation": {}
231
+ },
232
+ {
233
+ "label": "re",
234
+ "kind": 6,
235
+ "isExtraImport": true,
236
+ "importPath": "re",
237
+ "description": "re",
238
+ "detail": "re",
239
+ "documentation": {}
240
+ },
241
+ {
242
+ "label": "openai",
243
+ "kind": 6,
244
+ "isExtraImport": true,
245
+ "importPath": "openai",
246
+ "description": "openai",
247
+ "detail": "openai",
248
+ "documentation": {}
249
+ },
250
+ {
251
+ "label": "tiktoken",
252
+ "kind": 6,
253
+ "isExtraImport": true,
254
+ "importPath": "tiktoken",
255
+ "description": "tiktoken",
256
+ "detail": "tiktoken",
257
+ "documentation": {}
258
+ },
259
+ {
260
+ "label": "WhisperModel",
261
+ "importPath": "faster_whisper",
262
+ "description": "faster_whisper",
263
+ "isExtraImport": true,
264
+ "detail": "faster_whisper",
265
+ "documentation": {}
266
+ },
267
+ {
268
+ "label": "ffmpeg",
269
+ "kind": 6,
270
+ "isExtraImport": true,
271
+ "importPath": "ffmpeg",
272
+ "description": "ffmpeg",
273
+ "detail": "ffmpeg",
274
+ "documentation": {}
275
+ },
276
+ {
277
+ "label": "gdown",
278
+ "kind": 6,
279
+ "isExtraImport": true,
280
+ "importPath": "gdown",
281
+ "description": "gdown",
282
+ "detail": "gdown",
283
+ "documentation": {}
284
+ },
285
+ {
286
+ "label": "get_ui_dict",
287
+ "importPath": "ui.lang_dictionary",
288
+ "description": "ui.lang_dictionary",
289
+ "isExtraImport": true,
290
+ "detail": "ui.lang_dictionary",
291
+ "documentation": {}
292
+ },
293
+ {
294
+ "label": "*",
295
+ "importPath": "ui.lang_setting",
296
+ "description": "ui.lang_setting",
297
+ "isExtraImport": true,
298
+ "detail": "ui.lang_setting",
299
+ "documentation": {}
300
+ },
301
+ {
302
+ "label": "*",
303
+ "importPath": "main.adjust",
304
+ "description": "main.adjust",
305
+ "isExtraImport": true,
306
+ "detail": "main.adjust",
307
+ "documentation": {}
308
+ },
309
+ {
310
+ "label": "prepare_input",
311
+ "importPath": "main.set_up",
312
+ "description": "main.set_up",
313
+ "isExtraImport": true,
314
+ "detail": "main.set_up",
315
+ "documentation": {}
316
+ },
317
+ {
318
+ "label": "prepare_video_subtitle",
319
+ "importPath": "main.set_up",
320
+ "description": "main.set_up",
321
+ "isExtraImport": true,
322
+ "detail": "main.set_up",
323
+ "documentation": {}
324
+ },
325
+ {
326
+ "label": "get_summary",
327
+ "importPath": "main.summary",
328
+ "description": "main.summary",
329
+ "isExtraImport": true,
330
+ "detail": "main.summary",
331
+ "documentation": {}
332
+ },
333
+ {
334
+ "label": "get_video_from_url",
335
+ "importPath": "tool.gdrive_tool",
336
+ "description": "tool.gdrive_tool",
337
+ "isExtraImport": true,
338
+ "detail": "tool.gdrive_tool",
339
+ "documentation": {}
340
+ },
341
+ {
342
+ "label": "get_current_sample_file",
343
+ "kind": 2,
344
+ "importPath": "main.adjust",
345
+ "description": "main.adjust",
346
+ "peekOfCode": "def get_current_sample_file():\n global speaker_to_name\n global speaker_to_sample_file\n print(f\"GET CURRENT speaker_to_name: {speaker_to_name}\")\n print(f\"GET CURRENT speaker_to_sample: {speaker_to_sample_file}\")\n name = list(speaker_to_name.values())[current_pos]\n sample = list(speaker_to_sample_file.values())[current_pos]\n print(f\"CURRENT: {name} {sample}\")\n return [name, sample]\ndef get_sample_file_for_speakers():",
347
+ "detail": "main.adjust",
348
+ "documentation": {}
349
+ },
350
+ {
351
+ "label": "get_sample_file_for_speakers",
352
+ "kind": 2,
353
+ "importPath": "main.adjust",
354
+ "description": "main.adjust",
355
+ "peekOfCode": "def get_sample_file_for_speakers():\n global sample_groups\n global speaker_to_name\n global speaker_to_sample_file\n sample_groups, _ = load_groups_json()\n print(f\"SAMPLE GROUP: {sample_groups}\")\n speaker_to_name = {}\n speaker_to_sample_file = {}\n for speaker in sample_groups:\n for suffix in range(1, 100):",
356
+ "detail": "main.adjust",
357
+ "documentation": {}
358
+ },
359
+ {
360
+ "label": "prepare_output",
361
+ "kind": 2,
362
+ "importPath": "main.adjust",
363
+ "description": "main.adjust",
364
+ "peekOfCode": "def prepare_output(input_file):\n if input_file is None or not os.path.exists(input_file):\n raise gr.Error(current_ui_lang[\"input_video_warning\"])\n speakers = get_sample_file_for_speakers()\n download_video_update = download_video_subtitle_button.update(\n interactive=True)\n adjust_speaker_update = adjust_speaker.update(\n speakers[0], interactive=True)\n adjust_audio_update = adjust_audio.update(\n speakers[1], interactive=True)",
365
+ "detail": "main.adjust",
366
+ "documentation": {}
367
+ },
368
+ {
369
+ "label": "change_name",
370
+ "kind": 2,
371
+ "importPath": "main.adjust",
372
+ "description": "main.adjust",
373
+ "peekOfCode": "def change_name(to_name):\n global sample_groups\n global speaker_to_name\n global current_pos\n current_speaker = sample_groups[current_pos]\n speaker_to_name[current_speaker] = to_name\n print(str(get_current_sample_file()))\ndef get_speakers_next(to_name):\n change_name(to_name)\n global sample_groups",
374
+ "detail": "main.adjust",
375
+ "documentation": {}
376
+ },
377
+ {
378
+ "label": "get_speakers_next",
379
+ "kind": 2,
380
+ "importPath": "main.adjust",
381
+ "description": "main.adjust",
382
+ "peekOfCode": "def get_speakers_next(to_name):\n change_name(to_name)\n global sample_groups\n global current_pos\n if (current_pos < len(sample_groups) - 1):\n current_pos += 1\n return get_current_sample_file()\ndef get_speakers_previous(to_name):\n change_name(to_name)\n global current_pos",
383
+ "detail": "main.adjust",
384
+ "documentation": {}
385
+ },
386
+ {
387
+ "label": "get_speakers_previous",
388
+ "kind": 2,
389
+ "importPath": "main.adjust",
390
+ "description": "main.adjust",
391
+ "peekOfCode": "def get_speakers_previous(to_name):\n change_name(to_name)\n global current_pos\n if (current_pos > 0):\n current_pos -= 1\n return get_current_sample_file()\ndef start_adjust(to_name, progress=gr.Progress()):\n change_name(to_name)\n # Replacing texts\n progress(0.4, desc=current_ui_lang[\"progress_adjust_speaker\"])",
392
+ "detail": "main.adjust",
393
+ "documentation": {}
394
+ },
395
+ {
396
+ "label": "start_adjust",
397
+ "kind": 2,
398
+ "importPath": "main.adjust",
399
+ "description": "main.adjust",
400
+ "peekOfCode": "def start_adjust(to_name, progress=gr.Progress()):\n change_name(to_name)\n # Replacing texts\n progress(0.4, desc=current_ui_lang[\"progress_adjust_speaker\"])\n transcribe_txt_list, subtitle_txt_list = text_file_tool.read_transcribe_subtitle_file(\n False)\n modified_transcribe = replace_text(transcribe_txt_list)\n modified_subtitle = replace_text(subtitle_txt_list)\n text_file_tool.write_transcribe_subtitle_file(\n modified_transcribe, modified_subtitle, True)",
401
+ "detail": "main.adjust",
402
+ "documentation": {}
403
+ },
404
+ {
405
+ "label": "replace_text",
406
+ "kind": 2,
407
+ "importPath": "main.adjust",
408
+ "description": "main.adjust",
409
+ "peekOfCode": "def replace_text(lines):\n modified_lines = []\n for line in lines:\n for key, value in speaker_to_name.items():\n line = line.replace(key, value)\n print(f\"Replacing {key} with {value}\")\n modified_lines.append(line)\n print(modified_lines)\n return modified_lines",
410
+ "detail": "main.adjust",
411
+ "documentation": {}
412
+ },
413
+ {
414
+ "label": "min_duration_ms",
415
+ "kind": 5,
416
+ "importPath": "main.adjust",
417
+ "description": "main.adjust",
418
+ "peekOfCode": "min_duration_ms = 10000\ncurrent_pos = 0\nspeaker_to_name = {\"Speaker\": \"Name\"}\nspeaker_to_sample_file = {\"Speaker\": \"File\"}\nsample_groups = []\ndef get_current_sample_file():\n global speaker_to_name\n global speaker_to_sample_file\n print(f\"GET CURRENT speaker_to_name: {speaker_to_name}\")\n print(f\"GET CURRENT speaker_to_sample: {speaker_to_sample_file}\")",
419
+ "detail": "main.adjust",
420
+ "documentation": {}
421
+ },
422
+ {
423
+ "label": "current_pos",
424
+ "kind": 5,
425
+ "importPath": "main.adjust",
426
+ "description": "main.adjust",
427
+ "peekOfCode": "current_pos = 0\nspeaker_to_name = {\"Speaker\": \"Name\"}\nspeaker_to_sample_file = {\"Speaker\": \"File\"}\nsample_groups = []\ndef get_current_sample_file():\n global speaker_to_name\n global speaker_to_sample_file\n print(f\"GET CURRENT speaker_to_name: {speaker_to_name}\")\n print(f\"GET CURRENT speaker_to_sample: {speaker_to_sample_file}\")\n name = list(speaker_to_name.values())[current_pos]",
428
+ "detail": "main.adjust",
429
+ "documentation": {}
430
+ },
431
+ {
432
+ "label": "speaker_to_name",
433
+ "kind": 5,
434
+ "importPath": "main.adjust",
435
+ "description": "main.adjust",
436
+ "peekOfCode": "speaker_to_name = {\"Speaker\": \"Name\"}\nspeaker_to_sample_file = {\"Speaker\": \"File\"}\nsample_groups = []\ndef get_current_sample_file():\n global speaker_to_name\n global speaker_to_sample_file\n print(f\"GET CURRENT speaker_to_name: {speaker_to_name}\")\n print(f\"GET CURRENT speaker_to_sample: {speaker_to_sample_file}\")\n name = list(speaker_to_name.values())[current_pos]\n sample = list(speaker_to_sample_file.values())[current_pos]",
437
+ "detail": "main.adjust",
438
+ "documentation": {}
439
+ },
440
+ {
441
+ "label": "speaker_to_sample_file",
442
+ "kind": 5,
443
+ "importPath": "main.adjust",
444
+ "description": "main.adjust",
445
+ "peekOfCode": "speaker_to_sample_file = {\"Speaker\": \"File\"}\nsample_groups = []\ndef get_current_sample_file():\n global speaker_to_name\n global speaker_to_sample_file\n print(f\"GET CURRENT speaker_to_name: {speaker_to_name}\")\n print(f\"GET CURRENT speaker_to_sample: {speaker_to_sample_file}\")\n name = list(speaker_to_name.values())[current_pos]\n sample = list(speaker_to_sample_file.values())[current_pos]\n print(f\"CURRENT: {name} {sample}\")",
446
+ "detail": "main.adjust",
447
+ "documentation": {}
448
+ },
449
+ {
450
+ "label": "sample_groups",
451
+ "kind": 5,
452
+ "importPath": "main.adjust",
453
+ "description": "main.adjust",
454
+ "peekOfCode": "sample_groups = []\ndef get_current_sample_file():\n global speaker_to_name\n global speaker_to_sample_file\n print(f\"GET CURRENT speaker_to_name: {speaker_to_name}\")\n print(f\"GET CURRENT speaker_to_sample: {speaker_to_sample_file}\")\n name = list(speaker_to_name.values())[current_pos]\n sample = list(speaker_to_sample_file.values())[current_pos]\n print(f\"CURRENT: {name} {sample}\")\n return [name, sample]",
455
+ "detail": "main.adjust",
456
+ "documentation": {}
457
+ },
458
+ {
459
+ "label": "start_diarization",
460
+ "kind": 2,
461
+ "importPath": "main.diarization",
462
+ "description": "main.diarization",
463
+ "peekOfCode": "def start_diarization(input_file):\n diarization = pipeline(input_file)\n sample_groups = []\n speaker_groups = {}\n for turn, _, speaker in diarization.itertracks(yield_label=True):\n if (speaker not in sample_groups):\n sample_groups.append(str(speaker))\n suffix = 1\n file_name = f\"{speaker}-{suffix}\"\n while file_name in speaker_groups:",
464
+ "detail": "main.diarization",
465
+ "documentation": {}
466
+ },
467
+ {
468
+ "label": "audio_segmentation",
469
+ "kind": 2,
470
+ "importPath": "main.diarization",
471
+ "description": "main.diarization",
472
+ "peekOfCode": "def audio_segmentation(input_file, speaker_groups_dict):\n audioSegment = AudioSegment.from_wav(input_file)\n for speaker in speaker_groups_dict:\n time = speaker_groups_dict[speaker]\n audioSegment[time[0]*1000: time[1] *\n 1000].export(f\"{speaker}.wav\", format='wav')\n print(f\"group {speaker}: {time[0]*1000}--{time[1]*1000}\")\ndef save_groups_json(input_file, sample_groups_list: list, speaker_groups_dict: dict):\n with open(dir_sample_groups_json, \"w\", encoding=\"utf-8\") as json_file_sample:\n json.dump(sample_groups_list, json_file_sample)",
473
+ "detail": "main.diarization",
474
+ "documentation": {}
475
+ },
476
+ {
477
+ "label": "save_groups_json",
478
+ "kind": 2,
479
+ "importPath": "main.diarization",
480
+ "description": "main.diarization",
481
+ "peekOfCode": "def save_groups_json(input_file, sample_groups_list: list, speaker_groups_dict: dict):\n with open(dir_sample_groups_json, \"w\", encoding=\"utf-8\") as json_file_sample:\n json.dump(sample_groups_list, json_file_sample)\n with open(dir_speaker_groups_json, \"w\", encoding=\"utf-8\") as json_file_speaker:\n json.dump(speaker_groups_dict, json_file_speaker)",
482
+ "detail": "main.diarization",
483
+ "documentation": {}
484
+ },
485
+ {
486
+ "label": "hugging_face_token",
487
+ "kind": 5,
488
+ "importPath": "main.diarization",
489
+ "description": "main.diarization",
490
+ "peekOfCode": "hugging_face_token = \"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\"\npipeline = Pipeline.from_pretrained(\n 'pyannote/speaker-diarization', use_auth_token=hugging_face_token)\nuse_device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\npipeline.to(use_device)\ndef start_diarization(input_file):\n diarization = pipeline(input_file)\n sample_groups = []\n speaker_groups = {}\n for turn, _, speaker in diarization.itertracks(yield_label=True):",
491
+ "detail": "main.diarization",
492
+ "documentation": {}
493
+ },
494
+ {
495
+ "label": "pipeline",
496
+ "kind": 5,
497
+ "importPath": "main.diarization",
498
+ "description": "main.diarization",
499
+ "peekOfCode": "pipeline = Pipeline.from_pretrained(\n 'pyannote/speaker-diarization', use_auth_token=hugging_face_token)\nuse_device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\npipeline.to(use_device)\ndef start_diarization(input_file):\n diarization = pipeline(input_file)\n sample_groups = []\n speaker_groups = {}\n for turn, _, speaker in diarization.itertracks(yield_label=True):\n if (speaker not in sample_groups):",
500
+ "detail": "main.diarization",
501
+ "documentation": {}
502
+ },
503
+ {
504
+ "label": "use_device",
505
+ "kind": 5,
506
+ "importPath": "main.diarization",
507
+ "description": "main.diarization",
508
+ "peekOfCode": "use_device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\npipeline.to(use_device)\ndef start_diarization(input_file):\n diarization = pipeline(input_file)\n sample_groups = []\n speaker_groups = {}\n for turn, _, speaker in diarization.itertracks(yield_label=True):\n if (speaker not in sample_groups):\n sample_groups.append(str(speaker))\n suffix = 1",
509
+ "detail": "main.diarization",
510
+ "documentation": {}
511
+ },
512
+ {
513
+ "label": "prepare_input",
514
+ "kind": 2,
515
+ "importPath": "main.set_up",
516
+ "description": "main.set_up",
517
+ "peekOfCode": "def prepare_input(input_file, start_time, end_time, lang, model_size, progress=gr.Progress()):\n gr.Info(current_ui_lang[\"progress_starting_process\"])\n check_input_video_settings(input_file, start_time, end_time)\n if lang is None:\n raise gr.Error(current_ui_lang[\"lang_radio_warning\"])\n if model_size is None:\n raise gr.Error(current_ui_lang[\"model_dropdown_warning\"])\n print(f\"SOURCE: {input_file}\")\n # Convert video to audio\n progress(0.2, desc=current_ui_lang[\"progress_preparing_video\"])",
518
+ "detail": "main.set_up",
519
+ "documentation": {}
520
+ },
521
+ {
522
+ "label": "prepare_video_subtitle",
523
+ "kind": 2,
524
+ "importPath": "main.set_up",
525
+ "description": "main.set_up",
526
+ "peekOfCode": "def prepare_video_subtitle(input_file, start_time, end_time):\n check_input_video_settings(input_file, start_time, end_time)\n gr.Info(current_ui_lang[\"progress_add_subtitle\"])\n # Add subtitle to video\n add_subtitle_to_video()\n # Return to output files\n return [dir_base_transcribe_file, dir_base_subtitle_file, dir_video_subtitle_file]\ndef check_input_video_settings(input_file, start_time, end_time):\n if input_file is None or not os.path.exists(input_file):\n raise gr.Error(current_ui_lang[\"input_video_warning\"])",
527
+ "detail": "main.set_up",
528
+ "documentation": {}
529
+ },
530
+ {
531
+ "label": "check_input_video_settings",
532
+ "kind": 2,
533
+ "importPath": "main.set_up",
534
+ "description": "main.set_up",
535
+ "peekOfCode": "def check_input_video_settings(input_file, start_time, end_time):\n if input_file is None or not os.path.exists(input_file):\n raise gr.Error(current_ui_lang[\"input_video_warning\"])\n if validate_time_format(start_time) is False:\n raise gr.Error(current_ui_lang[\"start_time_warning\"])\n if validate_time_format(end_time) is False:\n raise gr.Error(current_ui_lang[\"end_time_warning\"])\n if (check_if_time_invalid(start_time, end_time)):\n raise gr.Error(current_ui_lang[\"time_invalid\"])\ndef validate_time_format(input_string):",
536
+ "detail": "main.set_up",
537
+ "documentation": {}
538
+ },
539
+ {
540
+ "label": "validate_time_format",
541
+ "kind": 2,
542
+ "importPath": "main.set_up",
543
+ "description": "main.set_up",
544
+ "peekOfCode": "def validate_time_format(input_string):\n pattern = re.compile(r'^\\d{2}:\\d{2}:\\d{2}$')\n return pattern.match(input_string) is not None\ndef check_if_time_invalid(start_time, end_time):\n start = get_total_seconds(start_time)\n end = get_total_seconds(end_time)\n return start >= end\ndef get_total_seconds(time_string):\n hours, minutes, seconds = map(int, time_string.split(\":\"))\n total_seconds = hours * 3600 + minutes * 60 + seconds",
545
+ "detail": "main.set_up",
546
+ "documentation": {}
547
+ },
548
+ {
549
+ "label": "check_if_time_invalid",
550
+ "kind": 2,
551
+ "importPath": "main.set_up",
552
+ "description": "main.set_up",
553
+ "peekOfCode": "def check_if_time_invalid(start_time, end_time):\n start = get_total_seconds(start_time)\n end = get_total_seconds(end_time)\n return start >= end\ndef get_total_seconds(time_string):\n hours, minutes, seconds = map(int, time_string.split(\":\"))\n total_seconds = hours * 3600 + minutes * 60 + seconds\n return total_seconds",
554
+ "detail": "main.set_up",
555
+ "documentation": {}
556
+ },
557
+ {
558
+ "label": "get_total_seconds",
559
+ "kind": 2,
560
+ "importPath": "main.set_up",
561
+ "description": "main.set_up",
562
+ "peekOfCode": "def get_total_seconds(time_string):\n hours, minutes, seconds = map(int, time_string.split(\":\"))\n total_seconds = hours * 3600 + minutes * 60 + seconds\n return total_seconds",
563
+ "detail": "main.set_up",
564
+ "documentation": {}
565
+ },
566
+ {
567
+ "label": "get_summary",
568
+ "kind": 2,
569
+ "importPath": "main.summary",
570
+ "description": "main.summary",
571
+ "peekOfCode": "def get_summary(lang_choice: int):\n transcribe_list = text_file_tool.read_simple_transcribe_file()\n transcribe = \"\\n\".join(transcribe_list)\n encoding = tiktoken.get_encoding(\"cl100k_base\")\n token_num = len(encoding.encode(transcribe))\n print(f\"Token number is {token_num}\")\n language = [\"English\", \"Bahasa Indonesia\", \"Any\"]\n result = openai.ChatCompletion.create(\n model=\"gpt-3.5-turbo\" if token_num < 4097 else \"gpt-3.5-turbo-16k\",\n messages=[",
572
+ "detail": "main.summary",
573
+ "documentation": {}
574
+ },
575
+ {
576
+ "label": "openai.api_key",
577
+ "kind": 5,
578
+ "importPath": "main.summary",
579
+ "description": "main.summary",
580
+ "peekOfCode": "openai.api_key = \"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\"\ndef get_summary(lang_choice: int):\n transcribe_list = text_file_tool.read_simple_transcribe_file()\n transcribe = \"\\n\".join(transcribe_list)\n encoding = tiktoken.get_encoding(\"cl100k_base\")\n token_num = len(encoding.encode(transcribe))\n print(f\"Token number is {token_num}\")\n language = [\"English\", \"Bahasa Indonesia\", \"Any\"]\n result = openai.ChatCompletion.create(\n model=\"gpt-3.5-turbo\" if token_num < 4097 else \"gpt-3.5-turbo-16k\",",
581
+ "detail": "main.summary",
582
+ "documentation": {}
583
+ },
584
+ {
585
+ "label": "start_transcribe",
586
+ "kind": 2,
587
+ "importPath": "main.transcribe",
588
+ "description": "main.transcribe",
589
+ "peekOfCode": "def start_transcribe(lang_choice: int, model_size_choice: int, progress):\n print(\n f\"Starting transcribing with model size {model_size[model_size_choice]} for language {model_lang_list[lang_choice]}\")\n model = WhisperModel(model_size[model_size_choice])\n _, speaker_groups = load_groups_json()\n subtitle_txt_list = []\n transcribe_txt_list = []\n simple_transcribe_txt_list = []\n for speaker, _ in zip(speaker_groups, progress.tqdm(speaker_groups, desc=current_ui_lang[\"progress_transcribing_audio\"])):\n # Transcribe and save temp file",
590
+ "detail": "main.transcribe",
591
+ "documentation": {}
592
+ },
593
+ {
594
+ "label": "time_str_subtitle",
595
+ "kind": 2,
596
+ "importPath": "main.transcribe",
597
+ "description": "main.transcribe",
598
+ "peekOfCode": "def time_str_subtitle(t):\n return '{0:02d}:{1:02d}:{2:06.3f}'.format(round(t // 3600),\n round(t % 3600 // 60),\n t % 60)\ndef time_str(t):\n return '{0:02d}:{1:02d}:{2:02d}'.format(round(t // 3600),\n round(t % 3600 // 60),\n round(t % 60))",
599
+ "detail": "main.transcribe",
600
+ "documentation": {}
601
+ },
602
+ {
603
+ "label": "time_str",
604
+ "kind": 2,
605
+ "importPath": "main.transcribe",
606
+ "description": "main.transcribe",
607
+ "peekOfCode": "def time_str(t):\n return '{0:02d}:{1:02d}:{2:02d}'.format(round(t // 3600),\n round(t % 3600 // 60),\n round(t % 60))",
608
+ "detail": "main.transcribe",
609
+ "documentation": {}
610
+ },
611
+ {
612
+ "label": "model_lang_list",
613
+ "kind": 5,
614
+ "importPath": "main.transcribe",
615
+ "description": "main.transcribe",
616
+ "peekOfCode": "model_lang_list = ['en', 'id', None]\nmodel_size = [\"tiny\", \"base\", \"small\", \"medium\", \"large-v2\"]\ndef start_transcribe(lang_choice: int, model_size_choice: int, progress):\n print(\n f\"Starting transcribing with model size {model_size[model_size_choice]} for language {model_lang_list[lang_choice]}\")\n model = WhisperModel(model_size[model_size_choice])\n _, speaker_groups = load_groups_json()\n subtitle_txt_list = []\n transcribe_txt_list = []\n simple_transcribe_txt_list = []",
617
+ "detail": "main.transcribe",
618
+ "documentation": {}
619
+ },
620
+ {
621
+ "label": "model_size",
622
+ "kind": 5,
623
+ "importPath": "main.transcribe",
624
+ "description": "main.transcribe",
625
+ "peekOfCode": "model_size = [\"tiny\", \"base\", \"small\", \"medium\", \"large-v2\"]\ndef start_transcribe(lang_choice: int, model_size_choice: int, progress):\n print(\n f\"Starting transcribing with model size {model_size[model_size_choice]} for language {model_lang_list[lang_choice]}\")\n model = WhisperModel(model_size[model_size_choice])\n _, speaker_groups = load_groups_json()\n subtitle_txt_list = []\n transcribe_txt_list = []\n simple_transcribe_txt_list = []\n for speaker, _ in zip(speaker_groups, progress.tqdm(speaker_groups, desc=current_ui_lang[\"progress_transcribing_audio\"])):",
626
+ "detail": "main.transcribe",
627
+ "documentation": {}
628
+ },
629
+ {
630
+ "label": "convert_video_to_audio",
631
+ "kind": 2,
632
+ "importPath": "tool.ffmpeg_tool",
633
+ "description": "tool.ffmpeg_tool",
634
+ "peekOfCode": "def convert_video_to_audio(input_file, start_time, end_time):\n print(\"CONVERTING VIDEO TO AUDIO\")\n print(f\"INPUT: {input_file}\")\n print(f\"OUTPUT: {dir_cut_audio_file}\")\n (\n ffmpeg\n .input(input_file)\n .output(dir_cut_audio_file, ss=start_time, to=end_time, format=\"wav\", acodec='pcm_s16le')\n .run(overwrite_output=True)\n )",
635
+ "detail": "tool.ffmpeg_tool",
636
+ "documentation": {}
637
+ },
638
+ {
639
+ "label": "cut_video",
640
+ "kind": 2,
641
+ "importPath": "tool.ffmpeg_tool",
642
+ "description": "tool.ffmpeg_tool",
643
+ "peekOfCode": "def cut_video(input_file, start_time, end_time):\n print(\"CUTTING VIDEO\")\n print(f\"INPUT: {input_file}\")\n print(f\"OUTPUT: {dir_cut_video_file}\")\n (\n ffmpeg\n .input(input_file)\n .output(dir_cut_video_file, ss=start_time, to=end_time, acodec='copy', vcodec='copy')\n .run(overwrite_output=True)\n )",
644
+ "detail": "tool.ffmpeg_tool",
645
+ "documentation": {}
646
+ },
647
+ {
648
+ "label": "add_subtitle_to_video",
649
+ "kind": 2,
650
+ "importPath": "tool.ffmpeg_tool",
651
+ "description": "tool.ffmpeg_tool",
652
+ "peekOfCode": "def add_subtitle_to_video():\n print(\"ADDING SUBTITLE\")\n print(f\"SUBTITLE: {dir_adjusted_subtitle_file}\")\n print(f\"OUTPUT: {dir_video_subtitle_file}\")\n (\n ffmpeg\n .input(dir_cut_video_file)\n .output(dir_video_subtitle_file, vf=f'subtitles={dir_adjusted_subtitle_file}', acodec='copy')\n .run(overwrite_output=True)\n )",
653
+ "detail": "tool.ffmpeg_tool",
654
+ "documentation": {}
655
+ },
656
+ {
657
+ "label": "dir_download_file",
658
+ "kind": 5,
659
+ "importPath": "tool.file_name",
660
+ "description": "tool.file_name",
661
+ "peekOfCode": "dir_download_file = \"download_video.mp4\"\ndir_cut_audio_file = \"cut_audio.wav\"\ndir_cut_video_file = \"cut_video.mp4\"\n# BASE FILE CREATED ONLY ONCE\ndir_base_subtitle_file = \"subtitle.srt\"\ndir_base_transcribe_file = \"transcribe.txt\"\ndir_adjusted_subtitle_file = \"subtitle_adjusted.srt\"\ndir_adjusted_transcribe_file = \"transcribe_adjusted.txt\"\ndir_video_subtitle_file = \"video_subtitle.mp4\"\ndir_sample_groups_json = \"sample_groups.json\"",
662
+ "detail": "tool.file_name",
663
+ "documentation": {}
664
+ },
665
+ {
666
+ "label": "dir_cut_audio_file",
667
+ "kind": 5,
668
+ "importPath": "tool.file_name",
669
+ "description": "tool.file_name",
670
+ "peekOfCode": "dir_cut_audio_file = \"cut_audio.wav\"\ndir_cut_video_file = \"cut_video.mp4\"\n# BASE FILE CREATED ONLY ONCE\ndir_base_subtitle_file = \"subtitle.srt\"\ndir_base_transcribe_file = \"transcribe.txt\"\ndir_adjusted_subtitle_file = \"subtitle_adjusted.srt\"\ndir_adjusted_transcribe_file = \"transcribe_adjusted.txt\"\ndir_video_subtitle_file = \"video_subtitle.mp4\"\ndir_sample_groups_json = \"sample_groups.json\"\ndir_speaker_groups_json = \"speaker_groups.json\"",
671
+ "detail": "tool.file_name",
672
+ "documentation": {}
673
+ },
674
+ {
675
+ "label": "dir_cut_video_file",
676
+ "kind": 5,
677
+ "importPath": "tool.file_name",
678
+ "description": "tool.file_name",
679
+ "peekOfCode": "dir_cut_video_file = \"cut_video.mp4\"\n# BASE FILE CREATED ONLY ONCE\ndir_base_subtitle_file = \"subtitle.srt\"\ndir_base_transcribe_file = \"transcribe.txt\"\ndir_adjusted_subtitle_file = \"subtitle_adjusted.srt\"\ndir_adjusted_transcribe_file = \"transcribe_adjusted.txt\"\ndir_video_subtitle_file = \"video_subtitle.mp4\"\ndir_sample_groups_json = \"sample_groups.json\"\ndir_speaker_groups_json = \"speaker_groups.json\"\ndir_simple_transcribe_file = \"simple_transcribe.txt\"",
680
+ "detail": "tool.file_name",
681
+ "documentation": {}
682
+ },
683
+ {
684
+ "label": "dir_base_subtitle_file",
685
+ "kind": 5,
686
+ "importPath": "tool.file_name",
687
+ "description": "tool.file_name",
688
+ "peekOfCode": "dir_base_subtitle_file = \"subtitle.srt\"\ndir_base_transcribe_file = \"transcribe.txt\"\ndir_adjusted_subtitle_file = \"subtitle_adjusted.srt\"\ndir_adjusted_transcribe_file = \"transcribe_adjusted.txt\"\ndir_video_subtitle_file = \"video_subtitle.mp4\"\ndir_sample_groups_json = \"sample_groups.json\"\ndir_speaker_groups_json = \"speaker_groups.json\"\ndir_simple_transcribe_file = \"simple_transcribe.txt\"",
689
+ "detail": "tool.file_name",
690
+ "documentation": {}
691
+ },
692
+ {
693
+ "label": "dir_base_transcribe_file",
694
+ "kind": 5,
695
+ "importPath": "tool.file_name",
696
+ "description": "tool.file_name",
697
+ "peekOfCode": "dir_base_transcribe_file = \"transcribe.txt\"\ndir_adjusted_subtitle_file = \"subtitle_adjusted.srt\"\ndir_adjusted_transcribe_file = \"transcribe_adjusted.txt\"\ndir_video_subtitle_file = \"video_subtitle.mp4\"\ndir_sample_groups_json = \"sample_groups.json\"\ndir_speaker_groups_json = \"speaker_groups.json\"\ndir_simple_transcribe_file = \"simple_transcribe.txt\"",
698
+ "detail": "tool.file_name",
699
+ "documentation": {}
700
+ },
701
+ {
702
+ "label": "dir_adjusted_subtitle_file",
703
+ "kind": 5,
704
+ "importPath": "tool.file_name",
705
+ "description": "tool.file_name",
706
+ "peekOfCode": "dir_adjusted_subtitle_file = \"subtitle_adjusted.srt\"\ndir_adjusted_transcribe_file = \"transcribe_adjusted.txt\"\ndir_video_subtitle_file = \"video_subtitle.mp4\"\ndir_sample_groups_json = \"sample_groups.json\"\ndir_speaker_groups_json = \"speaker_groups.json\"\ndir_simple_transcribe_file = \"simple_transcribe.txt\"",
707
+ "detail": "tool.file_name",
708
+ "documentation": {}
709
+ },
710
+ {
711
+ "label": "dir_adjusted_transcribe_file",
712
+ "kind": 5,
713
+ "importPath": "tool.file_name",
714
+ "description": "tool.file_name",
715
+ "peekOfCode": "dir_adjusted_transcribe_file = \"transcribe_adjusted.txt\"\ndir_video_subtitle_file = \"video_subtitle.mp4\"\ndir_sample_groups_json = \"sample_groups.json\"\ndir_speaker_groups_json = \"speaker_groups.json\"\ndir_simple_transcribe_file = \"simple_transcribe.txt\"",
716
+ "detail": "tool.file_name",
717
+ "documentation": {}
718
+ },
719
+ {
720
+ "label": "dir_video_subtitle_file",
721
+ "kind": 5,
722
+ "importPath": "tool.file_name",
723
+ "description": "tool.file_name",
724
+ "peekOfCode": "dir_video_subtitle_file = \"video_subtitle.mp4\"\ndir_sample_groups_json = \"sample_groups.json\"\ndir_speaker_groups_json = \"speaker_groups.json\"\ndir_simple_transcribe_file = \"simple_transcribe.txt\"",
725
+ "detail": "tool.file_name",
726
+ "documentation": {}
727
+ },
728
+ {
729
+ "label": "dir_sample_groups_json",
730
+ "kind": 5,
731
+ "importPath": "tool.file_name",
732
+ "description": "tool.file_name",
733
+ "peekOfCode": "dir_sample_groups_json = \"sample_groups.json\"\ndir_speaker_groups_json = \"speaker_groups.json\"\ndir_simple_transcribe_file = \"simple_transcribe.txt\"",
734
+ "detail": "tool.file_name",
735
+ "documentation": {}
736
+ },
737
+ {
738
+ "label": "dir_speaker_groups_json",
739
+ "kind": 5,
740
+ "importPath": "tool.file_name",
741
+ "description": "tool.file_name",
742
+ "peekOfCode": "dir_speaker_groups_json = \"speaker_groups.json\"\ndir_simple_transcribe_file = \"simple_transcribe.txt\"",
743
+ "detail": "tool.file_name",
744
+ "documentation": {}
745
+ },
746
+ {
747
+ "label": "dir_simple_transcribe_file",
748
+ "kind": 5,
749
+ "importPath": "tool.file_name",
750
+ "description": "tool.file_name",
751
+ "peekOfCode": "dir_simple_transcribe_file = \"simple_transcribe.txt\"",
752
+ "detail": "tool.file_name",
753
+ "documentation": {}
754
+ },
755
+ {
756
+ "label": "get_video_from_url",
757
+ "kind": 2,
758
+ "importPath": "tool.gdrive_tool",
759
+ "description": "tool.gdrive_tool",
760
+ "peekOfCode": "def get_video_from_url(url):\n # Download video from google drive with shareable link\n gr.Info(current_ui_lang[\"get_video_start_info\"])\n download_result = gdown.download(\n url, dir_download_file, quiet=False, fuzzy=True)\n # Raise error if failed\n if (download_result is None):\n raise gr.Error(current_ui_lang[\"get_video_fail_info\"])\n gr.Info(current_ui_lang[\"get_video_finished_info\"])\n return dir_download_file",
761
+ "detail": "tool.gdrive_tool",
762
+ "documentation": {}
763
+ },
764
+ {
765
+ "label": "load_groups_json",
766
+ "kind": 2,
767
+ "importPath": "tool.json_tool",
768
+ "description": "tool.json_tool",
769
+ "peekOfCode": "def load_groups_json():\n if not os.path.exists(dir_sample_groups_json) or not os.path.exists(dir_speaker_groups_json):\n print(\"JSON file doesn't exist\")\n return [], {}\n with open(dir_sample_groups_json, \"r\", encoding=\"utf-8\") as json_file_sample:\n sample_groups_list: list = json.load(json_file_sample)\n with open(dir_speaker_groups_json, \"r\", encoding=\"utf-8\") as json_file_speaker:\n speaker_groups_dict: dict = json.load(json_file_speaker)\n return sample_groups_list, speaker_groups_dict",
770
+ "detail": "tool.json_tool",
771
+ "documentation": {}
772
+ },
773
+ {
774
+ "label": "write_simple_transcribe_file",
775
+ "kind": 2,
776
+ "importPath": "tool.text_file_tool",
777
+ "description": "tool.text_file_tool",
778
+ "peekOfCode": "def write_simple_transcribe_file(simple_transcribe_txt_list: list):\n with open(dir_simple_transcribe_file, \"w\", encoding=\"utf-8\") as file:\n file.writelines(simple_transcribe_txt_list)\ndef read_simple_transcribe_file():\n with open(dir_simple_transcribe_file, \"r\", encoding=\"utf-8\") as file:\n simple_transcribe_txt_list = file.readlines()\n return simple_transcribe_txt_list\ndef write_transcribe_subtitle_file(transcribe_txt_list: list, subtitle_txt_list: list, write_adjusted_file: bool):\n transcribe = dir_base_transcribe_file\n subtitle = dir_base_subtitle_file",
779
+ "detail": "tool.text_file_tool",
780
+ "documentation": {}
781
+ },
782
+ {
783
+ "label": "read_simple_transcribe_file",
784
+ "kind": 2,
785
+ "importPath": "tool.text_file_tool",
786
+ "description": "tool.text_file_tool",
787
+ "peekOfCode": "def read_simple_transcribe_file():\n with open(dir_simple_transcribe_file, \"r\", encoding=\"utf-8\") as file:\n simple_transcribe_txt_list = file.readlines()\n return simple_transcribe_txt_list\ndef write_transcribe_subtitle_file(transcribe_txt_list: list, subtitle_txt_list: list, write_adjusted_file: bool):\n transcribe = dir_base_transcribe_file\n subtitle = dir_base_subtitle_file\n if write_adjusted_file:\n transcribe = dir_adjusted_transcribe_file\n subtitle = dir_adjusted_subtitle_file",
788
+ "detail": "tool.text_file_tool",
789
+ "documentation": {}
790
+ },
791
+ {
792
+ "label": "write_transcribe_subtitle_file",
793
+ "kind": 2,
794
+ "importPath": "tool.text_file_tool",
795
+ "description": "tool.text_file_tool",
796
+ "peekOfCode": "def write_transcribe_subtitle_file(transcribe_txt_list: list, subtitle_txt_list: list, write_adjusted_file: bool):\n transcribe = dir_base_transcribe_file\n subtitle = dir_base_subtitle_file\n if write_adjusted_file:\n transcribe = dir_adjusted_transcribe_file\n subtitle = dir_adjusted_subtitle_file\n with open(transcribe, \"w\", encoding=\"utf-8\") as file:\n file.writelines(transcribe_txt_list)\n with open(subtitle, \"w\", encoding=\"utf-8\") as file:\n file.writelines(subtitle_txt_list)",
797
+ "detail": "tool.text_file_tool",
798
+ "documentation": {}
799
+ },
800
+ {
801
+ "label": "read_transcribe_subtitle_file",
802
+ "kind": 2,
803
+ "importPath": "tool.text_file_tool",
804
+ "description": "tool.text_file_tool",
805
+ "peekOfCode": "def read_transcribe_subtitle_file(read_adjusted_file: bool):\n transcribe = dir_base_transcribe_file\n subtitle = dir_base_subtitle_file\n if read_adjusted_file:\n transcribe = dir_adjusted_transcribe_file\n subtitle = dir_adjusted_subtitle_file\n if not os.path.exists(transcribe):\n raise gr.Error(current_ui_lang[\"file_not_exist\"] + \": Transcribe\")\n if not os.path.exists(subtitle):\n raise gr.Error(current_ui_lang[\"file_not_exist\"] + \": Subtitle\")",
806
+ "detail": "tool.text_file_tool",
807
+ "documentation": {}
808
+ },
809
+ {
810
+ "label": "get_ui_dict",
811
+ "kind": 2,
812
+ "importPath": "ui.lang_dictionary",
813
+ "description": "ui.lang_dictionary",
814
+ "peekOfCode": "def get_ui_dict(index):\n selectable_ui_lang = [english_ui, indonesia_ui]\n return selectable_ui_lang[index]\nenglish_ui = {\n \"top_markdown\": \"\"\"\n ## Transcribe\n Insert your video and set the options for transcribing\n \"\"\",\n \"middle_markdown\": \"\"\"\n ## Adjustment",
815
+ "detail": "ui.lang_dictionary",
816
+ "documentation": {}
817
+ },
818
+ {
819
+ "label": "english_ui",
820
+ "kind": 5,
821
+ "importPath": "ui.lang_dictionary",
822
+ "description": "ui.lang_dictionary",
823
+ "peekOfCode": "english_ui = {\n \"top_markdown\": \"\"\"\n ## Transcribe\n Insert your video and set the options for transcribing\n \"\"\",\n \"middle_markdown\": \"\"\"\n ## Adjustment\n Listen to the clips below and type in the name according to the speaker's sound. After that, please click the 'Adjust Speaker' button to adjust the result above accordingly. \n \"\"\",\n \"bottom_markdown\": \"\"\"",
824
+ "detail": "ui.lang_dictionary",
825
+ "documentation": {}
826
+ },
827
+ {
828
+ "label": "indonesia_ui",
829
+ "kind": 5,
830
+ "importPath": "ui.lang_dictionary",
831
+ "description": "ui.lang_dictionary",
832
+ "peekOfCode": "indonesia_ui = {\n \"top_markdown\": \"\"\"\n ## Transkrip\n Masukkan video dan sesuaikan opsi untuk transkrip\n \"\"\",\n \"middle_markdown\": \"\"\"\n ## Penyesuaian\n Dengarkan cuplikan suara pembicara dan ubah nama sesuai suara pembicara. Setelah itu, silahkan tekan tombol 'Sesuaikan Pembicara' untuk menyesuaikan nama pembicara pada hasil di atas\n \"\"\",\n \"bottom_markdown\": \"\"\"",
833
+ "detail": "ui.lang_dictionary",
834
+ "documentation": {}
835
+ },
836
+ {
837
+ "label": "change_lang",
838
+ "kind": 2,
839
+ "importPath": "ui.lang_setting",
840
+ "description": "ui.lang_setting",
841
+ "peekOfCode": "def change_lang(input):\n # Change language function\n global current_ui_lang\n current_ui_lang = get_ui_dict(input)\n print(f\"Change language to {available_ui_lang[input]}\")\n return [\n # Top\n top_markdown.update(\n current_ui_lang[\"top_markdown\"]),\n input_url.update(",
842
+ "detail": "ui.lang_setting",
843
+ "documentation": {}
844
+ },
845
+ {
846
+ "label": "comp_to_update",
847
+ "kind": 5,
848
+ "importPath": "ui.lang_setting",
849
+ "description": "ui.lang_setting",
850
+ "peekOfCode": "comp_to_update = [\n top_markdown,\n input_url,\n url_download_button,\n input_video,\n start_time,\n end_time,\n lang_radio,\n model_dropdown,\n start_button,",
851
+ "detail": "ui.lang_setting",
852
+ "documentation": {}
853
+ },
854
+ {
855
+ "label": "ui_lang_index",
856
+ "kind": 5,
857
+ "importPath": "ui.ui_component",
858
+ "description": "ui.ui_component",
859
+ "peekOfCode": "ui_lang_index = 1\navailable_ui_lang = [\"English\", \"Bahasa Indonesia\"]\ncurrent_ui_lang = get_ui_dict(ui_lang_index)\nlang_radio_choice = 1\nmodel_dropdown_choice = 2\n# Transcribe components\nui_lang_radio = gr.Radio(\n available_ui_lang, type=\"index\", value=available_ui_lang[ui_lang_index], interactive=True, show_label=False)\ntop_markdown = gr.Markdown(\n current_ui_lang[\"top_markdown\"])",
860
+ "detail": "ui.ui_component",
861
+ "documentation": {}
862
+ },
863
+ {
864
+ "label": "available_ui_lang",
865
+ "kind": 5,
866
+ "importPath": "ui.ui_component",
867
+ "description": "ui.ui_component",
868
+ "peekOfCode": "available_ui_lang = [\"English\", \"Bahasa Indonesia\"]\ncurrent_ui_lang = get_ui_dict(ui_lang_index)\nlang_radio_choice = 1\nmodel_dropdown_choice = 2\n# Transcribe components\nui_lang_radio = gr.Radio(\n available_ui_lang, type=\"index\", value=available_ui_lang[ui_lang_index], interactive=True, show_label=False)\ntop_markdown = gr.Markdown(\n current_ui_lang[\"top_markdown\"])\ninput_url = gr.Textbox(",
869
+ "detail": "ui.ui_component",
870
+ "documentation": {}
871
+ },
872
+ {
873
+ "label": "current_ui_lang",
874
+ "kind": 5,
875
+ "importPath": "ui.ui_component",
876
+ "description": "ui.ui_component",
877
+ "peekOfCode": "current_ui_lang = get_ui_dict(ui_lang_index)\nlang_radio_choice = 1\nmodel_dropdown_choice = 2\n# Transcribe components\nui_lang_radio = gr.Radio(\n available_ui_lang, type=\"index\", value=available_ui_lang[ui_lang_index], interactive=True, show_label=False)\ntop_markdown = gr.Markdown(\n current_ui_lang[\"top_markdown\"])\ninput_url = gr.Textbox(\n max_lines=1, label=current_ui_lang[\"input_url_label\"], info=current_ui_lang[\"input_url_info\"], interactive=True)",
878
+ "detail": "ui.ui_component",
879
+ "documentation": {}
880
+ },
881
+ {
882
+ "label": "lang_radio_choice",
883
+ "kind": 5,
884
+ "importPath": "ui.ui_component",
885
+ "description": "ui.ui_component",
886
+ "peekOfCode": "lang_radio_choice = 1\nmodel_dropdown_choice = 2\n# Transcribe components\nui_lang_radio = gr.Radio(\n available_ui_lang, type=\"index\", value=available_ui_lang[ui_lang_index], interactive=True, show_label=False)\ntop_markdown = gr.Markdown(\n current_ui_lang[\"top_markdown\"])\ninput_url = gr.Textbox(\n max_lines=1, label=current_ui_lang[\"input_url_label\"], info=current_ui_lang[\"input_url_info\"], interactive=True)\nurl_download_button = gr.Button(",
887
+ "detail": "ui.ui_component",
888
+ "documentation": {}
889
+ },
890
+ {
891
+ "label": "model_dropdown_choice",
892
+ "kind": 5,
893
+ "importPath": "ui.ui_component",
894
+ "description": "ui.ui_component",
895
+ "peekOfCode": "model_dropdown_choice = 2\n# Transcribe components\nui_lang_radio = gr.Radio(\n available_ui_lang, type=\"index\", value=available_ui_lang[ui_lang_index], interactive=True, show_label=False)\ntop_markdown = gr.Markdown(\n current_ui_lang[\"top_markdown\"])\ninput_url = gr.Textbox(\n max_lines=1, label=current_ui_lang[\"input_url_label\"], info=current_ui_lang[\"input_url_info\"], interactive=True)\nurl_download_button = gr.Button(\n current_ui_lang[\"download_button_value\"], size='sm', interactive=True)",
896
+ "detail": "ui.ui_component",
897
+ "documentation": {}
898
+ },
899
+ {
900
+ "label": "ui_lang_radio",
901
+ "kind": 5,
902
+ "importPath": "ui.ui_component",
903
+ "description": "ui.ui_component",
904
+ "peekOfCode": "ui_lang_radio = gr.Radio(\n available_ui_lang, type=\"index\", value=available_ui_lang[ui_lang_index], interactive=True, show_label=False)\ntop_markdown = gr.Markdown(\n current_ui_lang[\"top_markdown\"])\ninput_url = gr.Textbox(\n max_lines=1, label=current_ui_lang[\"input_url_label\"], info=current_ui_lang[\"input_url_info\"], interactive=True)\nurl_download_button = gr.Button(\n current_ui_lang[\"download_button_value\"], size='sm', interactive=True)\ninput_video = gr.Video(\n label=current_ui_lang[\"input_video_label\"], interactive=True)",
905
+ "detail": "ui.ui_component",
906
+ "documentation": {}
907
+ },
908
+ {
909
+ "label": "top_markdown",
910
+ "kind": 5,
911
+ "importPath": "ui.ui_component",
912
+ "description": "ui.ui_component",
913
+ "peekOfCode": "top_markdown = gr.Markdown(\n current_ui_lang[\"top_markdown\"])\ninput_url = gr.Textbox(\n max_lines=1, label=current_ui_lang[\"input_url_label\"], info=current_ui_lang[\"input_url_info\"], interactive=True)\nurl_download_button = gr.Button(\n current_ui_lang[\"download_button_value\"], size='sm', interactive=True)\ninput_video = gr.Video(\n label=current_ui_lang[\"input_video_label\"], interactive=True)\nstart_time = gr.Textbox(\n \"00:00:00\", max_lines=1, placeholder=\"00:00:00\", label=current_ui_lang[\"start_time_label\"], interactive=True)",
914
+ "detail": "ui.ui_component",
915
+ "documentation": {}
916
+ },
917
+ {
918
+ "label": "input_url",
919
+ "kind": 5,
920
+ "importPath": "ui.ui_component",
921
+ "description": "ui.ui_component",
922
+ "peekOfCode": "input_url = gr.Textbox(\n max_lines=1, label=current_ui_lang[\"input_url_label\"], info=current_ui_lang[\"input_url_info\"], interactive=True)\nurl_download_button = gr.Button(\n current_ui_lang[\"download_button_value\"], size='sm', interactive=True)\ninput_video = gr.Video(\n label=current_ui_lang[\"input_video_label\"], interactive=True)\nstart_time = gr.Textbox(\n \"00:00:00\", max_lines=1, placeholder=\"00:00:00\", label=current_ui_lang[\"start_time_label\"], interactive=True)\nend_time = gr.Textbox(\n \"00:15:00\", max_lines=1, placeholder=\"99:99:99\", label=current_ui_lang[\"end_time_label\"], interactive=True)",
923
+ "detail": "ui.ui_component",
924
+ "documentation": {}
925
+ },
926
+ {
927
+ "label": "url_download_button",
928
+ "kind": 5,
929
+ "importPath": "ui.ui_component",
930
+ "description": "ui.ui_component",
931
+ "peekOfCode": "url_download_button = gr.Button(\n current_ui_lang[\"download_button_value\"], size='sm', interactive=True)\ninput_video = gr.Video(\n label=current_ui_lang[\"input_video_label\"], interactive=True)\nstart_time = gr.Textbox(\n \"00:00:00\", max_lines=1, placeholder=\"00:00:00\", label=current_ui_lang[\"start_time_label\"], interactive=True)\nend_time = gr.Textbox(\n \"00:15:00\", max_lines=1, placeholder=\"99:99:99\", label=current_ui_lang[\"end_time_label\"], interactive=True)\nlang_radio = gr.Radio(\n current_ui_lang[\"lang_radio_choices\"], label=current_ui_lang[\"lang_radio_label\"], info=current_ui_lang[\"lang_radio_info\"], type='index', interactive=True)",
932
+ "detail": "ui.ui_component",
933
+ "documentation": {}
934
+ },
935
+ {
936
+ "label": "input_video",
937
+ "kind": 5,
938
+ "importPath": "ui.ui_component",
939
+ "description": "ui.ui_component",
940
+ "peekOfCode": "input_video = gr.Video(\n label=current_ui_lang[\"input_video_label\"], interactive=True)\nstart_time = gr.Textbox(\n \"00:00:00\", max_lines=1, placeholder=\"00:00:00\", label=current_ui_lang[\"start_time_label\"], interactive=True)\nend_time = gr.Textbox(\n \"00:15:00\", max_lines=1, placeholder=\"99:99:99\", label=current_ui_lang[\"end_time_label\"], interactive=True)\nlang_radio = gr.Radio(\n current_ui_lang[\"lang_radio_choices\"], label=current_ui_lang[\"lang_radio_label\"], info=current_ui_lang[\"lang_radio_info\"], type='index', interactive=True)\nmodel_dropdown = gr.Dropdown(\n current_ui_lang[\"model_dropdown_choices\"], label=current_ui_lang[\"model_dropdown_label\"], info=current_ui_lang[\"model_dropdown_info\"], type='index', interactive=True)",
941
+ "detail": "ui.ui_component",
942
+ "documentation": {}
943
+ },
944
+ {
945
+ "label": "start_time",
946
+ "kind": 5,
947
+ "importPath": "ui.ui_component",
948
+ "description": "ui.ui_component",
949
+ "peekOfCode": "start_time = gr.Textbox(\n \"00:00:00\", max_lines=1, placeholder=\"00:00:00\", label=current_ui_lang[\"start_time_label\"], interactive=True)\nend_time = gr.Textbox(\n \"00:15:00\", max_lines=1, placeholder=\"99:99:99\", label=current_ui_lang[\"end_time_label\"], interactive=True)\nlang_radio = gr.Radio(\n current_ui_lang[\"lang_radio_choices\"], label=current_ui_lang[\"lang_radio_label\"], info=current_ui_lang[\"lang_radio_info\"], type='index', interactive=True)\nmodel_dropdown = gr.Dropdown(\n current_ui_lang[\"model_dropdown_choices\"], label=current_ui_lang[\"model_dropdown_label\"], info=current_ui_lang[\"model_dropdown_info\"], type='index', interactive=True)\nstart_button = gr.Button(\n current_ui_lang[\"start_button_value\"], variant=\"primary\", interactive=True)",
950
+ "detail": "ui.ui_component",
951
+ "documentation": {}
952
+ },
953
+ {
954
+ "label": "end_time",
955
+ "kind": 5,
956
+ "importPath": "ui.ui_component",
957
+ "description": "ui.ui_component",
958
+ "peekOfCode": "end_time = gr.Textbox(\n \"00:15:00\", max_lines=1, placeholder=\"99:99:99\", label=current_ui_lang[\"end_time_label\"], interactive=True)\nlang_radio = gr.Radio(\n current_ui_lang[\"lang_radio_choices\"], label=current_ui_lang[\"lang_radio_label\"], info=current_ui_lang[\"lang_radio_info\"], type='index', interactive=True)\nmodel_dropdown = gr.Dropdown(\n current_ui_lang[\"model_dropdown_choices\"], label=current_ui_lang[\"model_dropdown_label\"], info=current_ui_lang[\"model_dropdown_info\"], type='index', interactive=True)\nstart_button = gr.Button(\n current_ui_lang[\"start_button_value\"], variant=\"primary\", interactive=True)\n# Adjust components\nmiddle_markdown = gr.Markdown(",
959
+ "detail": "ui.ui_component",
960
+ "documentation": {}
961
+ },
962
+ {
963
+ "label": "lang_radio",
964
+ "kind": 5,
965
+ "importPath": "ui.ui_component",
966
+ "description": "ui.ui_component",
967
+ "peekOfCode": "lang_radio = gr.Radio(\n current_ui_lang[\"lang_radio_choices\"], label=current_ui_lang[\"lang_radio_label\"], info=current_ui_lang[\"lang_radio_info\"], type='index', interactive=True)\nmodel_dropdown = gr.Dropdown(\n current_ui_lang[\"model_dropdown_choices\"], label=current_ui_lang[\"model_dropdown_label\"], info=current_ui_lang[\"model_dropdown_info\"], type='index', interactive=True)\nstart_button = gr.Button(\n current_ui_lang[\"start_button_value\"], variant=\"primary\", interactive=True)\n# Adjust components\nmiddle_markdown = gr.Markdown(\n current_ui_lang[\"middle_markdown\"])\nadjust_audio = gr.Audio(",
968
+ "detail": "ui.ui_component",
969
+ "documentation": {}
970
+ },
971
+ {
972
+ "label": "model_dropdown",
973
+ "kind": 5,
974
+ "importPath": "ui.ui_component",
975
+ "description": "ui.ui_component",
976
+ "peekOfCode": "model_dropdown = gr.Dropdown(\n current_ui_lang[\"model_dropdown_choices\"], label=current_ui_lang[\"model_dropdown_label\"], info=current_ui_lang[\"model_dropdown_info\"], type='index', interactive=True)\nstart_button = gr.Button(\n current_ui_lang[\"start_button_value\"], variant=\"primary\", interactive=True)\n# Adjust components\nmiddle_markdown = gr.Markdown(\n current_ui_lang[\"middle_markdown\"])\nadjust_audio = gr.Audio(\n interactive=False)\nadjust_speaker = gr.Textbox(",
977
+ "detail": "ui.ui_component",
978
+ "documentation": {}
979
+ },
980
+ {
981
+ "label": "start_button",
982
+ "kind": 5,
983
+ "importPath": "ui.ui_component",
984
+ "description": "ui.ui_component",
985
+ "peekOfCode": "start_button = gr.Button(\n current_ui_lang[\"start_button_value\"], variant=\"primary\", interactive=True)\n# Adjust components\nmiddle_markdown = gr.Markdown(\n current_ui_lang[\"middle_markdown\"])\nadjust_audio = gr.Audio(\n interactive=False)\nadjust_speaker = gr.Textbox(\n label=current_ui_lang[\"adjust_speaker_value\"], interactive=False)\nprev_button = gr.Button(",
986
+ "detail": "ui.ui_component",
987
+ "documentation": {}
988
+ },
989
+ {
990
+ "label": "middle_markdown",
991
+ "kind": 5,
992
+ "importPath": "ui.ui_component",
993
+ "description": "ui.ui_component",
994
+ "peekOfCode": "middle_markdown = gr.Markdown(\n current_ui_lang[\"middle_markdown\"])\nadjust_audio = gr.Audio(\n interactive=False)\nadjust_speaker = gr.Textbox(\n label=current_ui_lang[\"adjust_speaker_value\"], interactive=False)\nprev_button = gr.Button(\n current_ui_lang[\"prev_button_value\"], interactive=False)\nnext_button = gr.Button(\n current_ui_lang[\"next_button_value\"], interactive=False)",
995
+ "detail": "ui.ui_component",
996
+ "documentation": {}
997
+ },
998
+ {
999
+ "label": "adjust_audio",
1000
+ "kind": 5,
1001
+ "importPath": "ui.ui_component",
1002
+ "description": "ui.ui_component",
1003
+ "peekOfCode": "adjust_audio = gr.Audio(\n interactive=False)\nadjust_speaker = gr.Textbox(\n label=current_ui_lang[\"adjust_speaker_value\"], interactive=False)\nprev_button = gr.Button(\n current_ui_lang[\"prev_button_value\"], interactive=False)\nnext_button = gr.Button(\n current_ui_lang[\"next_button_value\"], interactive=False)\nadjust_button = gr.Button(\n current_ui_lang[\"adjust_button_value\"], variant=\"primary\", interactive=False)",
1004
+ "detail": "ui.ui_component",
1005
+ "documentation": {}
1006
+ },
1007
+ {
1008
+ "label": "adjust_speaker",
1009
+ "kind": 5,
1010
+ "importPath": "ui.ui_component",
1011
+ "description": "ui.ui_component",
1012
+ "peekOfCode": "adjust_speaker = gr.Textbox(\n label=current_ui_lang[\"adjust_speaker_value\"], interactive=False)\nprev_button = gr.Button(\n current_ui_lang[\"prev_button_value\"], interactive=False)\nnext_button = gr.Button(\n current_ui_lang[\"next_button_value\"], interactive=False)\nadjust_button = gr.Button(\n current_ui_lang[\"adjust_button_value\"], variant=\"primary\", interactive=False)\n# Result components\nbottom_markdown = gr.Markdown(",
1013
+ "detail": "ui.ui_component",
1014
+ "documentation": {}
1015
+ },
1016
+ {
1017
+ "label": "prev_button",
1018
+ "kind": 5,
1019
+ "importPath": "ui.ui_component",
1020
+ "description": "ui.ui_component",
1021
+ "peekOfCode": "prev_button = gr.Button(\n current_ui_lang[\"prev_button_value\"], interactive=False)\nnext_button = gr.Button(\n current_ui_lang[\"next_button_value\"], interactive=False)\nadjust_button = gr.Button(\n current_ui_lang[\"adjust_button_value\"], variant=\"primary\", interactive=False)\n# Result components\nbottom_markdown = gr.Markdown(\n current_ui_lang[\"bottom_markdown\"])\noutput_video = gr.Video(",
1022
+ "detail": "ui.ui_component",
1023
+ "documentation": {}
1024
+ },
1025
+ {
1026
+ "label": "next_button",
1027
+ "kind": 5,
1028
+ "importPath": "ui.ui_component",
1029
+ "description": "ui.ui_component",
1030
+ "peekOfCode": "next_button = gr.Button(\n current_ui_lang[\"next_button_value\"], interactive=False)\nadjust_button = gr.Button(\n current_ui_lang[\"adjust_button_value\"], variant=\"primary\", interactive=False)\n# Result components\nbottom_markdown = gr.Markdown(\n current_ui_lang[\"bottom_markdown\"])\noutput_video = gr.Video(\n label=current_ui_lang[\"output_video_label\"], interactive=False)\ndownload_video_subtitle_button = gr.Button(",
1031
+ "detail": "ui.ui_component",
1032
+ "documentation": {}
1033
+ },
1034
+ {
1035
+ "label": "adjust_button",
1036
+ "kind": 5,
1037
+ "importPath": "ui.ui_component",
1038
+ "description": "ui.ui_component",
1039
+ "peekOfCode": "adjust_button = gr.Button(\n current_ui_lang[\"adjust_button_value\"], variant=\"primary\", interactive=False)\n# Result components\nbottom_markdown = gr.Markdown(\n current_ui_lang[\"bottom_markdown\"])\noutput_video = gr.Video(\n label=current_ui_lang[\"output_video_label\"], interactive=False)\ndownload_video_subtitle_button = gr.Button(\n current_ui_lang[\"download_video_button_value\"], interactive=False, size='sm')\noutput_file = gr.File(",
1040
+ "detail": "ui.ui_component",
1041
+ "documentation": {}
1042
+ },
1043
+ {
1044
+ "label": "bottom_markdown",
1045
+ "kind": 5,
1046
+ "importPath": "ui.ui_component",
1047
+ "description": "ui.ui_component",
1048
+ "peekOfCode": "bottom_markdown = gr.Markdown(\n current_ui_lang[\"bottom_markdown\"])\noutput_video = gr.Video(\n label=current_ui_lang[\"output_video_label\"], interactive=False)\ndownload_video_subtitle_button = gr.Button(\n current_ui_lang[\"download_video_button_value\"], interactive=False, size='sm')\noutput_file = gr.File(\n file_count=\"multiple\", interactive=False)\noutput_transcribe = gr.Textbox(\n label=current_ui_lang[\"output_transcribe_label\"], interactive=False, show_copy_button=True)",
1049
+ "detail": "ui.ui_component",
1050
+ "documentation": {}
1051
+ },
1052
+ {
1053
+ "label": "output_video",
1054
+ "kind": 5,
1055
+ "importPath": "ui.ui_component",
1056
+ "description": "ui.ui_component",
1057
+ "peekOfCode": "output_video = gr.Video(\n label=current_ui_lang[\"output_video_label\"], interactive=False)\ndownload_video_subtitle_button = gr.Button(\n current_ui_lang[\"download_video_button_value\"], interactive=False, size='sm')\noutput_file = gr.File(\n file_count=\"multiple\", interactive=False)\noutput_transcribe = gr.Textbox(\n label=current_ui_lang[\"output_transcribe_label\"], interactive=False, show_copy_button=True)\n# Summary components\nsummary_markdown = gr.Markdown(",
1058
+ "detail": "ui.ui_component",
1059
+ "documentation": {}
1060
+ },
1061
+ {
1062
+ "label": "download_video_subtitle_button",
1063
+ "kind": 5,
1064
+ "importPath": "ui.ui_component",
1065
+ "description": "ui.ui_component",
1066
+ "peekOfCode": "download_video_subtitle_button = gr.Button(\n current_ui_lang[\"download_video_button_value\"], interactive=False, size='sm')\noutput_file = gr.File(\n file_count=\"multiple\", interactive=False)\noutput_transcribe = gr.Textbox(\n label=current_ui_lang[\"output_transcribe_label\"], interactive=False, show_copy_button=True)\n# Summary components\nsummary_markdown = gr.Markdown(\n current_ui_lang[\"summary_markdown\"])\nsummary_button = gr.Button(",
1067
+ "detail": "ui.ui_component",
1068
+ "documentation": {}
1069
+ },
1070
+ {
1071
+ "label": "output_file",
1072
+ "kind": 5,
1073
+ "importPath": "ui.ui_component",
1074
+ "description": "ui.ui_component",
1075
+ "peekOfCode": "output_file = gr.File(\n file_count=\"multiple\", interactive=False)\noutput_transcribe = gr.Textbox(\n label=current_ui_lang[\"output_transcribe_label\"], interactive=False, show_copy_button=True)\n# Summary components\nsummary_markdown = gr.Markdown(\n current_ui_lang[\"summary_markdown\"])\nsummary_button = gr.Button(\n current_ui_lang[\"summary_button_value\"], variant=\"primary\", interactive=False)\noutput_summary = gr.Textbox(",
1076
+ "detail": "ui.ui_component",
1077
+ "documentation": {}
1078
+ },
1079
+ {
1080
+ "label": "output_transcribe",
1081
+ "kind": 5,
1082
+ "importPath": "ui.ui_component",
1083
+ "description": "ui.ui_component",
1084
+ "peekOfCode": "output_transcribe = gr.Textbox(\n label=current_ui_lang[\"output_transcribe_label\"], interactive=False, show_copy_button=True)\n# Summary components\nsummary_markdown = gr.Markdown(\n current_ui_lang[\"summary_markdown\"])\nsummary_button = gr.Button(\n current_ui_lang[\"summary_button_value\"], variant=\"primary\", interactive=False)\noutput_summary = gr.Textbox(\n label=current_ui_lang[\"output_summary_label\"], interactive=False, show_copy_button=True)",
1085
+ "detail": "ui.ui_component",
1086
+ "documentation": {}
1087
+ },
1088
+ {
1089
+ "label": "summary_markdown",
1090
+ "kind": 5,
1091
+ "importPath": "ui.ui_component",
1092
+ "description": "ui.ui_component",
1093
+ "peekOfCode": "summary_markdown = gr.Markdown(\n current_ui_lang[\"summary_markdown\"])\nsummary_button = gr.Button(\n current_ui_lang[\"summary_button_value\"], variant=\"primary\", interactive=False)\noutput_summary = gr.Textbox(\n label=current_ui_lang[\"output_summary_label\"], interactive=False, show_copy_button=True)",
1094
+ "detail": "ui.ui_component",
1095
+ "documentation": {}
1096
+ },
1097
+ {
1098
+ "label": "summary_button",
1099
+ "kind": 5,
1100
+ "importPath": "ui.ui_component",
1101
+ "description": "ui.ui_component",
1102
+ "peekOfCode": "summary_button = gr.Button(\n current_ui_lang[\"summary_button_value\"], variant=\"primary\", interactive=False)\noutput_summary = gr.Textbox(\n label=current_ui_lang[\"output_summary_label\"], interactive=False, show_copy_button=True)",
1103
+ "detail": "ui.ui_component",
1104
+ "documentation": {}
1105
+ },
1106
+ {
1107
+ "label": "output_summary",
1108
+ "kind": 5,
1109
+ "importPath": "ui.ui_component",
1110
+ "description": "ui.ui_component",
1111
+ "peekOfCode": "output_summary = gr.Textbox(\n label=current_ui_lang[\"output_summary_label\"], interactive=False, show_copy_button=True)",
1112
+ "detail": "ui.ui_component",
1113
+ "documentation": {}
1114
+ }
1115
+ ]
app.py CHANGED
@@ -1,7 +1,11 @@
1
- from ui import *
2
- from adjust import *
3
- from set_up import prepare_input, prepare_video_subtitle
4
  import gradio as gr
 
 
 
 
 
 
 
5
 
6
  with gr.Blocks() as demo:
7
  ui_lang_radio.render()
@@ -17,24 +21,17 @@ with gr.Blocks() as demo:
17
  url_download_button.click(
18
  get_video_from_url, input_url, input_video)
19
  input_video.render()
20
- # input_video.clear(clear_duration, outputs=[
21
- # start_time, end_time])
22
- # input_video_button.render()
23
- # input_video_button.click(get_duration, input_video, [
24
- # start_time, end_time])
25
  with gr.Column():
26
  with gr.Row():
27
  start_time.render()
28
  end_time.render()
29
  lang_radio.render()
30
  model_dropdown.render()
31
- # summary_checkbox.render()
32
  start_button.render()
33
  (
34
  start_button
35
- .click(prepare_input, [input_video, start_time, end_time, lang_radio, model_dropdown], [output_transcribe, output_file])
36
- .success(prepare_output, inputs=input_video, outputs=[adjust_speaker, adjust_audio, prev_button, next_button, adjust_button])
37
- .success(prepare_video_subtitle, inputs=[input_video, start_time, end_time], outputs=output_video)
38
  )
39
 
40
  bottom_markdown.render()
@@ -42,10 +39,14 @@ with gr.Blocks() as demo:
42
  with gr.Column():
43
  output_video.render()
44
  output_file.render()
 
 
 
 
 
45
 
46
  with gr.Column():
47
  output_transcribe.render()
48
- # output_summary.render()
49
 
50
  middle_markdown.render()
51
  with gr.Row(equal_height=False):
@@ -54,20 +55,23 @@ with gr.Blocks() as demo:
54
  with gr.Row():
55
  prev_button.render()
56
  next_button.render()
57
- prev_button.click(get_speakers_previous, inputs=[adjust_speaker], outputs=[
58
- adjust_speaker, adjust_audio])
59
  next_button.click(get_speakers_next, inputs=[adjust_speaker], outputs=[
60
  adjust_speaker, adjust_audio])
61
 
62
  adjust_button.render()
63
- (
64
- adjust_button
65
- .click(start_adjust, inputs=[input_video, adjust_speaker], outputs=[output_transcribe, output_file])
66
- .success(start_adjust_subtitle, inputs=[input_video, start_time, end_time], outputs=output_video)
67
- )
 
 
 
68
 
69
  with gr.Accordion("Copyright"):
70
- gr.Markdown("OpenAI Whisper, Pyannote & Huggingface")
71
 
72
  if __name__ == "__main__":
73
  demo.queue(concurrency_count=2, max_size=2).launch(
 
 
 
 
1
  import gradio as gr
2
+ from ui.ui_component import *
3
+ from ui.lang_setting import *
4
+ from main.adjust import *
5
+ from main.set_up import prepare_input, prepare_video_subtitle
6
+ from main.summary import get_summary
7
+ from tool.gdrive_tool import get_video_from_url
8
+
9
 
10
  with gr.Blocks() as demo:
11
  ui_lang_radio.render()
 
21
  url_download_button.click(
22
  get_video_from_url, input_url, input_video)
23
  input_video.render()
 
 
 
 
 
24
  with gr.Column():
25
  with gr.Row():
26
  start_time.render()
27
  end_time.render()
28
  lang_radio.render()
29
  model_dropdown.render()
 
30
  start_button.render()
31
  (
32
  start_button
33
+ .click(prepare_input, [input_video, start_time, end_time, lang_radio, model_dropdown], [output_transcribe, output_file, output_video])
34
+ .success(prepare_output, inputs=input_video, outputs=[download_video_subtitle_button, adjust_speaker, adjust_audio, prev_button, next_button, adjust_button, summary_button])
 
35
  )
36
 
37
  bottom_markdown.render()
 
39
  with gr.Column():
40
  output_video.render()
41
  output_file.render()
42
+ download_video_subtitle_button.render()
43
+ (
44
+ download_video_subtitle_button
45
+ .click(prepare_video_subtitle, inputs=[input_video, start_time, end_time], outputs=output_file)
46
+ )
47
 
48
  with gr.Column():
49
  output_transcribe.render()
 
50
 
51
  middle_markdown.render()
52
  with gr.Row(equal_height=False):
 
55
  with gr.Row():
56
  prev_button.render()
57
  next_button.render()
58
+ prev_button.click(get_speakers_previous, inputs=[
59
+ adjust_speaker], outputs=[adjust_speaker, adjust_audio])
60
  next_button.click(get_speakers_next, inputs=[adjust_speaker], outputs=[
61
  adjust_speaker, adjust_audio])
62
 
63
  adjust_button.render()
64
+ adjust_button.click(start_adjust, inputs=[adjust_speaker], outputs=[
65
+ output_transcribe, output_file, output_video])
66
+
67
+ summary_markdown.render()
68
+ output_summary.render()
69
+ summary_button.render()
70
+ summary_button.click(get_summary, inputs=lang_radio,
71
+ outputs=output_summary)
72
 
73
  with gr.Accordion("Copyright"):
74
+ gr.Markdown("OpenAI Whisper, OpenAI GPT, Pyannote & Huggingface")
75
 
76
  if __name__ == "__main__":
77
  demo.queue(concurrency_count=2, max_size=2).launch(
file_name.py DELETED
@@ -1,19 +0,0 @@
1
- import os
2
-
3
-
4
- current_working_directory = os.getcwd()
5
-
6
- download_file = f"{current_working_directory}/download_video.mp4"
7
- audio_file = f"{current_working_directory}/input.wav"
8
- transcribe_file = f"{current_working_directory}/transcribe.txt"
9
- cut_video_file = "cut_video.mp4"
10
-
11
- subtitle_file = f"{current_working_directory}/subtitle.srt"
12
- base_subtitle_file = "subtitle.srt"
13
- subtitle_adjusted_file = f"{current_working_directory}/subtitle_adjusted.srt"
14
- base_subtitle_adjusted_file = "subtitle_adjusted.srt"
15
-
16
- transcribe_adjusted_file = f"{current_working_directory}/transcribe_adjusted.txt"
17
- video_subtitle_file = f"{current_working_directory}/output.mp4"
18
- sample_groups_json = f"{current_working_directory}/sample_groups.json"
19
- speaker_groups_json = f"{current_working_directory}/speaker_groups.json"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
adjust.py β†’ main/adjust.py RENAMED
@@ -1,58 +1,44 @@
1
- from ui import *
2
- from file_name import *
3
  from pydub import AudioSegment
4
- from utils import load_groups_json
5
- from video_tool import add_subtitle_to_video
6
- import gradio as gr
7
  import os
8
- import utils
 
 
9
 
10
  min_duration_ms = 10000
11
  current_pos = 0
12
 
13
  speaker_to_name = {"Speaker": "Name"}
14
- speaker_to_sample = {"Speaker": "File"}
15
 
16
  sample_groups = []
17
 
18
 
19
- def get_current():
20
  global speaker_to_name
21
- global speaker_to_sample
 
22
  print(f"GET CURRENT speaker_to_name: {speaker_to_name}")
23
- print(f"GET CURRENT speaker_to_sample: {speaker_to_sample}")
24
 
25
  name = list(speaker_to_name.values())[current_pos]
26
- sample = list(speaker_to_sample.values())[current_pos]
27
  print(f"CURRENT: {name} {sample}")
28
 
29
  return [name, sample]
30
 
31
 
32
- def prepare_output(input_file):
33
- if input_file is None or not os.path.exists(input_file):
34
- return [None, None, None, None, None]
35
-
36
- speakers = get_speakers()
37
- adjust_speaker_update = adjust_speaker.update(
38
- speakers[0], interactive=True)
39
- adjust_audio_update = adjust_audio.update(speakers[1], interactive=True)
40
- prev_button_update = prev_button.update(interactive=True)
41
- next_button_update = next_button.update(interactive=True)
42
- adjust_button_update = adjust_button.update(interactive=True)
43
- # Return adjust speaker, adjust audio, previous, next, adjust button
44
- return [adjust_speaker_update, adjust_audio_update, prev_button_update, next_button_update, adjust_button_update]
45
-
46
-
47
- def get_speakers():
48
  global sample_groups
49
  global speaker_to_name
50
- global speaker_to_sample
51
 
52
  sample_groups, _ = load_groups_json()
53
  print(f"SAMPLE GROUP: {sample_groups}")
54
  speaker_to_name = {}
55
- speaker_to_sample = {}
56
 
57
  for speaker in sample_groups:
58
  for suffix in range(1, 100):
@@ -61,17 +47,43 @@ def get_speakers():
61
  audio_segment = AudioSegment.from_file(file_path)
62
  if len(audio_segment) > min_duration_ms:
63
  print(f"Found file: {file_path}")
64
- print(
65
- f"File duration: {len(audio_segment) / 1000} seconds")
66
  break
67
 
68
  temp_file_name = f"{speaker}-sample.wav"
69
  audio_segment[:10 * 1000].export(temp_file_name, format="wav")
70
- speaker_to_sample[speaker] = temp_file_name
71
  speaker_to_name[speaker] = speaker
72
  print(f"speaker_to_name: {speaker_to_name}")
73
- print(f"speaker_to_sample: {speaker_to_sample}")
74
- return get_current()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
 
77
  def change_name(to_name):
@@ -81,7 +93,7 @@ def change_name(to_name):
81
 
82
  current_speaker = sample_groups[current_pos]
83
  speaker_to_name[current_speaker] = to_name
84
- print(str(get_current()))
85
 
86
 
87
  def get_speakers_next(to_name):
@@ -90,7 +102,7 @@ def get_speakers_next(to_name):
90
  global current_pos
91
  if (current_pos < len(sample_groups) - 1):
92
  current_pos += 1
93
- return get_current()
94
 
95
 
96
  def get_speakers_previous(to_name):
@@ -98,37 +110,31 @@ def get_speakers_previous(to_name):
98
  global current_pos
99
  if (current_pos > 0):
100
  current_pos -= 1
101
- return get_current()
102
-
103
 
104
- def start_adjust_subtitle(input_file, start_time, end_time, progress=gr.Progress()):
105
- # Adding subtitle to video
106
- progress(0.8, desc=ui_lang["progress_add_subtitle"])
107
- add_subtitle_to_video(
108
- input_file, base_subtitle_adjusted_file, video_subtitle_file, start_time, end_time)
109
- return video_subtitle_file
110
 
111
-
112
- def start_adjust(input_file, to_name, progress=gr.Progress()):
113
  change_name(to_name)
114
 
115
  # Replacing texts
116
- progress(0.4, desc=ui_lang["progress_adjust_speaker"])
117
- transcribe_txt_list, subtitle_txt_list = utils.read_transcribe_subtitle_file(input_file,
118
- False)
119
  modified_transcribe = replace_text(transcribe_txt_list)
120
  modified_subtitle = replace_text(subtitle_txt_list)
121
- utils.write_transcribe_subtitle_file(
122
- input_file, modified_transcribe, modified_subtitle, True)
123
 
124
- # Return video file link, transcribe string, transcribe.txt, subtitle.txt
125
- transcribe_txt_list, _ = utils.read_transcribe_subtitle_file(
126
- input_file, True)
127
  print(line for line in transcribe_txt_list)
128
  transcribe_txt = "\n".join(transcribe_txt_list)
 
 
129
  return [
130
  transcribe_txt,
131
- [transcribe_adjusted_file, subtitle_adjusted_file]
 
132
  ]
133
 
134
 
 
1
+ from ui.ui_component import *
2
+ from tool.file_name import *
3
  from pydub import AudioSegment
4
+ from tool.json_tool import load_groups_json
 
 
5
  import os
6
+ import gradio as gr
7
+ import tool.text_file_tool as text_file_tool
8
+
9
 
10
  min_duration_ms = 10000
11
  current_pos = 0
12
 
13
  speaker_to_name = {"Speaker": "Name"}
14
+ speaker_to_sample_file = {"Speaker": "File"}
15
 
16
  sample_groups = []
17
 
18
 
19
+ def get_current_sample_file():
20
  global speaker_to_name
21
+ global speaker_to_sample_file
22
+
23
  print(f"GET CURRENT speaker_to_name: {speaker_to_name}")
24
+ print(f"GET CURRENT speaker_to_sample: {speaker_to_sample_file}")
25
 
26
  name = list(speaker_to_name.values())[current_pos]
27
+ sample = list(speaker_to_sample_file.values())[current_pos]
28
  print(f"CURRENT: {name} {sample}")
29
 
30
  return [name, sample]
31
 
32
 
33
+ def get_sample_file_for_speakers():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  global sample_groups
35
  global speaker_to_name
36
+ global speaker_to_sample_file
37
 
38
  sample_groups, _ = load_groups_json()
39
  print(f"SAMPLE GROUP: {sample_groups}")
40
  speaker_to_name = {}
41
+ speaker_to_sample_file = {}
42
 
43
  for speaker in sample_groups:
44
  for suffix in range(1, 100):
 
47
  audio_segment = AudioSegment.from_file(file_path)
48
  if len(audio_segment) > min_duration_ms:
49
  print(f"Found file: {file_path}")
50
+ print(f"Duration: {len(audio_segment) / 1000} seconds")
 
51
  break
52
 
53
  temp_file_name = f"{speaker}-sample.wav"
54
  audio_segment[:10 * 1000].export(temp_file_name, format="wav")
55
+ speaker_to_sample_file[speaker] = temp_file_name
56
  speaker_to_name[speaker] = speaker
57
  print(f"speaker_to_name: {speaker_to_name}")
58
+ print(f"speaker_to_sample: {speaker_to_sample_file}")
59
+
60
+ return get_current_sample_file()
61
+
62
+
63
+ def prepare_output(input_file):
64
+ if input_file is None or not os.path.exists(input_file):
65
+ raise gr.Error(current_ui_lang["input_video_warning"])
66
+
67
+ speakers = get_sample_file_for_speakers()
68
+
69
+ download_video_update = download_video_subtitle_button.update(
70
+ interactive=True)
71
+ adjust_speaker_update = adjust_speaker.update(
72
+ speakers[0], interactive=True)
73
+ adjust_audio_update = adjust_audio.update(
74
+ speakers[1], interactive=True)
75
+ prev_button_update = prev_button.update(
76
+ interactive=True)
77
+ next_button_update = next_button.update(
78
+ interactive=True)
79
+ adjust_button_update = adjust_button.update(
80
+ interactive=True)
81
+ summary_button_update = summary_button.update(
82
+ interactive=True
83
+ )
84
+
85
+ # Return download button, adjust speaker, adjust audio, previous, next, adjust button
86
+ return [download_video_update, adjust_speaker_update, adjust_audio_update, prev_button_update, next_button_update, adjust_button_update, summary_button_update]
87
 
88
 
89
  def change_name(to_name):
 
93
 
94
  current_speaker = sample_groups[current_pos]
95
  speaker_to_name[current_speaker] = to_name
96
+ print(str(get_current_sample_file()))
97
 
98
 
99
  def get_speakers_next(to_name):
 
102
  global current_pos
103
  if (current_pos < len(sample_groups) - 1):
104
  current_pos += 1
105
+ return get_current_sample_file()
106
 
107
 
108
  def get_speakers_previous(to_name):
 
110
  global current_pos
111
  if (current_pos > 0):
112
  current_pos -= 1
113
+ return get_current_sample_file()
 
114
 
 
 
 
 
 
 
115
 
116
+ def start_adjust(to_name, progress=gr.Progress()):
 
117
  change_name(to_name)
118
 
119
  # Replacing texts
120
+ progress(0.4, desc=current_ui_lang["progress_adjust_speaker"])
121
+ transcribe_txt_list, subtitle_txt_list = text_file_tool.read_transcribe_subtitle_file(
122
+ False)
123
  modified_transcribe = replace_text(transcribe_txt_list)
124
  modified_subtitle = replace_text(subtitle_txt_list)
125
+ text_file_tool.write_transcribe_subtitle_file(
126
+ modified_transcribe, modified_subtitle, True)
127
 
128
+ # Get complete transcribe into string
129
+ transcribe_txt_list, _ = text_file_tool.read_transcribe_subtitle_file(True)
 
130
  print(line for line in transcribe_txt_list)
131
  transcribe_txt = "\n".join(transcribe_txt_list)
132
+
133
+ # Return to output textbox, output files, and output video
134
  return [
135
  transcribe_txt,
136
+ [dir_adjusted_transcribe_file, dir_adjusted_subtitle_file],
137
+ [dir_cut_video_file, dir_adjusted_subtitle_file]
138
  ]
139
 
140
 
diarization.py β†’ main/diarization.py RENAMED
@@ -1,6 +1,6 @@
1
  from pyannote.audio import Pipeline
2
  from pydub import AudioSegment
3
- from file_name import *
4
  import torch
5
  import json
6
  import gc
@@ -9,11 +9,13 @@ import os
9
  gc.collect()
10
  torch.cuda.empty_cache()
11
 
12
- hugging_face_token = os.environ["HUGGING_FACE_TOKEN"]
 
 
13
  pipeline = Pipeline.from_pretrained(
14
  'pyannote/speaker-diarization', use_auth_token=hugging_face_token)
15
- device = torch.device("cuda")
16
- pipeline.to(device)
17
 
18
 
19
  def start_diarization(input_file):
@@ -52,7 +54,7 @@ def audio_segmentation(input_file, speaker_groups_dict):
52
 
53
 
54
  def save_groups_json(input_file, sample_groups_list: list, speaker_groups_dict: dict):
55
- with open(sample_groups_json, "w", encoding="utf-8") as json_file_sample:
56
  json.dump(sample_groups_list, json_file_sample)
57
- with open(speaker_groups_json, "w", encoding="utf-8") as json_file_speaker:
58
  json.dump(speaker_groups_dict, json_file_speaker)
 
1
  from pyannote.audio import Pipeline
2
  from pydub import AudioSegment
3
+ from tool.file_name import *
4
  import torch
5
  import json
6
  import gc
 
9
  gc.collect()
10
  torch.cuda.empty_cache()
11
 
12
+ # FIXME REMEMBER TO DELETE ENVIRON BEFORE COMMIT
13
+ # hugging_face_token = os.environ["HUGGING_FACE_TOKEN"]
14
+ hugging_face_token = "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"
15
  pipeline = Pipeline.from_pretrained(
16
  'pyannote/speaker-diarization', use_auth_token=hugging_face_token)
17
+ use_device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
18
+ pipeline.to(use_device)
19
 
20
 
21
  def start_diarization(input_file):
 
54
 
55
 
56
  def save_groups_json(input_file, sample_groups_list: list, speaker_groups_dict: dict):
57
+ with open(dir_sample_groups_json, "w", encoding="utf-8") as json_file_sample:
58
  json.dump(sample_groups_list, json_file_sample)
59
+ with open(dir_speaker_groups_json, "w", encoding="utf-8") as json_file_speaker:
60
  json.dump(speaker_groups_dict, json_file_speaker)
set_up.py β†’ main/set_up.py RENAMED
@@ -1,73 +1,76 @@
1
- from ui import *
2
- from file_name import *
3
- from diarization import start_diarization
4
- from transcribe import start_transcribe
5
- from video_tool import convert_video_to_audio, add_subtitle_to_video
6
- from datetime import datetime
7
  import gradio as gr
8
  import re
9
  import os
10
- import utils
11
-
12
-
13
- def prepare_video_subtitle(input_file, start_time, end_time, progress=gr.Progress()):
14
- if input_file is None or not os.path.exists(input_file):
15
- raise gr.Error(ui_lang["input_video_warning"])
16
- if validate_time_format(start_time) is False:
17
- raise gr.Error(ui_lang["start_time_warning"])
18
- if validate_time_format(end_time) is False:
19
- raise gr.Error(ui_lang["end_time_warning"])
20
- if (check_if_time_invalid(start_time, end_time)):
21
- raise gr.Error(ui_lang["time_invalid"])
22
- # Add subtitle to video
23
- progress(0.8, desc=ui_lang["progress_add_subtitle"])
24
- add_subtitle_to_video(input_file, base_subtitle_file,
25
- video_subtitle_file, start_time, end_time)
26
- return video_subtitle_file
27
 
28
 
29
  def prepare_input(input_file, start_time, end_time, lang, model_size, progress=gr.Progress()):
30
- gr.Info(ui_lang["progress_starting_process"])
31
 
32
- if input_file is None or not os.path.exists(input_file):
33
- raise gr.Error(ui_lang["input_video_warning"])
34
- if validate_time_format(start_time) is False:
35
- raise gr.Error(ui_lang["start_time_warning"])
36
- if validate_time_format(end_time) is False:
37
- raise gr.Error(ui_lang["end_time_warning"])
38
- if (check_if_time_invalid(start_time, end_time)):
39
- raise gr.Error(ui_lang["time_invalid"])
40
  if lang is None:
41
- raise gr.Error(ui_lang["lang_radio_warning"])
42
  if model_size is None:
43
- raise gr.Error(ui_lang["model_dropdown_warning"])
44
 
45
  print(f"SOURCE: {input_file}")
46
- print(f"AUDIO FILE: {audio_file}")
47
 
48
  # Convert video to audio
49
- progress(0.2, desc=ui_lang["progress_preparing_video"])
50
- convert_video_to_audio(
51
- input_file, audio_file, start_time, end_time)
52
 
53
  # Start diarization
54
- progress(0.4, desc=ui_lang["progress_acquiring_diarization"])
55
- start_diarization(audio_file)
56
 
57
  # Start transcribing
58
- progress(0.6, desc=ui_lang["progress_transcribing_audio"])
59
- start_transcribe(input_file, lang, model_size, progress)
 
 
 
 
60
 
61
- # Return video file link, transcribe string, transcribe.txt, subtitle.txt
62
- transcribe_txt_list, _ = utils.read_transcribe_subtitle_file(
63
- input_file, False)
64
  transcribe_txt = "\n".join(transcribe_txt_list)
 
 
65
  return [
66
  transcribe_txt,
67
- [transcribe_file, subtitle_file]
 
68
  ]
69
 
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  def validate_time_format(input_string):
72
  pattern = re.compile(r'^\d{2}:\d{2}:\d{2}$')
73
  return pattern.match(input_string) is not None
 
1
+ from ui.ui_component import *
2
+ from tool.file_name import *
3
+ from main.diarization import start_diarization
4
+ from main.transcribe import start_transcribe
5
+ from tool.ffmpeg_tool import *
 
6
  import gradio as gr
7
  import re
8
  import os
9
+ import tool.text_file_tool as text_file_tool
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
 
12
  def prepare_input(input_file, start_time, end_time, lang, model_size, progress=gr.Progress()):
13
+ gr.Info(current_ui_lang["progress_starting_process"])
14
 
15
+ check_input_video_settings(input_file, start_time, end_time)
 
 
 
 
 
 
 
16
  if lang is None:
17
+ raise gr.Error(current_ui_lang["lang_radio_warning"])
18
  if model_size is None:
19
+ raise gr.Error(current_ui_lang["model_dropdown_warning"])
20
 
21
  print(f"SOURCE: {input_file}")
 
22
 
23
  # Convert video to audio
24
+ progress(0.2, desc=current_ui_lang["progress_preparing_video"])
25
+ convert_video_to_audio(input_file, start_time, end_time)
 
26
 
27
  # Start diarization
28
+ progress(0.4, desc=current_ui_lang["progress_acquiring_diarization"])
29
+ start_diarization(dir_cut_audio_file)
30
 
31
  # Start transcribing
32
+ progress(0.6, desc=current_ui_lang["progress_transcribing_audio"])
33
+ start_transcribe(lang, model_size, progress)
34
+
35
+ # Cutting video
36
+ progress(0.8, desc=current_ui_lang["progress_cutting_video"])
37
+ cut_video(input_file, start_time, end_time)
38
 
39
+ # Get complete transcribe into string
40
+ transcribe_txt_list, _ = text_file_tool.read_transcribe_subtitle_file(
41
+ False)
42
  transcribe_txt = "\n".join(transcribe_txt_list)
43
+
44
+ # Return to output textbox, output files, and output video
45
  return [
46
  transcribe_txt,
47
+ [dir_adjusted_transcribe_file, dir_adjusted_subtitle_file],
48
+ [dir_cut_video_file, dir_adjusted_subtitle_file]
49
  ]
50
 
51
 
52
+ def prepare_video_subtitle(input_file, start_time, end_time):
53
+ check_input_video_settings(input_file, start_time, end_time)
54
+ gr.Info(current_ui_lang["progress_add_subtitle"])
55
+
56
+ # Add subtitle to video
57
+ add_subtitle_to_video()
58
+
59
+ # Return to output files
60
+ return [dir_base_transcribe_file, dir_base_subtitle_file, dir_video_subtitle_file]
61
+
62
+
63
+ def check_input_video_settings(input_file, start_time, end_time):
64
+ if input_file is None or not os.path.exists(input_file):
65
+ raise gr.Error(current_ui_lang["input_video_warning"])
66
+ if validate_time_format(start_time) is False:
67
+ raise gr.Error(current_ui_lang["start_time_warning"])
68
+ if validate_time_format(end_time) is False:
69
+ raise gr.Error(current_ui_lang["end_time_warning"])
70
+ if (check_if_time_invalid(start_time, end_time)):
71
+ raise gr.Error(current_ui_lang["time_invalid"])
72
+
73
+
74
  def validate_time_format(input_string):
75
  pattern = re.compile(r'^\d{2}:\d{2}:\d{2}$')
76
  return pattern.match(input_string) is not None
main/summary.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import tiktoken
3
+ import tool.text_file_tool as text_file_tool
4
+
5
+
6
+ # FIXME REMEMBER TO DELETE ENVIRON BEFORE COMMIT
7
+ # openai.api_key = os.environ["OPEN_AI_KEY"]
8
+ openai.api_key = "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"
9
+
10
+
11
+ def get_summary(lang_choice: int):
12
+ transcribe_list = text_file_tool.read_simple_transcribe_file()
13
+ transcribe = "\n".join(transcribe_list)
14
+
15
+ encoding = tiktoken.get_encoding("cl100k_base")
16
+ token_num = len(encoding.encode(transcribe))
17
+ print(f"Token number is {token_num}")
18
+
19
+ language = ["English", "Bahasa Indonesia", "Any"]
20
+ result = openai.ChatCompletion.create(
21
+ model="gpt-3.5-turbo" if token_num < 4097 else "gpt-3.5-turbo-16k",
22
+ messages=[
23
+ {"role": "system", "content": "You will make summary from dialogues in a meeting. The summary will only mention core point of the meeting"},
24
+ {"role": "user", "content": "Please provide the dialogue"},
25
+ {"role": "assistant", "content": transcribe},
26
+ {"role": "user",
27
+ "content": f"Write summary for the given meeting dialogue in {language[lang_choice]}"}
28
+ ]
29
+ )
30
+ return result["choices"][0]["message"]["content"]
transcribe.py β†’ main/transcribe.py RENAMED
@@ -1,9 +1,9 @@
1
  from faster_whisper import WhisperModel
2
- from utils import load_groups_json
 
3
  import torch
4
  import gc
5
- from ui import *
6
- import utils
7
 
8
  gc.collect()
9
  torch.cuda.empty_cache()
@@ -12,29 +12,28 @@ model_lang_list = ['en', 'id', None]
12
  model_size = ["tiny", "base", "small", "medium", "large-v2"]
13
 
14
 
15
- def start_transcribe(input_file, lang_choice: int, model_size_choice: int, progress):
16
-
17
  print(
18
  f"Starting transcribing with model size {model_size[model_size_choice]} for language {model_lang_list[lang_choice]}")
19
 
20
- model = WhisperModel(
21
- model_size[model_size_choice], device="cuda", compute_type="int8_float16")
22
  _, speaker_groups = load_groups_json()
23
 
24
  subtitle_txt_list = []
25
  transcribe_txt_list = []
26
- for speaker, _ in zip(speaker_groups, progress.tqdm(speaker_groups, desc=ui_lang["progress_transcribing_audio"])):
 
27
  # Transcribe and save temp file
28
  audiof = f"{speaker}.wav"
29
- print(f"Loading {audiof}")
30
  segments, _ = model.transcribe(
31
  audio=audiof, language=model_lang_list[lang_choice], word_timestamps=True)
32
  segments_list = list(segments)
33
 
34
  speaker_txt_list = []
35
  shift = speaker_groups[speaker][0] + 1
36
- print(
37
- f"Current starting point: {shift}s or {time_str_subtitle(shift)}")
38
  name = str(speaker)[:10]
39
  for segment in segments_list:
40
  start = time_str_subtitle(segment.start + shift)
@@ -43,18 +42,33 @@ def start_transcribe(input_file, lang_choice: int, model_size_choice: int, progr
43
  segment_txt = segment.text
44
  speaker_txt_list.append(segment_txt)
45
 
 
46
  subtitle = f"{len(subtitle_txt_list) + 1}\n{start} --> {end}\n[{name}] {segment_txt}\n\n"
47
  subtitle_txt_list.append(subtitle)
48
 
49
  speaker_txt = " ".join(speaker_txt_list)
50
  transcribe_txt_list.append(
51
  f"[{time_str(shift)}]\n[{name}] {speaker_txt}\n")
 
52
 
53
- utils.write_transcribe_subtitle_file(
54
- input_file, transcribe_txt_list, subtitle_txt_list, False)
 
 
 
 
 
 
 
55
 
56
 
57
  def time_str_subtitle(t):
58
  return '{0:02d}:{1:02d}:{2:06.3f}'.format(round(t // 3600),
59
  round(t % 3600 // 60),
60
  t % 60)
 
 
 
 
 
 
 
1
  from faster_whisper import WhisperModel
2
+ from tool.json_tool import load_groups_json
3
+ from ui.ui_component import *
4
  import torch
5
  import gc
6
+ import tool.text_file_tool as text_file_tool
 
7
 
8
  gc.collect()
9
  torch.cuda.empty_cache()
 
12
  model_size = ["tiny", "base", "small", "medium", "large-v2"]
13
 
14
 
15
+ def start_transcribe(lang_choice: int, model_size_choice: int, progress):
 
16
  print(
17
  f"Starting transcribing with model size {model_size[model_size_choice]} for language {model_lang_list[lang_choice]}")
18
 
19
+ model = WhisperModel(model_size[model_size_choice])
 
20
  _, speaker_groups = load_groups_json()
21
 
22
  subtitle_txt_list = []
23
  transcribe_txt_list = []
24
+ simple_transcribe_txt_list = []
25
+ for speaker, _ in zip(speaker_groups, progress.tqdm(speaker_groups, desc=current_ui_lang["progress_transcribing_audio"])):
26
  # Transcribe and save temp file
27
  audiof = f"{speaker}.wav"
28
+
29
  segments, _ = model.transcribe(
30
  audio=audiof, language=model_lang_list[lang_choice], word_timestamps=True)
31
  segments_list = list(segments)
32
 
33
  speaker_txt_list = []
34
  shift = speaker_groups[speaker][0] + 1
35
+ print(f"Starting point: {shift}s or {time_str_subtitle(shift)}")
36
+
37
  name = str(speaker)[:10]
38
  for segment in segments_list:
39
  start = time_str_subtitle(segment.start + shift)
 
42
  segment_txt = segment.text
43
  speaker_txt_list.append(segment_txt)
44
 
45
+ # TODO CHECK FOR TRIPLE QUOTES
46
  subtitle = f"{len(subtitle_txt_list) + 1}\n{start} --> {end}\n[{name}] {segment_txt}\n\n"
47
  subtitle_txt_list.append(subtitle)
48
 
49
  speaker_txt = " ".join(speaker_txt_list)
50
  transcribe_txt_list.append(
51
  f"[{time_str(shift)}]\n[{name}] {speaker_txt}\n")
52
+ simple_transcribe_txt_list.append(f"{speaker_txt}\n")
53
 
54
+ # Write simple transcribe for summary later
55
+ text_file_tool.write_simple_transcribe_file(
56
+ simple_transcribe_txt_list)
57
+ # Write to base as main
58
+ text_file_tool.write_transcribe_subtitle_file(
59
+ transcribe_txt_list, subtitle_txt_list, False)
60
+ # Write to adjusted as fallout
61
+ text_file_tool.write_transcribe_subtitle_file(
62
+ transcribe_txt_list, subtitle_txt_list, True)
63
 
64
 
65
  def time_str_subtitle(t):
66
  return '{0:02d}:{1:02d}:{2:06.3f}'.format(round(t // 3600),
67
  round(t % 3600 // 60),
68
  t % 60)
69
+
70
+
71
+ def time_str(t):
72
+ return '{0:02d}:{1:02d}:{2:02d}'.format(round(t // 3600),
73
+ round(t % 3600 // 60),
74
+ round(t % 60))
requirements.txt CHANGED
@@ -4,4 +4,6 @@ pyannote-audio @ git+https://github.com/pyannote/pyannote-audio.git
4
  pydub
5
  transformers
6
  torch
7
- faster-whisper
 
 
 
4
  pydub
5
  transformers
6
  torch
7
+ faster-whisper
8
+ tiktoken
9
+ openai
tool/ffmpeg_tool.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tool.file_name import *
2
+ import ffmpeg
3
+
4
+
5
+ def convert_video_to_audio(input_file, start_time, end_time):
6
+ print("CONVERTING VIDEO TO AUDIO")
7
+ print(f"INPUT: {input_file}")
8
+ print(f"OUTPUT: {dir_cut_audio_file}")
9
+
10
+ (
11
+ ffmpeg
12
+ .input(input_file)
13
+ .output(dir_cut_audio_file, ss=start_time, to=end_time, format="wav", acodec='pcm_s16le')
14
+ .run(overwrite_output=True)
15
+ )
16
+
17
+
18
+ def cut_video(input_file, start_time, end_time):
19
+ print("CUTTING VIDEO")
20
+ print(f"INPUT: {input_file}")
21
+ print(f"OUTPUT: {dir_cut_video_file}")
22
+
23
+ (
24
+ ffmpeg
25
+ .input(input_file)
26
+ .output(dir_cut_video_file, ss=start_time, to=end_time, acodec='copy', vcodec='copy')
27
+ .run(overwrite_output=True)
28
+ )
29
+
30
+
31
+ def add_subtitle_to_video():
32
+ print("ADDING SUBTITLE")
33
+ print(f"SUBTITLE: {dir_adjusted_subtitle_file}")
34
+ print(f"OUTPUT: {dir_video_subtitle_file}")
35
+
36
+ (
37
+ ffmpeg
38
+ .input(dir_cut_video_file)
39
+ .output(dir_video_subtitle_file, vf=f'subtitles={dir_adjusted_subtitle_file}', acodec='copy')
40
+ .run(overwrite_output=True)
41
+ )
tool/file_name.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import os
2
+ # TODO DEACTIVATE WORKING DIR FOR A WHILE
3
+ # current_working_directory = os.getcwd()
4
+
5
+ dir_download_file = "download_video.mp4"
6
+ dir_cut_audio_file = "cut_audio.wav"
7
+ dir_cut_video_file = "cut_video.mp4"
8
+
9
+ # BASE FILE CREATED ONLY ONCE
10
+ dir_base_subtitle_file = "subtitle.srt"
11
+ dir_base_transcribe_file = "transcribe.txt"
12
+ dir_adjusted_subtitle_file = "subtitle_adjusted.srt"
13
+ dir_adjusted_transcribe_file = "transcribe_adjusted.txt"
14
+
15
+ dir_video_subtitle_file = "video_subtitle.mp4"
16
+ dir_sample_groups_json = "sample_groups.json"
17
+ dir_speaker_groups_json = "speaker_groups.json"
18
+
19
+ dir_simple_transcribe_file = "simple_transcribe.txt"
tool/gdrive_tool.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tool.file_name import *
2
+ from ui.ui_component import current_ui_lang
3
+ import gradio as gr
4
+ import gdown
5
+
6
+
7
+ def get_video_from_url(url):
8
+ # Download video from google drive with shareable link
9
+ gr.Info(current_ui_lang["get_video_start_info"])
10
+ download_result = gdown.download(
11
+ url, dir_download_file, quiet=False, fuzzy=True)
12
+
13
+ # Raise error if failed
14
+ if (download_result is None):
15
+ raise gr.Error(current_ui_lang["get_video_fail_info"])
16
+
17
+ gr.Info(current_ui_lang["get_video_finished_info"])
18
+ return dir_download_file
tool/json_tool.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tool.file_name import *
2
+ import os
3
+ import json
4
+
5
+
6
+ def load_groups_json():
7
+ if not os.path.exists(dir_sample_groups_json) or not os.path.exists(dir_speaker_groups_json):
8
+ print("JSON file doesn't exist")
9
+ return [], {}
10
+
11
+ with open(dir_sample_groups_json, "r", encoding="utf-8") as json_file_sample:
12
+ sample_groups_list: list = json.load(json_file_sample)
13
+ with open(dir_speaker_groups_json, "r", encoding="utf-8") as json_file_speaker:
14
+ speaker_groups_dict: dict = json.load(json_file_speaker)
15
+ return sample_groups_list, speaker_groups_dict
tool/text_file_tool.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tool.file_name import *
2
+ from ui.ui_component import *
3
+ import gradio as gr
4
+ import os
5
+
6
+
7
+ def write_simple_transcribe_file(simple_transcribe_txt_list: list):
8
+ with open(dir_simple_transcribe_file, "w", encoding="utf-8") as file:
9
+ file.writelines(simple_transcribe_txt_list)
10
+
11
+
12
+ def read_simple_transcribe_file():
13
+ with open(dir_simple_transcribe_file, "r", encoding="utf-8") as file:
14
+ simple_transcribe_txt_list = file.readlines()
15
+ return simple_transcribe_txt_list
16
+
17
+
18
+ def write_transcribe_subtitle_file(transcribe_txt_list: list, subtitle_txt_list: list, write_adjusted_file: bool):
19
+ transcribe = dir_base_transcribe_file
20
+ subtitle = dir_base_subtitle_file
21
+ if write_adjusted_file:
22
+ transcribe = dir_adjusted_transcribe_file
23
+ subtitle = dir_adjusted_subtitle_file
24
+
25
+ with open(transcribe, "w", encoding="utf-8") as file:
26
+ file.writelines(transcribe_txt_list)
27
+ with open(subtitle, "w", encoding="utf-8") as file:
28
+ file.writelines(subtitle_txt_list)
29
+
30
+
31
+ def read_transcribe_subtitle_file(read_adjusted_file: bool):
32
+ transcribe = dir_base_transcribe_file
33
+ subtitle = dir_base_subtitle_file
34
+ if read_adjusted_file:
35
+ transcribe = dir_adjusted_transcribe_file
36
+ subtitle = dir_adjusted_subtitle_file
37
+
38
+ if not os.path.exists(transcribe):
39
+ raise gr.Error(current_ui_lang["file_not_exist"] + ": Transcribe")
40
+ if not os.path.exists(subtitle):
41
+ raise gr.Error(current_ui_lang["file_not_exist"] + ": Subtitle")
42
+
43
+ with open(transcribe, "r", encoding="utf-8") as file:
44
+ transcribe_txt_list = file.readlines()
45
+ with open(subtitle, "r", encoding="utf-8") as file:
46
+ subtitle_txt_list = file.readlines()
47
+ return transcribe_txt_list, subtitle_txt_list
ui.py DELETED
@@ -1,157 +0,0 @@
1
- from lang_ui import get_ui_lang
2
- import gradio as gr
3
- import file_name
4
- import ffmpeg
5
- import gdown
6
- import time
7
-
8
- # Display available langauges and set default UI language
9
- ui_lang_index = 1
10
- available_ui_lang = ["English", "Bahasa Indonesia"]
11
- ui_lang = get_ui_lang(ui_lang_index)
12
-
13
- lang_radio_choice = 1
14
- model_dropdown_choice = 2
15
-
16
- # Transcribe components
17
- ui_lang_radio = gr.Radio(
18
- available_ui_lang, type="index", value=available_ui_lang[ui_lang_index], interactive=True, show_label=False)
19
- top_markdown = gr.Markdown(
20
- ui_lang["top_markdown"])
21
- input_url = gr.Textbox(
22
- max_lines=1, label=ui_lang["input_url_label"], info=ui_lang["input_url_info"], interactive=True)
23
- url_download_button = gr.Button(
24
- ui_lang["download_button_value"], size='sm', interactive=True)
25
- input_video = gr.Video(
26
- label=ui_lang["input_video_label"], interactive=True)
27
- # input_video_button = gr.Button(
28
- # ui_lang["input_video_button_value"], interactive=True)
29
- start_time = gr.Textbox("00:00:00", max_lines=1, placeholder="00:00:00",
30
- label=ui_lang["start_time_label"], interactive=True)
31
- end_time = gr.Textbox("00:00:00", max_lines=1, placeholder="99:99:99",
32
- label=ui_lang["end_time_label"], interactive=True)
33
- lang_radio = gr.Radio(
34
- ui_lang["lang_radio_choices"], label=ui_lang["lang_radio_label"], info=ui_lang["lang_radio_info"], type='index', interactive=True)
35
- model_dropdown = gr.Dropdown(
36
- ui_lang["model_dropdown_choices"], label=ui_lang["model_dropdown_label"], info=ui_lang["model_dropdown_info"], type='index', interactive=True)
37
- summary_checkbox = gr.Checkbox(
38
- label=ui_lang["summary_checkbox_label"], info=ui_lang["summary_checkbox_info"], interactive=False)
39
- start_button = gr.Button(
40
- ui_lang["start_button_value"], variant="primary", interactive=True)
41
-
42
- # Adjust components
43
- middle_markdown = gr.Markdown(
44
- ui_lang["middle_markdown"])
45
- adjust_audio = gr.Audio(interactive=False)
46
- adjust_speaker = gr.Textbox(
47
- label=ui_lang["adjust_speaker_value"], interactive=False)
48
- prev_button = gr.Button(ui_lang["prev_button_value"], interactive=False)
49
- next_button = gr.Button(ui_lang["next_button_value"], interactive=False)
50
- adjust_button = gr.Button(
51
- ui_lang["adjust_button_value"], variant="primary", interactive=False)
52
-
53
- # Result components
54
- bottom_markdown = gr.Markdown(
55
- ui_lang["bottom_markdown"]
56
- )
57
- output_video = gr.Video(label=ui_lang["output_video_label"], interactive=False)
58
- output_file = gr.File(file_count="multiple", interactive=False)
59
- output_transcribe = gr.Textbox(
60
- label=ui_lang["output_transcribe_label"], interactive=False, show_copy_button=True)
61
- output_summary = gr.Textbox(
62
- interactive=False, show_copy_button=True)
63
-
64
-
65
- def time_str(t):
66
- return '{0:02d}:{1:02d}:{2:02d}'.format(round(t // 3600),
67
- round(t % 3600 // 60),
68
- round(t % 60))
69
-
70
-
71
- def get_video_from_url(url):
72
- gr.Info(ui_lang["get_video_start_info"])
73
- download_result = gdown.download(
74
- url, file_name.download_file, quiet=False, fuzzy=True)
75
-
76
- if (download_result is None):
77
- raise gr.Error(ui_lang["get_video_fail_info"])
78
-
79
- gr.Info(ui_lang["get_video_finished_info"])
80
- return file_name.download_file
81
-
82
-
83
- # def clear_duration():
84
- # return [
85
- # start_time.update(None, interactive=False),
86
- # end_time.update(None, interactive=False)
87
- # ]
88
-
89
-
90
- # def get_duration(input_file):
91
- # print("Checking file")
92
- # if input_file is None:
93
- # raise gr.Error(ui_lang["input_video_warning"])
94
- # print("Getting duration & Waiting")
95
- # info_json = ffmpeg.probe(input_file)
96
- # print("Probing finished")
97
- # duration_seconds = float(info_json['format']['duration'])
98
- # duration_formatted = time_str(duration_seconds)
99
- # return [
100
- # start_time.update("00:00:00", interactive=True),
101
- # end_time.update(duration_formatted, interactive=True)
102
- # ]
103
-
104
-
105
- # Change language function
106
-
107
-
108
- def change_lang(input):
109
- global ui_lang
110
- ui_lang = get_ui_lang(input)
111
- print(f"Change language to {available_ui_lang[input]}")
112
- return [
113
- # Top
114
- top_markdown.update(
115
- ui_lang["top_markdown"]),
116
- input_url.update(
117
- label=ui_lang["input_url_label"], info=ui_lang["input_url_info"]),
118
- url_download_button.update(
119
- ui_lang["download_button_value"]),
120
- input_video.update(
121
- label=ui_lang["input_video_label"]),
122
- start_time.update(
123
- label=ui_lang["start_time_label"]),
124
- end_time.update(
125
- label=ui_lang["end_time_label"]),
126
- lang_radio.update(
127
- choices=ui_lang["lang_radio_choices"], value=None, label=ui_lang["lang_radio_label"], info=ui_lang["lang_radio_info"],),
128
- model_dropdown.update(
129
- choices=ui_lang["model_dropdown_choices"], value=None, label=ui_lang["model_dropdown_label"], info=ui_lang["model_dropdown_info"]),
130
- start_button.update(
131
- ui_lang["start_button_value"]),
132
-
133
- # Middle
134
- middle_markdown.update(
135
- ui_lang["middle_markdown"]),
136
- adjust_speaker.update(
137
- label=ui_lang["adjust_speaker_value"]),
138
- prev_button.update(
139
- ui_lang["prev_button_value"]),
140
- next_button.update(
141
- ui_lang["next_button_value"]),
142
- adjust_button.update(
143
- ui_lang["adjust_button_value"]),
144
-
145
- # Bottom
146
- bottom_markdown.update(
147
- ui_lang["bottom_markdown"]),
148
- output_video.update(
149
- label=ui_lang["output_video_label"]),
150
- output_transcribe.update(
151
- label=ui_lang["output_transcribe_label"]),
152
- ]
153
-
154
-
155
- # comp_to_update and change_lang return must always be in equal number
156
- comp_to_update = [
157
- top_markdown, input_url, url_download_button, input_video, start_time, end_time, lang_radio, model_dropdown, start_button, middle_markdown, adjust_speaker, prev_button, next_button, adjust_button, bottom_markdown, output_video, output_transcribe]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lang_ui.py β†’ ui/lang_dictionary.py RENAMED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  english_ui = {
2
  "top_markdown": """
3
  ## Transcribe
@@ -11,6 +16,10 @@ english_ui = {
11
  ## Result
12
  The following is the result of the transcribe
13
  """,
 
 
 
 
14
 
15
  "get_video_start_info": "Start downloading",
16
  "get_video_fail_info": "Failed to download, please make sure the link can be accessed by 'Anyone with the link'",
@@ -30,14 +39,12 @@ english_ui = {
30
  "input_video_button_value": "Process Video",
31
  "start_time_label": "Start time",
32
  "end_time_label": "End time",
33
- "lang_radio_choices": ["English", "Indonesian", "Automatic"],
34
  "lang_radio_label": "Language",
35
  "lang_radio_info": "What language do they speak in the video?",
36
  "model_dropdown_choices": ["tiny", "base", "small", "medium", "large"],
37
  "model_dropdown_label": "Model size",
38
  "model_dropdown_info": "The higher the model, the more accurate the transcript will be but the process will take longer",
39
- "summary_checkbox_label": "Use summary",
40
- "summary_checkbox_info": "Do you need a summary of the transcribe? Note: Result might be inaccurate",
41
  "start_button_value": "Start Transcribing",
42
 
43
  "adjust_speaker_value": "Speaker name",
@@ -47,13 +54,20 @@ english_ui = {
47
 
48
  "output_video_label": "Video with subtitle",
49
  "output_transcribe_label": "Transcribe result",
 
 
 
 
50
 
51
  "progress_starting_process": "Starting process",
52
  "progress_preparing_video": "Preparing video",
53
  "progress_acquiring_diarization": "Acquiring diarization",
54
  "progress_transcribing_audio": "Transcribing audio",
 
55
  "progress_adjust_speaker": "Adjusting speakers",
56
- "progress_add_subtitle": "Adding subtitle on video"
 
 
57
  }
58
 
59
  indonesia_ui = {
@@ -69,6 +83,10 @@ indonesia_ui = {
69
  ## Hasil
70
  Berikut hasil akhir dari transkrip
71
  """,
 
 
 
 
72
 
73
  "get_video_start_info": "Mulai mengunduh",
74
  "get_video_fail_info": "Gagal mengunduh, pastikan tautan dapat diakses oleh 'Siapa saja yang memiliki link'",
@@ -88,14 +106,12 @@ indonesia_ui = {
88
  "input_video_button_value": "Proses Video",
89
  "start_time_label": "Waktu mulai",
90
  "end_time_label": "Waktu selesai",
91
- "lang_radio_choices": ["Bahasa Inggris", "Bahasa Indonesia", "Otomatis"],
92
  "lang_radio_label": "Bahasa",
93
  "lang_radio_info": "Bahasa apa yang digunakan dalam video?",
94
- "model_dropdown_choices": ["mungil", "dasar", "kecil", "sedang", "besar"],
95
  "model_dropdown_label": "Ukuran model",
96
- "model_dropdown_info": "Semakin tinggi modelnya, semakin akurat transkripnya namun prosesnya akan membutuhkan waktu yang lebih lama. Disarankan untuk menggunakan model 'besar'",
97
- "summary_checkbox_label": "Gunakan kesimpulan",
98
- "summary_checkbox_info": "Apakah anda memerlukan kesimpulan dari transkrip? Hasil mungkin tidak sepenuhnya akurat",
99
  "start_button_value": "Mulai Transkrip",
100
 
101
  "adjust_speaker_value": "Nama pembicara",
@@ -105,16 +121,18 @@ indonesia_ui = {
105
 
106
  "output_video_label": "Video dengan subtitle",
107
  "output_transcribe_label": "Hasil transkrip",
 
 
 
 
108
 
109
  "progress_starting_process": "Memulai proses",
110
  "progress_preparing_video": "Mempersiapkan video",
111
  "progress_acquiring_diarization": "Mengenali pembicara",
112
  "progress_transcribing_audio": "Mendapatkan transkrip suara",
 
113
  "progress_adjust_speaker": "Menyesuaikan pembicara",
114
- "progress_add_subtitle": "Menambahkan subtitle pada video"
115
- }
116
-
117
 
118
- def get_ui_lang(index):
119
- selectable_ui_lang = [english_ui, indonesia_ui]
120
- return selectable_ui_lang[index]
 
1
+ def get_ui_dict(index):
2
+ selectable_ui_lang = [english_ui, indonesia_ui]
3
+ return selectable_ui_lang[index]
4
+
5
+
6
  english_ui = {
7
  "top_markdown": """
8
  ## Transcribe
 
16
  ## Result
17
  The following is the result of the transcribe
18
  """,
19
+ "summary_markdown": """
20
+ ## Summary
21
+ You can find the summary of the whole conversation through this dialog
22
+ """,
23
 
24
  "get_video_start_info": "Start downloading",
25
  "get_video_fail_info": "Failed to download, please make sure the link can be accessed by 'Anyone with the link'",
 
39
  "input_video_button_value": "Process Video",
40
  "start_time_label": "Start time",
41
  "end_time_label": "End time",
42
+ "lang_radio_choices": ["English", "Bahasa Indonesia", "Other / Lainnya"],
43
  "lang_radio_label": "Language",
44
  "lang_radio_info": "What language do they speak in the video?",
45
  "model_dropdown_choices": ["tiny", "base", "small", "medium", "large"],
46
  "model_dropdown_label": "Model size",
47
  "model_dropdown_info": "The higher the model, the more accurate the transcript will be but the process will take longer",
 
 
48
  "start_button_value": "Start Transcribing",
49
 
50
  "adjust_speaker_value": "Speaker name",
 
54
 
55
  "output_video_label": "Video with subtitle",
56
  "output_transcribe_label": "Transcribe result",
57
+ "download_video_button_value": "Get Video with Subtitle",
58
+
59
+ "summary_button_value": "Create Summary",
60
+ "output_summary_label": "Summary",
61
 
62
  "progress_starting_process": "Starting process",
63
  "progress_preparing_video": "Preparing video",
64
  "progress_acquiring_diarization": "Acquiring diarization",
65
  "progress_transcribing_audio": "Transcribing audio",
66
+ "progress_cutting_video": "Cutting video",
67
  "progress_adjust_speaker": "Adjusting speakers",
68
+ "progress_add_subtitle": "Adding subtitle on video",
69
+
70
+ "file_not_exist": "File doesn't exist",
71
  }
72
 
73
  indonesia_ui = {
 
83
  ## Hasil
84
  Berikut hasil akhir dari transkrip
85
  """,
86
+ "summary_markdown": """
87
+ ## Kesimpulan
88
+ Anda dapat menemukan kesimpulan dari keseluruhan percakapan melalui dialog berikut
89
+ """,
90
 
91
  "get_video_start_info": "Mulai mengunduh",
92
  "get_video_fail_info": "Gagal mengunduh, pastikan tautan dapat diakses oleh 'Siapa saja yang memiliki link'",
 
106
  "input_video_button_value": "Proses Video",
107
  "start_time_label": "Waktu mulai",
108
  "end_time_label": "Waktu selesai",
109
+ "lang_radio_choices": ["English", "Bahasa Indonesia", "Other / Lainnya"],
110
  "lang_radio_label": "Bahasa",
111
  "lang_radio_info": "Bahasa apa yang digunakan dalam video?",
112
+ "model_dropdown_choices": ["tiny", "base", "small", "medium", "large"],
113
  "model_dropdown_label": "Ukuran model",
114
+ "model_dropdown_info": "Semakin tinggi modelnya, semakin akurat transkripnya. Disarankan untuk menggunakan model 'large'",
 
 
115
  "start_button_value": "Mulai Transkrip",
116
 
117
  "adjust_speaker_value": "Nama pembicara",
 
121
 
122
  "output_video_label": "Video dengan subtitle",
123
  "output_transcribe_label": "Hasil transkrip",
124
+ "download_video_button_value": "Dapatkan File Video dengan Subtitle",
125
+
126
+ "summary_button_value": "Buat Kesimpulan",
127
+ "output_summary_label": "Kesimpulan",
128
 
129
  "progress_starting_process": "Memulai proses",
130
  "progress_preparing_video": "Mempersiapkan video",
131
  "progress_acquiring_diarization": "Mengenali pembicara",
132
  "progress_transcribing_audio": "Mendapatkan transkrip suara",
133
+ "progress_cutting_video": "Memotong video",
134
  "progress_adjust_speaker": "Menyesuaikan pembicara",
135
+ "progress_add_subtitle": "Menambahkan subtitle pada video",
 
 
136
 
137
+ "file_not_exist": "Catatan tidak ditemukan",
138
+ }
 
ui/lang_setting.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ui.ui_component import *
2
+
3
+
4
+ def change_lang(input):
5
+ # Change language function
6
+ global current_ui_lang
7
+ current_ui_lang = get_ui_dict(input)
8
+ print(f"Change language to {available_ui_lang[input]}")
9
+ return [
10
+ # Top
11
+ top_markdown.update(
12
+ current_ui_lang["top_markdown"]),
13
+ input_url.update(
14
+ label=current_ui_lang["input_url_label"], info=current_ui_lang["input_url_info"]),
15
+ url_download_button.update(
16
+ current_ui_lang["download_button_value"]),
17
+ input_video.update(
18
+ label=current_ui_lang["input_video_label"]),
19
+ start_time.update(
20
+ label=current_ui_lang["start_time_label"]),
21
+ end_time.update(
22
+ label=current_ui_lang["end_time_label"]),
23
+ lang_radio.update(
24
+ choices=current_ui_lang["lang_radio_choices"], value=None, label=current_ui_lang["lang_radio_label"], info=current_ui_lang["lang_radio_info"],),
25
+ model_dropdown.update(
26
+ choices=current_ui_lang["model_dropdown_choices"], value=None, label=current_ui_lang["model_dropdown_label"], info=current_ui_lang["model_dropdown_info"]),
27
+ start_button.update(
28
+ current_ui_lang["start_button_value"]),
29
+
30
+ # Middle
31
+ middle_markdown.update(
32
+ current_ui_lang["middle_markdown"]),
33
+ adjust_speaker.update(
34
+ label=current_ui_lang["adjust_speaker_value"]),
35
+ prev_button.update(
36
+ current_ui_lang["prev_button_value"]),
37
+ next_button.update(
38
+ current_ui_lang["next_button_value"]),
39
+ adjust_button.update(
40
+ current_ui_lang["adjust_button_value"]),
41
+
42
+ # Bottom
43
+ bottom_markdown.update(
44
+ current_ui_lang["bottom_markdown"]),
45
+ output_video.update(
46
+ label=current_ui_lang["output_video_label"]),
47
+ download_video_subtitle_button.update(
48
+ current_ui_lang["download_video_button_value"]),
49
+ output_transcribe.update(
50
+ label=current_ui_lang["output_transcribe_label"]),
51
+
52
+ # Summary
53
+ summary_markdown.update(
54
+ current_ui_lang["summary_markdown"]),
55
+ summary_button.update(
56
+ current_ui_lang["summary_button_value"]),
57
+ output_summary.update(
58
+ label=current_ui_lang["output_summary_label"]),
59
+ ]
60
+
61
+
62
+ # comp_to_update and change_lang return must always be equal
63
+ comp_to_update = [
64
+ top_markdown,
65
+ input_url,
66
+ url_download_button,
67
+ input_video,
68
+ start_time,
69
+ end_time,
70
+ lang_radio,
71
+ model_dropdown,
72
+ start_button,
73
+ middle_markdown,
74
+ adjust_speaker,
75
+ prev_button,
76
+ next_button,
77
+ adjust_button,
78
+ bottom_markdown,
79
+ output_video,
80
+ download_video_subtitle_button,
81
+ output_transcribe,
82
+ summary_markdown,
83
+ summary_button,
84
+ output_summary,
85
+ ]
ui/ui_component.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ui.lang_dictionary import get_ui_dict
2
+ import gradio as gr
3
+
4
+ # Display available langauges and set default UI language
5
+ ui_lang_index = 1
6
+ available_ui_lang = ["English", "Bahasa Indonesia"]
7
+ current_ui_lang = get_ui_dict(ui_lang_index)
8
+
9
+ lang_radio_choice = 1
10
+ model_dropdown_choice = 2
11
+
12
+ # Transcribe components
13
+ ui_lang_radio = gr.Radio(
14
+ available_ui_lang, type="index", value=available_ui_lang[ui_lang_index], interactive=True, show_label=False)
15
+ top_markdown = gr.Markdown(
16
+ current_ui_lang["top_markdown"])
17
+ input_url = gr.Textbox(
18
+ max_lines=1, label=current_ui_lang["input_url_label"], info=current_ui_lang["input_url_info"], interactive=True)
19
+ url_download_button = gr.Button(
20
+ current_ui_lang["download_button_value"], size='sm', interactive=True)
21
+ input_video = gr.Video(
22
+ label=current_ui_lang["input_video_label"], interactive=True)
23
+ start_time = gr.Textbox(
24
+ "00:00:00", max_lines=1, placeholder="00:00:00", label=current_ui_lang["start_time_label"], interactive=True)
25
+ end_time = gr.Textbox(
26
+ "00:15:00", max_lines=1, placeholder="99:99:99", label=current_ui_lang["end_time_label"], interactive=True)
27
+ lang_radio = gr.Radio(
28
+ current_ui_lang["lang_radio_choices"], label=current_ui_lang["lang_radio_label"], info=current_ui_lang["lang_radio_info"], type='index', interactive=True)
29
+ model_dropdown = gr.Dropdown(
30
+ current_ui_lang["model_dropdown_choices"], label=current_ui_lang["model_dropdown_label"], info=current_ui_lang["model_dropdown_info"], type='index', interactive=True)
31
+ start_button = gr.Button(
32
+ current_ui_lang["start_button_value"], variant="primary", interactive=True)
33
+
34
+ # Adjust components
35
+ middle_markdown = gr.Markdown(
36
+ current_ui_lang["middle_markdown"])
37
+ adjust_audio = gr.Audio(
38
+ interactive=False)
39
+ adjust_speaker = gr.Textbox(
40
+ label=current_ui_lang["adjust_speaker_value"], interactive=False)
41
+ prev_button = gr.Button(
42
+ current_ui_lang["prev_button_value"], interactive=False)
43
+ next_button = gr.Button(
44
+ current_ui_lang["next_button_value"], interactive=False)
45
+ adjust_button = gr.Button(
46
+ current_ui_lang["adjust_button_value"], variant="primary", interactive=False)
47
+
48
+ # Result components
49
+ bottom_markdown = gr.Markdown(
50
+ current_ui_lang["bottom_markdown"])
51
+ output_video = gr.Video(
52
+ label=current_ui_lang["output_video_label"], interactive=False)
53
+ download_video_subtitle_button = gr.Button(
54
+ current_ui_lang["download_video_button_value"], interactive=False, size='sm')
55
+ output_file = gr.File(
56
+ file_count="multiple", interactive=False)
57
+ output_transcribe = gr.Textbox(
58
+ label=current_ui_lang["output_transcribe_label"], interactive=False, show_copy_button=True)
59
+
60
+ # Summary components
61
+ summary_markdown = gr.Markdown(
62
+ current_ui_lang["summary_markdown"])
63
+ summary_button = gr.Button(
64
+ current_ui_lang["summary_button_value"], variant="primary", interactive=False)
65
+ output_summary = gr.Textbox(
66
+ label=current_ui_lang["output_summary_label"], interactive=False, show_copy_button=True)
utils.py DELETED
@@ -1,46 +0,0 @@
1
- import json
2
- from file_name import *
3
- import os
4
-
5
-
6
- def load_groups_json():
7
- if not os.path.exists(sample_groups_json) or not os.path.exists(speaker_groups_json):
8
- print("JSON file doesn't exist")
9
- return [], {}
10
-
11
- with open(sample_groups_json, "r", encoding="utf-8") as json_file_sample:
12
- sample_groups_list: list = json.load(json_file_sample)
13
- with open(speaker_groups_json, "r", encoding="utf-8") as json_file_speaker:
14
- speaker_groups_dict: dict = json.load(json_file_speaker)
15
- return sample_groups_list, speaker_groups_dict
16
-
17
-
18
- def write_transcribe_subtitle_file(input_file, transcribe_txt_list: list, subtitle_txt_list: list, adjustment: bool):
19
- transcribe = transcribe_file
20
- subtitle = subtitle_file
21
- if adjustment:
22
- transcribe = transcribe_adjusted_file
23
- subtitle = subtitle_adjusted_file
24
-
25
- with open(transcribe, "w", encoding="utf-8") as file:
26
- file.writelines(transcribe_txt_list)
27
- with open(subtitle, "w", encoding="utf-8") as file:
28
- file.writelines(subtitle_txt_list)
29
-
30
-
31
- def read_transcribe_subtitle_file(input_file, adjustment: bool):
32
- transcribe = transcribe_file
33
- subtitle = subtitle_file
34
- if adjustment:
35
- transcribe = transcribe_adjusted_file
36
- subtitle = subtitle_adjusted_file
37
-
38
- if not os.path.exists(transcribe) or not os.path.exists(subtitle):
39
- print("Transcribe or subtitle file doesn't exist")
40
- return [], []
41
-
42
- with open(transcribe, "r", encoding="utf-8") as file:
43
- transcribe_txt_list = file.readlines()
44
- with open(subtitle, "r", encoding="utf-8") as file:
45
- subtitle_txt_list = file.readlines()
46
- return transcribe_txt_list, subtitle_txt_list
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
video_tool.py DELETED
@@ -1,34 +0,0 @@
1
- import ffmpeg
2
- import file_name
3
-
4
-
5
- def convert_video_to_audio(input_file, output_file, start_time, end_time):
6
- print(f"INPUT: {input_file}")
7
- print(f"OUTPUT: {output_file}")
8
-
9
- (
10
- ffmpeg
11
- .input(input_file)
12
- .output(output_file, ss=start_time, to=end_time, format="wav", acodec='pcm_s16le')
13
- .run(overwrite_output=True)
14
- )
15
-
16
-
17
- def add_subtitle_to_video(input_file, subtitle_file, output_file, start_time, end_time):
18
- print(f"INPUT: {input_file}")
19
- print(f"SUBTITLE: {subtitle_file}")
20
- print(f"OUTPUT: {output_file}")
21
-
22
- (
23
- ffmpeg
24
- .input(input_file)
25
- .output(file_name.cut_video_file, ss=start_time, to=end_time, acodec='copy', vcodec='copy')
26
- .run(overwrite_output=True)
27
- )
28
-
29
- (
30
- ffmpeg
31
- .input(file_name.cut_video_file)
32
- .output(output_file, vf=f'subtitles={subtitle_file}', acodec='copy')
33
- .run(overwrite_output=True)
34
- )