Refactoring: adapted for changes in cuda, updated README.md, improved logger and added sentence level transcript generation.

Signed-off-by: Orihara Izaya <xloki.stormbringery@gmail.com>
This commit is contained in:
Orihara Izaya
2024-11-27 16:06:36 +01:00
parent df1a3c075b
commit bff7ceb81c
15 changed files with 576 additions and 237 deletions
+12 -12
View File
@@ -1,32 +1,32 @@
import os
import unittest
from src.file_manager import FileManager
from src.video_manager import VideoManager
class FileManagerTest(unittest.TestCase):
class VideoManagerTest(unittest.TestCase):
def setUp(self):
self.file_manager = FileManager()
self.dir = '<Your file directory>' # replace with your directory
self.file_manager = VideoManager()
self.dir = "<Your file directory>"
def test_download_youtube_audio(self):
youtube_link = '<Your YouTube link>' # replace with a YouTube link
filename = f'{self.dir}/audio.mp4'
youtube_link = "<Your YouTube link>"
filename = f"{self.dir}/audio.mp4"
self.file_manager.download_youtube_audio(youtube_link, filename)
self.assertTrue(os.path.exists(filename))
os.remove(filename) # clean up after test
os.remove(filename)
def test_convert_to_wav(self):
mp4_file = '<Your mp4 filename>' # replace with an MP4 file in your directory
wav_file = mp4_file.replace('.mp4', '.wav')
mp4_file = "<Your mp4 filename>"
wav_file = mp4_file.replace(".mp4", ".wav")
self.file_manager.convert_to_wav(mp4_file, wav_file)
self.assertTrue(os.path.exists(wav_file))
os.remove(wav_file) # clean up after test
os.remove(wav_file)
def test_load_local_file(self):
local_file_path = '<Your mp4 filename>' # replace with a file in your directory
local_file_path = "<Your mp4 filename>"
result_path = self.file_manager.load_local_file(local_file_path)
self.assertEqual(result_path, local_file_path.replace('.mp4', '.wav'))
self.assertEqual(result_path, local_file_path.replace(".mp4", ".wav"))
if __name__ == "__main__":
+1 -16
View File
@@ -1,4 +1,3 @@
import os
import unittest
from src.transcriber import Transcriber
@@ -9,24 +8,10 @@ class TranscriberTest(unittest.TestCase):
self.transcriber = Transcriber()
def test_transcribe(self):
wav_file = '<Your wav file>' # Replace with path to a .wav file on your machine
wav_file = "<Your wav file>"
result = self.transcriber.transcribe(wav_file)
self.assertIsNotNone(result)
def test_save_transcript(self):
wav_file = '<Your wav file>' # Replace with path to a .wav file on your machine
result = self.transcriber.transcribe(wav_file)
json_output_file = '<Path to your temporary JSON output file>' # Temporary output file for testing
txt_output_file = '<Path to your temporary TXT output file>' # Temporary output file for testing
self.transcriber.save_transcript(json_output_file, txt_output_file)
self.assertTrue(os.path.exists(json_output_file))
self.assertTrue(os.path.exists(txt_output_file))
os.remove(json_output_file) # clean up after test
os.remove(txt_output_file) # clean up after test
if __name__ == "__main__":
unittest.main()