marquesafonso commited on
Commit
b6093b0
·
1 Parent(s): 44d365d

separate cli and create api functionality

Browse files
Files changed (7) hide show
  1. .gitignore +1 -0
  2. Pipfile +4 -0
  3. Pipfile.lock +209 -5
  4. cli_app.py +56 -0
  5. main.py +50 -53
  6. utils/process_video.py +27 -0
  7. utils/subtitler.py +5 -1
.gitignore CHANGED
@@ -1,4 +1,5 @@
1
  data/*
 
2
  # Byte-compiled / optimized / DLL files
3
  __pycache__/
4
  *.py[cod]
 
1
  data/*
2
+ temp/
3
  # Byte-compiled / optimized / DLL files
4
  __pycache__/
5
  *.py[cod]
Pipfile CHANGED
@@ -8,6 +8,10 @@ pytube = "*"
8
  faster-whisper = "*"
9
  moviepy = "*"
10
  tqdm = "*"
 
 
 
 
11
 
12
  [dev-packages]
13
 
 
8
  faster-whisper = "*"
9
  moviepy = "*"
10
  tqdm = "*"
11
+ requests = "*"
12
+ python-multipart = "*"
13
+ fastapi = "*"
14
+ uvicorn = "*"
15
 
16
  [dev-packages]
17
 
Pipfile.lock CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "_meta": {
3
  "hash": {
4
- "sha256": "27098db4432ef9d9cfe405af23f5980c4af71c5d79ef8b9f67f922b6b4b6a5ed"
5
  },
6
  "pipfile-spec": 6,
7
  "requires": {
@@ -16,6 +16,22 @@
16
  ]
17
  },
18
  "default": {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  "av": {
20
  "hashes": [
21
  "sha256:04cd0ce13a87870fb0a0ea4673f04934af2b9ac7ae844eafe92e2c19c092ab11",
@@ -169,6 +185,22 @@
169
  "markers": "python_full_version >= '3.7.0'",
170
  "version": "==3.3.2"
171
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  "coloredlogs": {
173
  "hashes": [
174
  "sha256:612ee75c546f53e92e70049c9dbfcc18c935a2b9a53b66085ce9ef6a6e5c0934",
@@ -215,12 +247,19 @@
215
  ],
216
  "version": "==4.4.2"
217
  },
 
 
 
 
 
 
 
 
218
  "faster-whisper": {
219
  "hashes": [
220
  "sha256:591809328b93c8e4594d52097ec6352a270a81fbb7b956254967f28700f7e4da"
221
  ],
222
  "index": "pypi",
223
- "markers": "python_version >= '3.8'",
224
  "version": "==0.10.0"
225
  },
226
  "filelock": {
@@ -246,6 +285,14 @@
246
  "markers": "python_version >= '3.8'",
247
  "version": "==2023.12.2"
248
  },
 
 
 
 
 
 
 
 
249
  "huggingface-hub": {
250
  "hashes": [
251
  "sha256:176a4fc355a851c17550e7619488f383189727eab209534d7cef2114dae77b22",
@@ -467,13 +514,147 @@
467
  "markers": "python_version >= '3.8'",
468
  "version": "==4.25.1"
469
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
  "pytube": {
471
  "hashes": [
472
  "sha256:076052efe76f390dfa24b1194ff821d4e86c17d41cb5562f3a276a8bcbfc9d1d",
473
  "sha256:07b9904749e213485780d7eb606e5e5b8e4341aa4dccf699160876da00e12d78"
474
  ],
475
  "index": "pypi",
476
- "markers": "python_version >= '3.7'",
477
  "version": "==15.0.0"
478
  },
479
  "pyyaml": {
@@ -537,7 +718,7 @@
537
  "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f",
538
  "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"
539
  ],
540
- "markers": "python_version >= '3.7'",
541
  "version": "==2.31.0"
542
  },
543
  "setuptools": {
@@ -548,6 +729,22 @@
548
  "markers": "python_version >= '3.8'",
549
  "version": "==69.0.2"
550
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
551
  "sympy": {
552
  "hashes": [
553
  "sha256:c3588cd4295d0c0f603d0f2ae780587e64e2efeedb3521e46b9bb1d08d184fa5",
@@ -666,7 +863,6 @@
666
  "sha256:d88e651f9db8d8551a62556d3cff9e3034274ca5d66e93197cf2490e2dcb69c7"
667
  ],
668
  "index": "pypi",
669
- "markers": "python_version >= '3.7'",
670
  "version": "==4.66.1"
671
  },
672
  "typing-extensions": {
@@ -684,6 +880,14 @@
684
  ],
685
  "markers": "python_version >= '3.8'",
686
  "version": "==2.1.0"
 
 
 
 
 
 
 
 
687
  }
688
  },
689
  "develop": {}
 
1
  {
2
  "_meta": {
3
  "hash": {
4
+ "sha256": "8f0d40a634119c47c91003d2d9240c3f4f51e916aafde61ae5fc7376e961f54b"
5
  },
6
  "pipfile-spec": 6,
7
  "requires": {
 
16
  ]
17
  },
18
  "default": {
19
+ "annotated-types": {
20
+ "hashes": [
21
+ "sha256:0641064de18ba7a25dee8f96403ebc39113d0cb953a01429249d5c7564666a43",
22
+ "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"
23
+ ],
24
+ "markers": "python_version >= '3.8'",
25
+ "version": "==0.6.0"
26
+ },
27
+ "anyio": {
28
+ "hashes": [
29
+ "sha256:44a3c9aba0f5defa43261a8b3efb97891f2bd7d804e0e1f56419befa1adfc780",
30
+ "sha256:91dee416e570e92c64041bd18b900d1d6fa78dff7048769ce5ac5ddad004fbb5"
31
+ ],
32
+ "markers": "python_version >= '3.7'",
33
+ "version": "==3.7.1"
34
+ },
35
  "av": {
36
  "hashes": [
37
  "sha256:04cd0ce13a87870fb0a0ea4673f04934af2b9ac7ae844eafe92e2c19c092ab11",
 
185
  "markers": "python_full_version >= '3.7.0'",
186
  "version": "==3.3.2"
187
  },
188
+ "click": {
189
+ "hashes": [
190
+ "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28",
191
+ "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"
192
+ ],
193
+ "markers": "python_version >= '3.7'",
194
+ "version": "==8.1.7"
195
+ },
196
+ "colorama": {
197
+ "hashes": [
198
+ "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44",
199
+ "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"
200
+ ],
201
+ "markers": "platform_system == 'Windows'",
202
+ "version": "==0.4.6"
203
+ },
204
  "coloredlogs": {
205
  "hashes": [
206
  "sha256:612ee75c546f53e92e70049c9dbfcc18c935a2b9a53b66085ce9ef6a6e5c0934",
 
247
  ],
248
  "version": "==4.4.2"
249
  },
250
+ "fastapi": {
251
+ "hashes": [
252
+ "sha256:4d12838819aa52af244580675825e750ad67c9df4614f557a769606af902cf22",
253
+ "sha256:f19ebf6fdc82a3281d10f2cb4774bdfa90238e3b40af3525a0c09fd08ad1c480"
254
+ ],
255
+ "index": "pypi",
256
+ "version": "==0.105.0"
257
+ },
258
  "faster-whisper": {
259
  "hashes": [
260
  "sha256:591809328b93c8e4594d52097ec6352a270a81fbb7b956254967f28700f7e4da"
261
  ],
262
  "index": "pypi",
 
263
  "version": "==0.10.0"
264
  },
265
  "filelock": {
 
285
  "markers": "python_version >= '3.8'",
286
  "version": "==2023.12.2"
287
  },
288
+ "h11": {
289
+ "hashes": [
290
+ "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d",
291
+ "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"
292
+ ],
293
+ "markers": "python_version >= '3.7'",
294
+ "version": "==0.14.0"
295
+ },
296
  "huggingface-hub": {
297
  "hashes": [
298
  "sha256:176a4fc355a851c17550e7619488f383189727eab209534d7cef2114dae77b22",
 
514
  "markers": "python_version >= '3.8'",
515
  "version": "==4.25.1"
516
  },
517
+ "pydantic": {
518
+ "hashes": [
519
+ "sha256:80c50fb8e3dcecfddae1adbcc00ec5822918490c99ab31f6cf6140ca1c1429f0",
520
+ "sha256:ff177ba64c6faf73d7afa2e8cad38fd456c0dbe01c9954e71038001cd15a6edd"
521
+ ],
522
+ "markers": "python_version >= '3.7'",
523
+ "version": "==2.5.2"
524
+ },
525
+ "pydantic-core": {
526
+ "hashes": [
527
+ "sha256:038c9f763e650712b899f983076ce783175397c848da04985658e7628cbe873b",
528
+ "sha256:074f3d86f081ce61414d2dc44901f4f83617329c6f3ab49d2bc6c96948b2c26b",
529
+ "sha256:079206491c435b60778cf2b0ee5fd645e61ffd6e70c47806c9ed51fc75af078d",
530
+ "sha256:09b0e985fbaf13e6b06a56d21694d12ebca6ce5414b9211edf6f17738d82b0f8",
531
+ "sha256:0f6116a558fd06d1b7c2902d1c4cf64a5bd49d67c3540e61eccca93f41418124",
532
+ "sha256:103ef8d5b58596a731b690112819501ba1db7a36f4ee99f7892c40da02c3e189",
533
+ "sha256:16e29bad40bcf97aac682a58861249ca9dcc57c3f6be22f506501833ddb8939c",
534
+ "sha256:206ed23aecd67c71daf5c02c3cd19c0501b01ef3cbf7782db9e4e051426b3d0d",
535
+ "sha256:2248485b0322c75aee7565d95ad0e16f1c67403a470d02f94da7344184be770f",
536
+ "sha256:27548e16c79702f1e03f5628589c6057c9ae17c95b4c449de3c66b589ead0520",
537
+ "sha256:2d0ae0d8670164e10accbeb31d5ad45adb71292032d0fdb9079912907f0085f4",
538
+ "sha256:3128e0bbc8c091ec4375a1828d6118bc20404883169ac95ffa8d983b293611e6",
539
+ "sha256:3387277f1bf659caf1724e1afe8ee7dbc9952a82d90f858ebb931880216ea955",
540
+ "sha256:34708cc82c330e303f4ce87758828ef6e457681b58ce0e921b6e97937dd1e2a3",
541
+ "sha256:35613015f0ba7e14c29ac6c2483a657ec740e5ac5758d993fdd5870b07a61d8b",
542
+ "sha256:3ad873900297bb36e4b6b3f7029d88ff9829ecdc15d5cf20161775ce12306f8a",
543
+ "sha256:40180930807ce806aa71eda5a5a5447abb6b6a3c0b4b3b1b1962651906484d68",
544
+ "sha256:439c9afe34638ace43a49bf72d201e0ffc1a800295bed8420c2a9ca8d5e3dbb3",
545
+ "sha256:45e95333b8418ded64745f14574aa9bfc212cb4fbeed7a687b0c6e53b5e188cd",
546
+ "sha256:4641e8ad4efb697f38a9b64ca0523b557c7931c5f84e0fd377a9a3b05121f0de",
547
+ "sha256:49b08aae5013640a3bfa25a8eebbd95638ec3f4b2eaf6ed82cf0c7047133f03b",
548
+ "sha256:4bc536201426451f06f044dfbf341c09f540b4ebdb9fd8d2c6164d733de5e634",
549
+ "sha256:4ce601907e99ea5b4adb807ded3570ea62186b17f88e271569144e8cca4409c7",
550
+ "sha256:4e40f2bd0d57dac3feb3a3aed50f17d83436c9e6b09b16af271b6230a2915459",
551
+ "sha256:4e47a76848f92529879ecfc417ff88a2806438f57be4a6a8bf2961e8f9ca9ec7",
552
+ "sha256:513b07e99c0a267b1d954243845d8a833758a6726a3b5d8948306e3fe14675e3",
553
+ "sha256:531f4b4252fac6ca476fbe0e6f60f16f5b65d3e6b583bc4d87645e4e5ddde331",
554
+ "sha256:57d52fa717ff445cb0a5ab5237db502e6be50809b43a596fb569630c665abddf",
555
+ "sha256:59986de5710ad9613ff61dd9b02bdd2f615f1a7052304b79cc8fa2eb4e336d2d",
556
+ "sha256:5baab5455c7a538ac7e8bf1feec4278a66436197592a9bed538160a2e7d11e36",
557
+ "sha256:5c7d5b5005f177764e96bd584d7bf28d6e26e96f2a541fdddb934c486e36fd59",
558
+ "sha256:60b7607753ba62cf0739177913b858140f11b8af72f22860c28eabb2f0a61937",
559
+ "sha256:615a0a4bff11c45eb3c1996ceed5bdaa2f7b432425253a7c2eed33bb86d80abc",
560
+ "sha256:61ea96a78378e3bd5a0be99b0e5ed00057b71f66115f5404d0dae4819f495093",
561
+ "sha256:652c1988019752138b974c28f43751528116bcceadad85f33a258869e641d753",
562
+ "sha256:6637560562134b0e17de333d18e69e312e0458ee4455bdad12c37100b7cad706",
563
+ "sha256:678265f7b14e138d9a541ddabbe033012a2953315739f8cfa6d754cc8063e8ca",
564
+ "sha256:699156034181e2ce106c89ddb4b6504c30db8caa86e0c30de47b3e0654543260",
565
+ "sha256:6b9ff467ffbab9110e80e8c8de3bcfce8e8b0fd5661ac44a09ae5901668ba997",
566
+ "sha256:6c327e9cd849b564b234da821236e6bcbe4f359a42ee05050dc79d8ed2a91588",
567
+ "sha256:6d30226dfc816dd0fdf120cae611dd2215117e4f9b124af8c60ab9093b6e8e71",
568
+ "sha256:6e227c40c02fd873c2a73a98c1280c10315cbebe26734c196ef4514776120aeb",
569
+ "sha256:6e4d090e73e0725b2904fdbdd8d73b8802ddd691ef9254577b708d413bf3006e",
570
+ "sha256:70f4b4851dbb500129681d04cc955be2a90b2248d69273a787dda120d5cf1f69",
571
+ "sha256:70f947628e074bb2526ba1b151cee10e4c3b9670af4dbb4d73bc8a89445916b5",
572
+ "sha256:774de879d212db5ce02dfbf5b0da9a0ea386aeba12b0b95674a4ce0593df3d07",
573
+ "sha256:77fa384d8e118b3077cccfcaf91bf83c31fe4dc850b5e6ee3dc14dc3d61bdba1",
574
+ "sha256:79e0a2cdbdc7af3f4aee3210b1172ab53d7ddb6a2d8c24119b5706e622b346d0",
575
+ "sha256:7e88f5696153dc516ba6e79f82cc4747e87027205f0e02390c21f7cb3bd8abfd",
576
+ "sha256:7f8210297b04e53bc3da35db08b7302a6a1f4889c79173af69b72ec9754796b8",
577
+ "sha256:81982d78a45d1e5396819bbb4ece1fadfe5f079335dd28c4ab3427cd95389944",
578
+ "sha256:823fcc638f67035137a5cd3f1584a4542d35a951c3cc68c6ead1df7dac825c26",
579
+ "sha256:853a2295c00f1d4429db4c0fb9475958543ee80cfd310814b5c0ef502de24dda",
580
+ "sha256:88e74ab0cdd84ad0614e2750f903bb0d610cc8af2cc17f72c28163acfcf372a4",
581
+ "sha256:8aa1768c151cf562a9992462239dfc356b3d1037cc5a3ac829bb7f3bda7cc1f9",
582
+ "sha256:8c8a8812fe6f43a3a5b054af6ac2d7b8605c7bcab2804a8a7d68b53f3cd86e00",
583
+ "sha256:95b15e855ae44f0c6341ceb74df61b606e11f1087e87dcb7482377374aac6abe",
584
+ "sha256:96581cfefa9123accc465a5fd0cc833ac4d75d55cc30b633b402e00e7ced00a6",
585
+ "sha256:9bd18fee0923ca10f9a3ff67d4851c9d3e22b7bc63d1eddc12f439f436f2aada",
586
+ "sha256:a33324437018bf6ba1bb0f921788788641439e0ed654b233285b9c69704c27b4",
587
+ "sha256:a6a16f4a527aae4f49c875da3cdc9508ac7eef26e7977952608610104244e1b7",
588
+ "sha256:a717aef6971208f0851a2420b075338e33083111d92041157bbe0e2713b37325",
589
+ "sha256:a71891847f0a73b1b9eb86d089baee301477abef45f7eaf303495cd1473613e4",
590
+ "sha256:aae7ea3a1c5bb40c93cad361b3e869b180ac174656120c42b9fadebf685d121b",
591
+ "sha256:ab1cdb0f14dc161ebc268c09db04d2c9e6f70027f3b42446fa11c153521c0e88",
592
+ "sha256:ab4ea451082e684198636565224bbb179575efc1658c48281b2c866bfd4ddf04",
593
+ "sha256:abf058be9517dc877227ec3223f0300034bd0e9f53aebd63cf4456c8cb1e0863",
594
+ "sha256:af36f36538418f3806048f3b242a1777e2540ff9efaa667c27da63d2749dbce0",
595
+ "sha256:b53e9ad053cd064f7e473a5f29b37fc4cc9dc6d35f341e6afc0155ea257fc911",
596
+ "sha256:b7851992faf25eac90bfcb7bfd19e1f5ffa00afd57daec8a0042e63c74a4551b",
597
+ "sha256:b9b759b77f5337b4ea024f03abc6464c9f35d9718de01cfe6bae9f2e139c397e",
598
+ "sha256:ba39688799094c75ea8a16a6b544eb57b5b0f3328697084f3f2790892510d144",
599
+ "sha256:ba6b6b3846cfc10fdb4c971980a954e49d447cd215ed5a77ec8190bc93dd7bc5",
600
+ "sha256:bb4c2eda937a5e74c38a41b33d8c77220380a388d689bcdb9b187cf6224c9720",
601
+ "sha256:c0b97ec434041827935044bbbe52b03d6018c2897349670ff8fe11ed24d1d4ab",
602
+ "sha256:c1452a1acdf914d194159439eb21e56b89aa903f2e1c65c60b9d874f9b950e5d",
603
+ "sha256:c2027d05c8aebe61d898d4cffd774840a9cb82ed356ba47a90d99ad768f39789",
604
+ "sha256:c2adbe22ab4babbca99c75c5d07aaf74f43c3195384ec07ccbd2f9e3bddaecec",
605
+ "sha256:c2d97e906b4ff36eb464d52a3bc7d720bd6261f64bc4bcdbcd2c557c02081ed2",
606
+ "sha256:c339dabd8ee15f8259ee0f202679b6324926e5bc9e9a40bf981ce77c038553db",
607
+ "sha256:c6eae413494a1c3f89055da7a5515f32e05ebc1a234c27674a6956755fb2236f",
608
+ "sha256:c949f04ecad823f81b1ba94e7d189d9dfb81edbb94ed3f8acfce41e682e48cef",
609
+ "sha256:c97bee68898f3f4344eb02fec316db93d9700fb1e6a5b760ffa20d71d9a46ce3",
610
+ "sha256:ca61d858e4107ce5e1330a74724fe757fc7135190eb5ce5c9d0191729f033209",
611
+ "sha256:cb4679d4c2b089e5ef89756bc73e1926745e995d76e11925e3e96a76d5fa51fc",
612
+ "sha256:cb774298da62aea5c80a89bd58c40205ab4c2abf4834453b5de207d59d2e1651",
613
+ "sha256:ccd4d5702bb90b84df13bd491be8d900b92016c5a455b7e14630ad7449eb03f8",
614
+ "sha256:cf9d3fe53b1ee360e2421be95e62ca9b3296bf3f2fb2d3b83ca49ad3f925835e",
615
+ "sha256:d2ae91f50ccc5810b2f1b6b858257c9ad2e08da70bf890dee02de1775a387c66",
616
+ "sha256:d37f8ec982ead9ba0a22a996129594938138a1503237b87318392a48882d50b7",
617
+ "sha256:d81e6987b27bc7d101c8597e1cd2bcaa2fee5e8e0f356735c7ed34368c471550",
618
+ "sha256:dcf4e6d85614f7a4956c2de5a56531f44efb973d2fe4a444d7251df5d5c4dcfd",
619
+ "sha256:de790a3b5aa2124b8b78ae5faa033937a72da8efe74b9231698b5a1dd9be3405",
620
+ "sha256:e47e9a08bcc04d20975b6434cc50bf82665fbc751bcce739d04a3120428f3e27",
621
+ "sha256:e60f112ac88db9261ad3a52032ea46388378034f3279c643499edb982536a093",
622
+ "sha256:e87fc540c6cac7f29ede02e0f989d4233f88ad439c5cdee56f693cc9c1c78077",
623
+ "sha256:eac5c82fc632c599f4639a5886f96867ffced74458c7db61bc9a66ccb8ee3113",
624
+ "sha256:ebb4e035e28f49b6f1a7032920bb9a0c064aedbbabe52c543343d39341a5b2a3",
625
+ "sha256:ec1e72d6412f7126eb7b2e3bfca42b15e6e389e1bc88ea0069d0cc1742f477c6",
626
+ "sha256:ef98ca7d5995a82f43ec0ab39c4caf6a9b994cb0b53648ff61716370eadc43cf",
627
+ "sha256:f0cbc7fff06a90bbd875cc201f94ef0ee3929dfbd5c55a06674b60857b8b85ed",
628
+ "sha256:f4791cf0f8c3104ac668797d8c514afb3431bc3305f5638add0ba1a5a37e0d88",
629
+ "sha256:f5e412d717366e0677ef767eac93566582518fe8be923361a5c204c1a62eaafe",
630
+ "sha256:fb2ed8b3fe4bf4506d6dab3b93b83bbc22237e230cba03866d561c3577517d18",
631
+ "sha256:fe0a5a1025eb797752136ac8b4fa21aa891e3d74fd340f864ff982d649691867"
632
+ ],
633
+ "markers": "python_version >= '3.7'",
634
+ "version": "==2.14.5"
635
+ },
636
+ "pyreadline3": {
637
+ "hashes": [
638
+ "sha256:6f3d1f7b8a31ba32b73917cefc1f28cc660562f39aea8646d30bd6eff21f7bae",
639
+ "sha256:b0efb6516fd4fb07b45949053826a62fa4cb353db5be2bbb4a7aa1fdd1e345fb"
640
+ ],
641
+ "markers": "python_version >= '3.8' and sys_platform == 'win32'",
642
+ "version": "==3.4.1"
643
+ },
644
+ "python-multipart": {
645
+ "hashes": [
646
+ "sha256:e9925a80bb668529f1b67c7fdb0a5dacdd7cbfc6fb0bff3ea443fe22bdd62132",
647
+ "sha256:ee698bab5ef148b0a760751c261902cd096e57e10558e11aca17646b74ee1c18"
648
+ ],
649
+ "index": "pypi",
650
+ "version": "==0.0.6"
651
+ },
652
  "pytube": {
653
  "hashes": [
654
  "sha256:076052efe76f390dfa24b1194ff821d4e86c17d41cb5562f3a276a8bcbfc9d1d",
655
  "sha256:07b9904749e213485780d7eb606e5e5b8e4341aa4dccf699160876da00e12d78"
656
  ],
657
  "index": "pypi",
 
658
  "version": "==15.0.0"
659
  },
660
  "pyyaml": {
 
718
  "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f",
719
  "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1"
720
  ],
721
+ "index": "pypi",
722
  "version": "==2.31.0"
723
  },
724
  "setuptools": {
 
729
  "markers": "python_version >= '3.8'",
730
  "version": "==69.0.2"
731
  },
732
+ "sniffio": {
733
+ "hashes": [
734
+ "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101",
735
+ "sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384"
736
+ ],
737
+ "markers": "python_version >= '3.7'",
738
+ "version": "==1.3.0"
739
+ },
740
+ "starlette": {
741
+ "hashes": [
742
+ "sha256:6a6b0d042acb8d469a01eba54e9cda6cbd24ac602c4cd016723117d6a7e73b75",
743
+ "sha256:918416370e846586541235ccd38a474c08b80443ed31c578a418e2209b3eef91"
744
+ ],
745
+ "markers": "python_version >= '3.7'",
746
+ "version": "==0.27.0"
747
+ },
748
  "sympy": {
749
  "hashes": [
750
  "sha256:c3588cd4295d0c0f603d0f2ae780587e64e2efeedb3521e46b9bb1d08d184fa5",
 
863
  "sha256:d88e651f9db8d8551a62556d3cff9e3034274ca5d66e93197cf2490e2dcb69c7"
864
  ],
865
  "index": "pypi",
 
866
  "version": "==4.66.1"
867
  },
868
  "typing-extensions": {
 
880
  ],
881
  "markers": "python_version >= '3.8'",
882
  "version": "==2.1.0"
883
+ },
884
+ "uvicorn": {
885
+ "hashes": [
886
+ "sha256:09c8e5a79dc466bdf28dead50093957db184de356fcdc48697bad3bde4c2588e",
887
+ "sha256:7c84fea70c619d4a710153482c0d230929af7bcf76c7bfa6de151f0a3a80121e"
888
+ ],
889
+ "index": "pypi",
890
+ "version": "==0.24.0.post1"
891
  }
892
  },
893
  "develop": {}
cli_app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from argparse import ArgumentParser
2
+ from utils.download_video import download_video
3
+ from utils.transcriber import transcriber
4
+ from utils.subtitler import subtitler
5
+ import logging, os
6
+ from tqdm import tqdm
7
+
8
+ logging.basicConfig(filename='main.log',
9
+ encoding='utf-8',
10
+ level=logging.DEBUG,
11
+ format='%(asctime)s %(levelname)s %(message)s',
12
+ datefmt='%m/%d/%Y %I:%M:%S %p')
13
+
14
+ def main(video_url,
15
+ invideo_filename,
16
+ fontsize,
17
+ bg_color,
18
+ max_words_per_line
19
+ ):
20
+ INVIDEO_DIR = os.path.join('data/',invideo_filename)
21
+ if not os.path.exists(INVIDEO_DIR):
22
+ os.makedirs(INVIDEO_DIR)
23
+ SRT_PATH = os.path.join(INVIDEO_DIR, f"{invideo_filename}.srt")
24
+ OUTVIDEO_PATH = os.path.join(INVIDEO_DIR, f"result_{invideo_filename}.mp4")
25
+ with tqdm(total=100, desc="Overall Progress") as pbar:
26
+ if video_url != None:
27
+ stream_title = download_video(video_url, INVIDEO_DIR, invideo_filename)
28
+ pbar.update(33.33)
29
+ if not os.path.exists(SRT_PATH):
30
+ transcriber(stream_title, SRT_PATH, max_words_per_line)
31
+ pbar.update(33.33)
32
+ subtitler(stream_title, SRT_PATH, OUTVIDEO_PATH,fontsize, bg_color)
33
+ pbar.update(33.34)
34
+ return
35
+ INVIDEO_PATH = os.path.join(INVIDEO_DIR, f"{invideo_filename}.mp4")
36
+ if not os.path.exists(SRT_PATH):
37
+ transcriber(INVIDEO_PATH, SRT_PATH, max_words_per_line)
38
+ pbar.update(66.66)
39
+ subtitler(INVIDEO_PATH, SRT_PATH, OUTVIDEO_PATH, fontsize,bg_color)
40
+ pbar.update(33.34)
41
+
42
+ if __name__ == '__main__':
43
+ parser = ArgumentParser()
44
+ parser.add_argument('--invideo_filename', required=True, type=str, help='filename')
45
+ parser.add_argument('--video_url', required=False, default=None, type=str, help='A video file to be subtitled (Optional)')
46
+ parser.add_argument('--fontsize', required=False, default=32, type=int, help='Font size for captions (int)')
47
+ parser.add_argument('--bg_color', required=False, default="#070a13b3", type=str, help='Hex color value for caption background colour.')
48
+ parser.add_argument("--max_words_per_line", type=int, default=None, help="(requires --word_timestamps True, no effect with --max_line_width) the maximum number of words in a segment")
49
+ args = parser.parse_args()
50
+ # Example usage
51
+ main(args.video_url,
52
+ args.invideo_filename,
53
+ args.fontsize,
54
+ args.bg_color,
55
+ args.max_words_per_line,
56
+ )
main.py CHANGED
@@ -1,56 +1,53 @@
1
- from argparse import ArgumentParser
2
- from utils.download_video import download_video
3
- from utils.transcriber import transcriber
4
- from utils.subtitler import subtitler
5
- import logging, os
6
- from tqdm import tqdm
7
 
8
- logging.basicConfig(filename='main.log',
9
- encoding='utf-8',
10
- level=logging.DEBUG,
11
- format='%(asctime)s %(levelname)s %(message)s',
12
- datefmt='%m/%d/%Y %I:%M:%S %p')
13
 
14
- def main(video_url,
15
- invideo_filename,
16
- fontsize,
17
- bg_color,
18
- max_words_per_line
19
- ):
20
- INVIDEO_DIR = os.path.join('data/',invideo_filename)
21
- if not os.path.exists(INVIDEO_DIR):
22
- os.makedirs(INVIDEO_DIR)
23
- SRT_PATH = os.path.join(INVIDEO_DIR, f"{invideo_filename}.srt")
24
- OUTVIDEO_PATH = os.path.join(INVIDEO_DIR, f"result_{invideo_filename}.mp4")
25
- with tqdm(total=100, desc="Overall Progress") as pbar:
26
- if video_url != None:
27
- stream_title = download_video(video_url, INVIDEO_DIR, invideo_filename)
28
- pbar.update(33.33)
29
- if not os.path.exists(SRT_PATH):
30
- transcriber(stream_title, SRT_PATH, max_words_per_line)
31
- pbar.update(33.33)
32
- subtitler(stream_title, SRT_PATH, OUTVIDEO_PATH,fontsize, bg_color)
33
- pbar.update(33.34)
34
- return
35
- INVIDEO_PATH = os.path.join(INVIDEO_DIR, f"{invideo_filename}.mp4")
36
- if not os.path.exists(SRT_PATH):
37
- transcriber(INVIDEO_PATH, SRT_PATH, max_words_per_line)
38
- pbar.update(66.66)
39
- subtitler(INVIDEO_PATH, SRT_PATH, OUTVIDEO_PATH, fontsize,bg_color)
40
- pbar.update(33.34)
41
 
42
- if __name__ == '__main__':
43
- parser = ArgumentParser()
44
- parser.add_argument('--invideo_filename', required=True, type=str, help='filename')
45
- parser.add_argument('--video_url', required=False, default=None, type=str, help='A video file to be subtitled (Optional)')
46
- parser.add_argument('--fontsize', required=False, default=32, type=int, help='Font size for captions (int)')
47
- parser.add_argument('--bg_color', required=False, default="#070a13b3", type=str, help='Hex color value for caption background colour.')
48
- parser.add_argument("--max_words_per_line", type=int, default=None, help="(requires --word_timestamps True, no effect with --max_line_width) the maximum number of words in a segment")
49
- args = parser.parse_args()
50
- # Example usage
51
- main(args.video_url,
52
- args.invideo_filename,
53
- args.fontsize,
54
- args.bg_color,
55
- args.max_words_per_line,
56
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, UploadFile, File, HTTPException, Form
2
+ from fastapi.responses import FileResponse, HTMLResponse
3
+ from typing import Optional
4
+ from utils.process_video import process_video
5
+ import shutil, os
 
6
 
7
+ app = FastAPI()
 
 
 
 
8
 
9
+ @app.get("/")
10
+ async def root():
11
+ return {"message": "Hello from multilang-asr-captioner"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
+ @app.get("/submit_video/")
14
+ async def get_form():
15
+ html_content = """
16
+ <html>
17
+ <body>
18
+ <form action="/process_video/" enctype="multipart/form-data" method="post">
19
+ <input type="file" name="file"><br>
20
+ Font size: <input type="number" name="fontsize" value="32"><br>
21
+ Background color: <input type="text" name="bg_color" value="#070a13b3"><br>
22
+ Max words per line: <input type="number" name="max_words_per_line" value="8"><br>
23
+ <input type="submit">
24
+ </form>
25
+ </body>
26
+ </html>
27
+ """
28
+ return HTMLResponse(content=html_content)
29
+
30
+ @app.post("/process_video/")
31
+ async def process_video_api(file: UploadFile = File(...),
32
+ fontsize: Optional[int] = Form(32),
33
+ bg_color: Optional[str] = Form("#070a13b3"),
34
+ max_words_per_line: Optional[int] = Form(8)):
35
+ try:
36
+ if not str(file.filename).endswith('.mp4'):
37
+ raise HTTPException(status_code=400, detail="Invalid file type. Please upload an MP4 file.")
38
+ # Save the uploaded file to a temporary file
39
+ temp_dir = os.path.join(os.getcwd(),"temp")
40
+ os.makedirs(temp_dir, exist_ok=True)
41
+ temp_input_path = os.path.join(temp_dir, file.filename)
42
+ # Copy UploadFile to the temp_input_path
43
+ with open(temp_input_path, 'wb') as buffer:
44
+ try:
45
+ shutil.copyfileobj(file.file, buffer)
46
+ finally:
47
+ file.file.close()
48
+ # Process the video
49
+ output_path = process_video(temp_input_path, fontsize, bg_color, max_words_per_line)
50
+ # Return the processed video file
51
+ return FileResponse(output_path, media_type="video/mp4", filename=f"result_{file.filename}")
52
+ except Exception as e:
53
+ raise HTTPException(status_code=500, detail=str(e))
utils/process_video.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Import necessary modules
2
+ from utils.download_video import download_video
3
+ from utils.transcriber import transcriber
4
+ from utils.subtitler import subtitler
5
+ import logging, os
6
+
7
+ # Set up logging
8
+ logging.basicConfig(filename='main.log',
9
+ encoding='utf-8',
10
+ level=logging.DEBUG,
11
+ format='%(asctime)s %(levelname)s %(message)s',
12
+ datefmt='%m/%d/%Y %I:%M:%S %p')
13
+
14
+ # API Function
15
+ def process_video(invideo_filename:str,
16
+ fontsize:str,
17
+ bg_color:str,
18
+ max_words_per_line:int
19
+ ):
20
+ SRT_PATH = os.path.abspath(f"{invideo_filename.split('.')[0]}.srt")
21
+ OUTVIDEO_PATH = os.path.join("temp/", f"result.mp4")
22
+ if not os.path.exists(SRT_PATH):
23
+ transcriber(invideo_filename, SRT_PATH, max_words_per_line)
24
+ logging.info("Transcription Complete")
25
+ subtitler(invideo_filename, SRT_PATH, OUTVIDEO_PATH, fontsize, bg_color)
26
+ logging.info("Subtitling Complete")
27
+ return OUTVIDEO_PATH
utils/subtitler.py CHANGED
@@ -22,7 +22,11 @@ def parse_srt(srt_file):
22
  return subtitles
23
 
24
 
25
- def subtitler(video_file, srt_file, output_file,fontsize, bg_color):
 
 
 
 
26
  """Add subtitles from an SRT file to a video."""
27
  video_file = os.path.abspath(video_file)
28
  srt_file = os.path.abspath(srt_file)
 
22
  return subtitles
23
 
24
 
25
+ def subtitler(video_file:str,
26
+ srt_file:str,
27
+ output_file:str,
28
+ fontsize:int,
29
+ bg_color:str):
30
  """Add subtitles from an SRT file to a video."""
31
  video_file = os.path.abspath(video_file)
32
  srt_file = os.path.abspath(srt_file)